Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.jms.connection
Class DelegatingConnectionFactory

    java.lang.Object
      org.springframework.jms.connection.DelegatingConnectionFactory

All Implemented Interfaces:
  javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory, InitializingBean, SmartConnectionFactory

    public class DelegatingConnectionFactory

extends java.lang.Object
implements SmartConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.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).

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:
  `createConnection()`, `setShouldStopConnections(boolean)`, `ConnectionFactoryUtils.releaseConnection(javax.jms.Connection, javax.jms.ConnectionFactory, boolean)`

Constructor Summary
`DelegatingConnectionFactory()`

Method Summary
`void` | `afterPropertiesSet()` Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
`javax.jms.Connection` | `createConnection()`
`javax.jms.Connection` | `createConnection(java.lang.String username, java.lang.String password)`
`javax.jms.QueueConnection` | `createQueueConnection()`
`javax.jms.QueueConnection` | `createQueueConnection(java.lang.String username, java.lang.String password)`
`javax.jms.TopicConnection` | `createTopicConnection()`
`javax.jms.TopicConnection` | `createTopicConnection(java.lang.String username, java.lang.String password)`
`javax.jms.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(javax.jms.ConnectionFactory targetConnectionFactory)` Set the target ConnectionFactory that this ConnectionFactory should delegate to.
`boolean` | `shouldStop(javax.jms.Connection con)` Should we stop the Connection, obtained from this ConnectionFactory?

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DelegatingConnectionFactory

    public DelegatingConnectionFactory()

Method Detail

### setTargetConnectionFactory

    public void setTargetConnectionFactory(javax.jms.ConnectionFactory targetConnectionFactory)

  Set the target ConnectionFactory that this ConnectionFactory should delegate to.

### getTargetConnectionFactory

    public javax.jms.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"). 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.

  See Also:
    `ConnectionFactoryUtils.releaseConnection(javax.jms.Connection, javax.jms.ConnectionFactory, boolean)`

### afterPropertiesSet

    public void afterPropertiesSet()

  Description copied from interface: `InitializingBean`
  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.

  Specified by:
    `afterPropertiesSet` in interface `InitializingBean`

### createConnection

    public javax.jms.Connection createConnection()
                                          throws javax.jms.JMSException

  Specified by:
    `createConnection` in interface `javax.jms.ConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### createConnection

    public javax.jms.Connection createConnection(java.lang.String username,
                                                 java.lang.String password)
                                          throws javax.jms.JMSException

  Specified by:
    `createConnection` in interface `javax.jms.ConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### createQueueConnection

    public javax.jms.QueueConnection createQueueConnection()
                                                    throws javax.jms.JMSException

  Specified by:
    `createQueueConnection` in interface `javax.jms.QueueConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### createQueueConnection

    public javax.jms.QueueConnection createQueueConnection(java.lang.String username,
                                                           java.lang.String password)
                                                    throws javax.jms.JMSException

  Specified by:
    `createQueueConnection` in interface `javax.jms.QueueConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### createTopicConnection

    public javax.jms.TopicConnection createTopicConnection()
                                                    throws javax.jms.JMSException

  Specified by:
    `createTopicConnection` in interface `javax.jms.TopicConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### createTopicConnection

    public javax.jms.TopicConnection createTopicConnection(java.lang.String username,
                                                           java.lang.String password)
                                                    throws javax.jms.JMSException

  Specified by:
    `createTopicConnection` in interface `javax.jms.TopicConnectionFactory`
  Throws:
    `javax.jms.JMSException`

### shouldStop

    public boolean shouldStop(javax.jms.Connection con)

  Description copied from interface: `SmartConnectionFactory`
  Should we stop the Connection, obtained from this ConnectionFactory?

  Specified by:
    `shouldStop` in interface `SmartConnectionFactory`
  Parameters:
    `con` - the Connection to check
  Returns:
    whether a stop call is necessary
  See Also:
    `Connection.stop()`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD