|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.jms.connection.ConnectionFactoryUtils
public abstract class ConnectionFactoryUtils
Helper class for managing a JMS ConnectionFactory
, in particular
for obtaining transactional JMS resources for a given ConnectionFactory.
Mainly for internal use within the framework. Used by
JmsTemplate
as well as
DefaultMessageListenerContainer
.
SmartConnectionFactory
Nested Class Summary | |
---|---|
private static class |
ConnectionFactoryUtils.JmsResourceSynchronization
Callback for resource cleanup at the end of a non-native JMS transaction (e.g. |
static interface |
ConnectionFactoryUtils.ResourceFactory
Callback interface for resource creation. |
Field Summary | |
---|---|
private static Log |
logger
|
Constructor Summary | |
---|---|
ConnectionFactoryUtils()
|
Method Summary | |
---|---|
static javax.jms.Session |
doGetTransactionalSession(javax.jms.ConnectionFactory connectionFactory,
ConnectionFactoryUtils.ResourceFactory resourceFactory)
Obtain a JMS Session that is synchronized with the current transaction, if any. |
static javax.jms.Session |
doGetTransactionalSession(javax.jms.ConnectionFactory connectionFactory,
ConnectionFactoryUtils.ResourceFactory resourceFactory,
boolean startConnection)
Obtain a JMS Session that is synchronized with the current transaction, if any. |
static javax.jms.Session |
getTargetSession(javax.jms.Session session)
Return the innermost target Session of the given Session. |
static javax.jms.QueueSession |
getTransactionalQueueSession(javax.jms.QueueConnectionFactory cf,
javax.jms.QueueConnection existingCon,
boolean synchedLocalTransactionAllowed)
Obtain a JMS QueueSession that is synchronized with the current transaction, if any. |
static javax.jms.Session |
getTransactionalSession(javax.jms.ConnectionFactory cf,
javax.jms.Connection existingCon,
boolean synchedLocalTransactionAllowed)
Obtain a JMS Session that is synchronized with the current transaction, if any. |
static javax.jms.TopicSession |
getTransactionalTopicSession(javax.jms.TopicConnectionFactory cf,
javax.jms.TopicConnection existingCon,
boolean synchedLocalTransactionAllowed)
Obtain a JMS TopicSession that is synchronized with the current transaction, if any. |
static boolean |
isSessionTransactional(javax.jms.Session session,
javax.jms.ConnectionFactory cf)
Determine whether the given JMS Session is transactional, that is, bound to the current thread by Spring's transaction facilities. |
static void |
releaseConnection(javax.jms.Connection con,
javax.jms.ConnectionFactory cf,
boolean started)
Release the given Connection, stopping it (if necessary) and eventually closing it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log logger
Constructor Detail |
---|
public ConnectionFactoryUtils()
Method Detail |
---|
public static void releaseConnection(javax.jms.Connection con, javax.jms.ConnectionFactory cf, boolean started)
Checks SmartConnectionFactory.shouldStop(javax.jms.Connection)
, if available.
This is essentially a more sophisticated version of
JmsUtils.closeConnection(javax.jms.Connection)
.
con
- the Connection to release
(if this is null
, the call will be ignored)cf
- the ConnectionFactory that the Connection was obtained from
(may be null
)started
- whether the Connection might have been started by the applicationSmartConnectionFactory.shouldStop(javax.jms.Connection)
,
JmsUtils.closeConnection(javax.jms.Connection)
public static javax.jms.Session getTargetSession(javax.jms.Session session)
session
- the Session proxy to unwrap
SessionProxy.getTargetSession()
public static boolean isSessionTransactional(javax.jms.Session session, javax.jms.ConnectionFactory cf)
session
- the JMS Session to checkcf
- the JMS ConnectionFactory that the Session originated from
public static javax.jms.Session getTransactionalSession(javax.jms.ConnectionFactory cf, javax.jms.Connection existingCon, boolean synchedLocalTransactionAllowed) throws javax.jms.JMSException
cf
- the ConnectionFactory to obtain a Session forexistingCon
- the existing JMS Connection to obtain a Session for
(may be null
)synchedLocalTransactionAllowed
- whether to allow for a local JMS transaction
that is synchronized with a Spring-managed transaction (where the main transaction
might be a JDBC-based one for a specific DataSource, for example), with the JMS
transaction committing right after the main transaction. If not allowed, the given
ConnectionFactory needs to handle transaction enlistment underneath the covers.
null
if none found
javax.jms.JMSException
- in case of JMS failurepublic static javax.jms.QueueSession getTransactionalQueueSession(javax.jms.QueueConnectionFactory cf, javax.jms.QueueConnection existingCon, boolean synchedLocalTransactionAllowed) throws javax.jms.JMSException
Mainly intended for use with the JMS 1.0.2 API.
cf
- the ConnectionFactory to obtain a Session forexistingCon
- the existing JMS Connection to obtain a Session for
(may be null
)synchedLocalTransactionAllowed
- whether to allow for a local JMS transaction
that is synchronized with a Spring-managed transaction (where the main transaction
might be a JDBC-based one for a specific DataSource, for example), with the JMS
transaction committing right after the main transaction. If not allowed, the given
ConnectionFactory needs to handle transaction enlistment underneath the covers.
null
if none found
javax.jms.JMSException
- in case of JMS failurepublic static javax.jms.TopicSession getTransactionalTopicSession(javax.jms.TopicConnectionFactory cf, javax.jms.TopicConnection existingCon, boolean synchedLocalTransactionAllowed) throws javax.jms.JMSException
Mainly intended for use with the JMS 1.0.2 API.
cf
- the ConnectionFactory to obtain a Session forexistingCon
- the existing JMS Connection to obtain a Session for
(may be null
)synchedLocalTransactionAllowed
- whether to allow for a local JMS transaction
that is synchronized with a Spring-managed transaction (where the main transaction
might be a JDBC-based one for a specific DataSource, for example), with the JMS
transaction committing right after the main transaction. If not allowed, the given
ConnectionFactory needs to handle transaction enlistment underneath the covers.
null
if none found
javax.jms.JMSException
- in case of JMS failurepublic static javax.jms.Session doGetTransactionalSession(javax.jms.ConnectionFactory connectionFactory, ConnectionFactoryUtils.ResourceFactory resourceFactory) throws javax.jms.JMSException
This doGetTransactionalSession
variant always starts the underlying
JMS Connection, assuming that the Session will be used for receiving messages.
connectionFactory
- the JMS ConnectionFactory to bind for
(used as TransactionSynchronizationManager key)resourceFactory
- the ResourceFactory to use for extracting or creating
JMS resources
null
if none found
javax.jms.JMSException
- in case of JMS failuredoGetTransactionalSession(javax.jms.ConnectionFactory, ResourceFactory, boolean)
public static javax.jms.Session doGetTransactionalSession(javax.jms.ConnectionFactory connectionFactory, ConnectionFactoryUtils.ResourceFactory resourceFactory, boolean startConnection) throws javax.jms.JMSException
connectionFactory
- the JMS ConnectionFactory to bind for
(used as TransactionSynchronizationManager key)resourceFactory
- the ResourceFactory to use for extracting or creating
JMS resourcesstartConnection
- whether the underlying JMS Connection approach should be
started in order to allow for receiving messages. Note that a reused Connection
may already have been started before, even if this flag is false
.
null
if none found
javax.jms.JMSException
- in case of JMS failure
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |