Class DelegatingConnectionFactory

java.lang.Object
org.springframework.jms.connection.DelegatingConnectionFactory
All Implemented Interfaces:
ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean, SmartConnectionFactory

public class DelegatingConnectionFactory extends Object implements SmartConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean
ConnectionFactory implementation that delegates all calls to a given target 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.

Since:
2.0.2
Author:
Juergen Hoeller
See Also: