jakarta.jms.ConnectionFactory implementation that delegates all calls
to a given target jakarta.jms.ConnectionFactory , adapting specific
create(Queue/Topic)Connection calls to the target ConnectionFactory
if necessary (e.g. when running JMS 1.0.2 API based code against a generic
JMS 1.1 ConnectionFactory, such as ActiveMQ's PooledConnectionFactory).
As of Spring Framework 5, this class supports JMS 2.0 JMSContext
calls and therefore requires the JMS 2.0 API to be present at runtime.
It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
as long as no actual JMS 2.0 calls are triggered by the application's setup.
This class allows for being subclassed, with subclasses overriding only
those methods (such as createConnection()) that should not simply
delegate to the target ConnectionFactory.
Can also be defined as-is, wrapping a specific target ConnectionFactory, using the "shouldStopConnections" flag to indicate whether Connections obtained from the target factory are supposed to be stopped before closed. The latter may be necessary for some connection pools that simply return released connections to the pool, not stopping them while they sit in the pool.
createConnection(), setShouldStopConnections, ConnectionFactoryUtils#releaseConnection
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private ConnectionFactory |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| public Connection | createConnection()
Implements jakarta. Creates a connection with the default user identity. |
| public Connection | createConnection(String
the caller's user name username, String the caller's password password)Implements jakarta. Creates a connection with the specified user identity. |
| public JMSContext | createContext()
Implements jakarta. Creates a JMSContext with the default user identity and an unspecified sessionMode. |
| public JMSContext | createContext(String
the caller's user name userName, String the caller's password password)Implements jakarta. Creates a JMSContext with the specified user identity and an unspecified sessionMode. |
| public JMSContext | createContext(String
the caller's user name userName, String the caller's password password, int indicates which of four possible session modes will be used.
sessionMode)
Implements jakarta. Creates a JMSContext with the specified user identity and the specified session mode. |
| public JMSContext | createContext(int
indicates which of four possible session modes will be used.
sessionMode)
Implements jakarta. Creates a JMSContext with the default user identity and the specified session mode. |
| public QueueConnection | createQueueConnection()
Implements jakarta. Creates a queue connection with the default user identity. |
| public QueueConnection | createQueueConnection(String
the caller's user name username, String the caller's password password)Implements jakarta. Creates a queue connection with the specified user identity. |
| public TopicConnection | createTopicConnection()
Implements jakarta. Creates a topic connection with the default user identity. |
| public TopicConnection | createTopicConnection(String
the caller's user name username, String the caller's password password)Implements jakarta. Creates a topic connection with the specified user identity. |
| public ConnectionFactory | getTargetConnectionFactory()
Return the target ConnectionFactory that this ConnectionFactory delegates to. |
| private ConnectionFactory | |
| public void | setShouldStopConnections(boolean shouldStopConnections)
Indicate whether Connections obtained from the target factory are supposed to be stopped before closed ("true") or simply closed ("false"). |
| public void | setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)
Set the target ConnectionFactory that this ConnectionFactory should delegate to. |
| public boolean | shouldStop(Connection
the Connection to check con)Implements org. Should we stop the Connection, obtained from this ConnectionFactory? |
| shouldStopConnections | back to summary |
|---|---|
| private boolean shouldStopConnections | |
| targetConnectionFactory | back to summary |
|---|---|
| private ConnectionFactory targetConnectionFactory
| |
| DelegatingConnectionFactory | back to summary |
|---|---|
| public DelegatingConnectionFactory() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
| |
| createConnection | back to summary |
|---|---|
| public Connection createConnection() throws JMSException Implements jakarta. Doc from jakarta. Creates a connection with the default user identity. The connection is created in stopped mode. No messages will be
delivered until the
| |
| createConnection | back to summary |
|---|---|
| public Connection createConnection(String username, String password) throws JMSException Implements jakarta. Doc from jakarta. Creates a connection with the specified user identity. The connection is created in stopped mode. No messages will be
delivered until the
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext() Implements jakarta. Doc from jakarta. Creates a JMSContext with the default user identity and an unspecified sessionMode. A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer is created. The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress. In a Java SE environment or in the Jakarta EE application client container:
In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:
In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(String userName, String password) Implements jakarta. Doc from jakarta. Creates a JMSContext with the specified user identity and an unspecified sessionMode. A connection and session are created for use by the new JMSContext. The connection is created in stopped mode but will be automatically started when a JMSConsumer. The behaviour of the session that is created depends on whether this method is called in a Java SE environment, in the Jakarta EE application client container, or in the Jakarta EE web or EJB container. If this method is called in the Jakarta EE web or EJB container then the behaviour of the session also depends on whether or not there is an active JTA transaction in progress. In a Java SE environment or in the Jakarta EE application client container:
In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:
In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(String userName, String password, int sessionMode) Implements jakarta. Doc from jakarta. Creates a JMSContext with the specified user identity and the specified session mode. A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the In a Java SE environment or in the Jakarta EE application client container:
In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:
In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createContext | back to summary |
|---|---|
| public JMSContext createContext(int sessionMode) Implements jakarta. Doc from jakarta. Creates a JMSContext with the default user identity and the specified session mode. A connection and session are created for use by the new JMSContext. The JMSContext is created in stopped mode but will be automatically started when a JMSConsumer is created.
The effect of setting the In a Java SE environment or in the Jakarta EE application client container:
In a Jakarta EE web or EJB container, when there is an active JTA transaction in progress:
In the Jakarta EE web or EJB container, when there is no active JTA transaction in progress:
| |
| createQueueConnection | back to summary |
|---|---|
| public QueueConnection createQueueConnection() throws JMSException Implements jakarta. Doc from jakarta. Creates a queue connection with the default user identity. The connection is created in stopped mode. No messages
will be delivered until the
| |
| createQueueConnection | back to summary |
|---|---|
| public QueueConnection createQueueConnection(String username, String password) throws JMSException Implements jakarta. Doc from jakarta. Creates a queue connection with the specified user identity. The connection is created in stopped mode. No messages
will be delivered until the
| |
| createTopicConnection | back to summary |
|---|---|
| public TopicConnection createTopicConnection() throws JMSException Implements jakarta. Doc from jakarta. Creates a topic connection with the default user identity. The connection is created in stopped mode. No messages
will be delivered until the
| |
| createTopicConnection | back to summary |
|---|---|
| public TopicConnection createTopicConnection(String username, String password) throws JMSException Implements jakarta. Doc from jakarta. Creates a topic connection with the specified user identity. The connection is created in stopped mode. No messages
will be delivered until the
| |
| getTargetConnectionFactory | back to summary |
|---|---|
| public ConnectionFactory getTargetConnectionFactory() Return the target ConnectionFactory that this ConnectionFactory delegates to.
| |
| obtainTargetConnectionFactory | back to summary |
|---|---|
| private ConnectionFactory obtainTargetConnectionFactory() | |
| setShouldStopConnections | back to summary |
|---|---|
| public void setShouldStopConnections(boolean shouldStopConnections) Indicate whether Connections obtained from the target factory are supposed to be stopped before closed ("true") or simply closed ("false"). An extra stop call may be necessary for some connection pools that simply return released connections to the pool, not stopping them while they sit in the pool. Default is "false", simply closing Connections. | |
| setTargetConnectionFactory | back to summary |
|---|---|
| public void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory) Set the target ConnectionFactory that this ConnectionFactory should delegate to. | |
| shouldStop | back to summary |
|---|---|
| public boolean shouldStop(Connection con) Implements org. Doc from org. Should we stop the Connection, obtained from this ConnectionFactory?
| |