Spring Framework

org.springframework.jms.listener.endpoint
Class DefaultJmsActivationSpecFactory

java.lang.Object
  extended by org.springframework.jms.listener.endpoint.StandardJmsActivationSpecFactory
      extended by org.springframework.jms.listener.endpoint.DefaultJmsActivationSpecFactory
All Implemented Interfaces:
JmsActivationSpecFactory

public class DefaultJmsActivationSpecFactory
extends StandardJmsActivationSpecFactory

Default implementation of the JmsActivationSpecFactory interface. Supports the standard JMS properties as defined by the JMS 1.5 specification, as well as Spring's extended "maxConcurrency" and "prefetchSize" settings through autodetection of well-known vendor-specific provider properties.

An ActivationSpec factory is effectively dependent on the concrete JMS provider, e.g. on ActiveMQ. This default implementation simply guesses the ActivationSpec class name from the provider's class name ("ActiveMQResourceAdapter" -> "ActiveMQActivationSpec" in the same package, or "ActivationSpecImpl" in the same package as the ResourceAdapter class), and populates the ActivationSpec properties as suggested by the JCA 1.5 specification (Appendix B). Specify the 'activationSpecClass' property explicitly if these default naming rules do not apply.

Note: ActiveMQ, JORAM and WebSphere are supported in terms of extended settings (through the detection of their bean property naming conventions). The default ActivationSpec class detection rules may apply to other JMS providers as well.

Thanks to Agim Emruli and Laurie Chan for pointing out WebSphere MQ settings and contributing corresponding tests!

Since:
2.5
Author:
Juergen Hoeller
See Also:
StandardJmsActivationSpecFactory.setActivationSpecClass(java.lang.Class)

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
 
Constructor Summary
DefaultJmsActivationSpecFactory()
           
 
Method Summary
protected  void applyAcknowledgeMode(BeanWrapper bw, int ackMode)
          This implementation maps SESSION_TRANSACTED onto an ActivationSpec property named "useRAManagedTransaction", if available (following ActiveMQ's naming conventions).
protected  java.lang.Class determineActivationSpecClass(javax.resource.spi.ResourceAdapter adapter)
          This implementation guesses the ActivationSpec class name from the provider's class name: e.g.
protected  void populateActivationSpecProperties(BeanWrapper bw, JmsActivationSpecConfig config)
          This implementation supports Spring's extended "maxConcurrency" and "prefetchSize" settings through detecting corresponding ActivationSpec properties: "maxSessions"/"maxNumberOfWorks" and "maxMessagesPerSessions"/"maxMessages", respectively (following ActiveMQ's and JORAM's naming conventions).
 
Methods inherited from class org.springframework.jms.listener.endpoint.StandardJmsActivationSpecFactory
createActivationSpec, setActivationSpecClass, setDefaultProperties, setDestinationResolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

DefaultJmsActivationSpecFactory

public DefaultJmsActivationSpecFactory()
Method Detail

determineActivationSpecClass

protected java.lang.Class determineActivationSpecClass(javax.resource.spi.ResourceAdapter adapter)
This implementation guesses the ActivationSpec class name from the provider's class name: e.g. "ActiveMQResourceAdapter" -> "ActiveMQActivationSpec" in the same package, or a class named "ActivationSpecImpl" in the same package as the ResourceAdapter class.

Overrides:
determineActivationSpecClass in class StandardJmsActivationSpecFactory
Parameters:
adapter - the ResourceAdapter to check
Returns:
the corresponding ActivationSpec class, or null if not determinable
See Also:
StandardJmsActivationSpecFactory.setActivationSpecClass(java.lang.Class)

populateActivationSpecProperties

protected void populateActivationSpecProperties(BeanWrapper bw,
                                                JmsActivationSpecConfig config)
This implementation supports Spring's extended "maxConcurrency" and "prefetchSize" settings through detecting corresponding ActivationSpec properties: "maxSessions"/"maxNumberOfWorks" and "maxMessagesPerSessions"/"maxMessages", respectively (following ActiveMQ's and JORAM's naming conventions).

Overrides:
populateActivationSpecProperties in class StandardJmsActivationSpecFactory
Parameters:
bw - the BeanWrapper wrapping the ActivationSpec object
config - the configured object holding common JMS settings

applyAcknowledgeMode

protected void applyAcknowledgeMode(BeanWrapper bw,
                                    int ackMode)
This implementation maps SESSION_TRANSACTED onto an ActivationSpec property named "useRAManagedTransaction", if available (following ActiveMQ's naming conventions).

Overrides:
applyAcknowledgeMode in class StandardJmsActivationSpecFactory
Parameters:
bw - the BeanWrapper wrapping the ActivationSpec object
ackMode - the configured acknowledge mode (according to the constants in Session
See Also:
Session.AUTO_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.SESSION_TRANSACTED

Spring Framework