spring-framework / org.springframework.jms.connection / DelegatingConnectionFactory

DelegatingConnectionFactory

open class DelegatingConnectionFactory : SmartConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean

javax.jms.ConnectionFactory implementation that delegates all calls to a given target javax.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).

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.

Author
Juergen Hoeller

Since
2.0.2

See Also
#createConnection()#setShouldStopConnectionsConnectionFactoryUtils#releaseConnection

Constructors

<init>

DelegatingConnectionFactory()

javax.jms.ConnectionFactory implementation that delegates all calls to a given target javax.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).

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.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

createConnection

open fun createConnection(): Connection
open fun createConnection(username: String, password: String): Connection

createContext

open fun createContext(): JMSContext
open fun createContext(userName: String, password: String): JMSContext
open fun createContext(userName: String, password: String, sessionMode: Int): JMSContext
open fun createContext(sessionMode: Int): JMSContext

createQueueConnection

open fun createQueueConnection(): QueueConnection
open fun createQueueConnection(username: String, password: String): QueueConnection

createTopicConnection

open fun createTopicConnection(): TopicConnection
open fun createTopicConnection(username: String, password: String): TopicConnection

getTargetConnectionFactory

open fun getTargetConnectionFactory(): ConnectionFactory

Return the target ConnectionFactory that this ConnectionFactory delegates to.

setShouldStopConnections

open fun setShouldStopConnections(shouldStopConnections: Boolean): Unit

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

open fun setTargetConnectionFactory(targetConnectionFactory: ConnectionFactory): Unit

Set the target ConnectionFactory that this ConnectionFactory should delegate to.

shouldStop

open fun shouldStop(con: Connection): Boolean