public class

DelegatingConnectionFactory

extends Object
implements InitializingBean SmartConnectionFactory
java.lang.Object
   ↳ org.springframework.jms.connection.DelegatingConnectionFactory

Class Overview

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.

Summary

Public Constructors
DelegatingConnectionFactory()
Public Methods
void afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
Connection createConnection(String username, String password)
Connection createConnection()
QueueConnection createQueueConnection(String username, String password)
QueueConnection createQueueConnection()
TopicConnection createTopicConnection()
TopicConnection createTopicConnection(String username, String password)
ConnectionFactory getTargetConnectionFactory()
Return the target ConnectionFactory that this ConnectionFactory delegates to.
void setShouldStopConnections(boolean shouldStopConnections)
Indicate whether Connections obtained from the target factory are supposed to be stopped before closed ("true") or simply closed ("false").
void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)
Set the target ConnectionFactory that this ConnectionFactory should delegate to.
boolean shouldStop(Connection con)
Should we stop the Connection, obtained from this ConnectionFactory?
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.jms.connection.SmartConnectionFactory

Public Constructors

public DelegatingConnectionFactory ()

Public Methods

public void afterPropertiesSet ()

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.

public Connection createConnection (String username, String password)

Throws
JMSException

public Connection createConnection ()

Throws
JMSException

public QueueConnection createQueueConnection (String username, String password)

Throws
JMSException

public QueueConnection createQueueConnection ()

Throws
JMSException

public TopicConnection createTopicConnection ()

Throws
JMSException

public TopicConnection createTopicConnection (String username, String password)

Throws
JMSException

public ConnectionFactory getTargetConnectionFactory ()

Return the target ConnectionFactory that this ConnectionFactory delegates to.

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"). 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.

Default is "false", simply closing Connections.

public void setTargetConnectionFactory (ConnectionFactory targetConnectionFactory)

Set the target ConnectionFactory that this ConnectionFactory should delegate to.

public boolean shouldStop (Connection con)

Should we stop the Connection, obtained from this ConnectionFactory?

Parameters
con the Connection to check
Returns
  • whether a stop call is necessary