The Spring Framework

org.springframework.jms.support
Class JmsAccessor

java.lang.Object
  extended by org.springframework.jms.support.JmsAccessor
All Implemented Interfaces:
InitializingBean
Direct Known Subclasses:
JmsDestinationAccessor

public abstract class JmsAccessor
extends Object
implements InitializingBean

Base class for JmsTemplate and other JMS-accessing gateway helpers, defining common properties like the ConnectionFactory. The subclass JmsDestinationAccessor adds further, destination-related properties.

Not intended to be used directly. See JmsTemplate.

Since:
1.2
Author:
Juergen Hoeller
See Also:
JmsDestinationAccessor, JmsTemplate

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
JmsAccessor()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  JmsException convertJmsAccessException(JMSException ex)
          Convert the specified checked JMSException to a Spring runtime JmsException equivalent.
 ConnectionFactory getConnectionFactory()
          Return the ConnectionFactory to use for obtaining JMS Connections.
 int getSessionAcknowledgeMode()
          Return the acknowledgement mode for JMS sessions.
 boolean isSessionTransacted()
          Return whether the JMS sessions used by this accessor are supposed to be transacted.
 void setConnectionFactory(ConnectionFactory connectionFactory)
          Set the ConnectionFactory to use for obtaining JMS Connections.
 void setSessionAcknowledgeMode(int sessionAcknowledgeMode)
          Set the JMS acknowledgement mode that is used when creating a JMS Session to send a message.
 void setSessionAcknowledgeModeName(String constantName)
          Set the JMS acknowledgement mode by the name of the corresponding constant in the JMS Session interface, e.g.
 void setSessionTransacted(boolean sessionTransacted)
          Set the transaction mode that is used when creating a JMS Session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

JmsAccessor

public JmsAccessor()
Method Detail

setConnectionFactory

public void setConnectionFactory(ConnectionFactory connectionFactory)
Set the ConnectionFactory to use for obtaining JMS Connections.


getConnectionFactory

public ConnectionFactory getConnectionFactory()
Return the ConnectionFactory to use for obtaining JMS Connections.


setSessionTransacted

public void setSessionTransacted(boolean sessionTransacted)
Set the transaction mode that is used when creating a JMS Session. Default is "false".

Note that that within a JTA transaction, the parameters to create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method are not taken into account. Depending on the J2EE transaction context, the container makes its own decisions on these values. See section 17.3.5 of the EJB specification. Analogously, these parameters are not taken into account within a locally managed transaction either, since the accessor operates on an existing JMS Session in this case.

Setting this flag to "true" will use a short local JMS transaction when running outside of a managed transaction, and a synchronized local JMS transaction in case of a managed transaction (other than an XA transaction) being present. The latter has the effect of a local JMS transaction being managed alongside the main transaction (which might be a native JDBC transaction), with the JMS transaction committing right after the main transaction.

Parameters:
sessionTransacted - the transaction mode
See Also:
Connection.createSession(boolean, int)

isSessionTransacted

public boolean isSessionTransacted()
Return whether the JMS sessions used by this accessor are supposed to be transacted.

Returns:
true if the JMS Sessions used for sending a message are transacted
See Also:
setSessionTransacted(boolean)

setSessionAcknowledgeModeName

public void setSessionAcknowledgeModeName(String constantName)
Set the JMS acknowledgement mode by the name of the corresponding constant in the JMS Session interface, e.g. "CLIENT_ACKNOWLEDGE".

If you want to use vendor-specific extensions to the acknowledgment mode, use setSessionAcknowledgeModeName(String) instead.

Parameters:
constantName - the name of the Session acknowledge mode constant
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE, Connection.createSession(boolean, int)

setSessionAcknowledgeMode

public void setSessionAcknowledgeMode(int sessionAcknowledgeMode)
Set the JMS acknowledgement mode that is used when creating a JMS Session to send a message.

Default is Session.AUTO_ACKNOWLEDGE.

Vendor-specific extensions to the acknowledgment mode can be set here as well.

Note that that inside an EJB the parameters to create(Queue/Topic)Session(boolean transacted, int acknowledgeMode) method are not taken into account. Depending on the transaction context in the EJB, the container makes its own decisions on these values. See section 17.3.5 of the EJB spec.

Parameters:
sessionAcknowledgeMode - the acknowledgement mode
See Also:
Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE, Connection.createSession(boolean, int)

getSessionAcknowledgeMode

public int getSessionAcknowledgeMode()
Return the acknowledgement mode for JMS sessions.


afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

convertJmsAccessException

protected JmsException convertJmsAccessException(JMSException ex)
Convert the specified checked JMSException to a Spring runtime JmsException equivalent.

Default implementation delegates to the JmsUtils.convertJmsAccessException(javax.jms.JMSException) method.

Parameters:
ex - the original checked JMSException to convert
Returns:
the Spring runtime JmsException wrapping ex
See Also:
JmsUtils.convertJmsAccessException(javax.jms.JMSException)

The Spring Framework

Copyright © 2002-2006 The Spring Framework.