类 DelegatingConnectionFactory
- java.lang.Object
- org.springframework.jms.connection.DelegatingConnectionFactory
- 所有已实现的接口:
ConnectionFactory,QueueConnectionFactory,TopicConnectionFactory,InitializingBean,SmartConnectionFactory
public class DelegatingConnectionFactory extends Object implements SmartConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, InitializingBean
ConnectionFactoryimplementation that delegates all calls to a given targetConnectionFactory, adapting specificcreate(Queue/Topic)Connectioncalls 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.
- 从以下版本开始:
- 2.0.2
- 作者:
- Juergen Hoeller
- 另请参阅:
createConnection(),setShouldStopConnections(boolean),ConnectionFactoryUtils.releaseConnection(javax.jms.Connection, javax.jms.ConnectionFactory, boolean)
构造器概要
构造器 构造器 说明 DelegatingConnectionFactory()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.ConnectioncreateConnection()ConnectioncreateConnection(String username, String password)QueueConnectioncreateQueueConnection()QueueConnectioncreateQueueConnection(String username, String password)TopicConnectioncreateTopicConnection()TopicConnectioncreateTopicConnection(String username, String password)ConnectionFactorygetTargetConnectionFactory()Return the target ConnectionFactory that this ConnectionFactory delegates to.voidsetShouldStopConnections(boolean shouldStopConnections)Indicate whether Connections obtained from the target factory are supposed to be stopped before closed ("true") or simply closed ("false").voidsetTargetConnectionFactory(ConnectionFactory targetConnectionFactory)Set the target ConnectionFactory that this ConnectionFactory should delegate to.booleanshouldStop(Connection con)Should we stop the Connection, obtained from this ConnectionFactory?
构造器详细资料
DelegatingConnectionFactory
public DelegatingConnectionFactory()
方法详细资料
setTargetConnectionFactory
public void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)
Set the target ConnectionFactory that this ConnectionFactory should delegate to.
getTargetConnectionFactory
public ConnectionFactory getTargetConnectionFactory()
Return the target ConnectionFactory that this ConnectionFactory delegates to.
setShouldStopConnections
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.
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet在接口中InitializingBean
createConnection
public Connection createConnection() throws JMSException
- 指定者:
createConnection在接口中ConnectionFactory- 抛出:
JMSException
createConnection
public Connection createConnection(String username, String password) throws JMSException
- 指定者:
createConnection在接口中ConnectionFactory- 抛出:
JMSException
createQueueConnection
public QueueConnection createQueueConnection() throws JMSException
createQueueConnection
public QueueConnection createQueueConnection(String username, String password) throws JMSException
createTopicConnection
public TopicConnection createTopicConnection() throws JMSException
createTopicConnection
public TopicConnection createTopicConnection(String username, String password) throws JMSException
shouldStop
public boolean shouldStop(Connection con)
从接口复制的说明:SmartConnectionFactoryShould we stop the Connection, obtained from this ConnectionFactory?- 指定者:
shouldStop在接口中SmartConnectionFactory- 参数:
con- the Connection to check- 返回:
- whether a stop call is necessary
- 另请参阅:
Connection.stop()