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

## org.springframework.jms.listener.serversession
Class CommonsPoolServerSessionFactory

    java.lang.Object
      org.springframework.jms.listener.serversession.AbstractPoolingServerSessionFactory
          org.springframework.jms.listener.serversession.CommonsPoolServerSessionFactory

All Implemented Interfaces:
  ServerSessionFactory

    public class CommonsPoolServerSessionFactory

extends AbstractPoolingServerSessionFactory

ServerSessionFactory implementation that holds ServerSessions in a configurable Jakarta Commons Pool.

By default, an instance of `GenericObjectPool` is created. Subclasses may change the type of `ObjectPool` used by overriding the `createObjectPool` method.

Provides many configuration properties mirroring those of the Commons Pool `GenericObjectPool` class; these properties are passed to the `GenericObjectPool` during construction. If creating a subclass of this class to change the `ObjectPool` implementation type, pass in the values of configuration properties that are relevant to your chosen implementation.

Since:
  2.0
Author:
  Juergen Hoeller
See Also:
  `GenericObjectPool`, `createObjectPool(org.springframework.jms.listener.serversession.ListenerSessionManager)`, `AbstractPoolingServerSessionFactory.setMaxSize(int)`, `setMaxIdle(int)`, `setMinIdle(int)`, `setMaxWait(long)`

Field Summary

Fields inherited from class org.springframework.jms.listener.serversession.AbstractPoolingServerSessionFactory
`logger`

Constructor Summary
`CommonsPoolServerSessionFactory()` Create a CommonsPoolServerSessionFactory with default settings.

Method Summary
`void` | `close(ListenerSessionManager sessionManager)` Closes all pools held by this ServerSessionFactory.
`protected ObjectPool` | `createObjectPool(ListenerSessionManager sessionManager)` Subclasses can override this if they want to return a specific Commons pool.
`protected PoolableObjectFactory` | `createPoolableObjectFactory(ListenerSessionManager sessionManager)` Create a Commons PoolableObjectFactory adapter for the given session manager.
`int` | `getMaxIdle()` Return the maximum number of idle ServerSessions in the pool.
`long` | `getMaxWait()` Return the maximum waiting time for fetching a ServerSession from the pool.
`long` | `getMinEvictableIdleTimeMillis()` Return the minimum time that an idle ServerSession can sit in the pool.
`int` | `getMinIdle()` Return the minimum number of idle ServerSessions in the pool.
`ServerSession` | `getServerSession(ListenerSessionManager sessionManager)` Returns a ServerSession from the pool, creating a new pool for the given session manager if necessary.
`long` | `getTimeBetweenEvictionRunsMillis()` Return the time between eviction runs that check idle ServerSessions.
`protected void` | `serverSessionFinished(ServerSession serverSession, ListenerSessionManager sessionManager)` Returns the given ServerSession, which just finished an execution of its listener, back to the pool.
`void` | `setMaxIdle(int maxIdle)` Set the maximum number of idle ServerSessions in the pool.
`void` | `setMaxWait(long maxWait)` Set the maximum waiting time for fetching an ServerSession from the pool.
`void` | `setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)` Set the minimum time that an idle ServerSession can sit in the pool before it becomes subject to eviction.
`void` | `setMinIdle(int minIdle)` Set the minimum number of idle ServerSessions in the pool.
`void` | `setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)` Set the time between eviction runs that check idle ServerSessions whether they have been idle for too long or have become invalid.

Methods inherited from class org.springframework.jms.listener.serversession.AbstractPoolingServerSessionFactory
`createServerSession, destroyServerSession, getMaxSize, getTaskExecutor, setMaxSize, setTaskExecutor`

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

Constructor Detail

### CommonsPoolServerSessionFactory

    public CommonsPoolServerSessionFactory()

  Create a CommonsPoolServerSessionFactory with default settings. Default maximum size of the pool is 8.

  See Also:
    `AbstractPoolingServerSessionFactory.setMaxSize(int)`, `GenericObjectPool.setMaxActive(int)`

Method Detail

### setMaxIdle

    public void setMaxIdle(int maxIdle)

  Set the maximum number of idle ServerSessions in the pool. Default is 8.

  See Also:
    `GenericObjectPool.setMaxIdle(int)`

### getMaxIdle

    public int getMaxIdle()

  Return the maximum number of idle ServerSessions in the pool.

### setMinIdle

    public void setMinIdle(int minIdle)

  Set the minimum number of idle ServerSessions in the pool. Default is 0.

  See Also:
    `GenericObjectPool.setMinIdle(int)`

### getMinIdle

    public int getMinIdle()

  Return the minimum number of idle ServerSessions in the pool.

### setMaxWait

    public void setMaxWait(long maxWait)

  Set the maximum waiting time for fetching an ServerSession from the pool. Default is -1, waiting forever.

  See Also:
    `GenericObjectPool.setMaxWait(long)`

### getMaxWait

    public long getMaxWait()

  Return the maximum waiting time for fetching a ServerSession from the pool.

### setTimeBetweenEvictionRunsMillis

    public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)

  Set the time between eviction runs that check idle ServerSessions whether they have been idle for too long or have become invalid. Default is -1, not performing any eviction.

  See Also:
    `GenericObjectPool.setTimeBetweenEvictionRunsMillis(long)`

### getTimeBetweenEvictionRunsMillis

    public long getTimeBetweenEvictionRunsMillis()

  Return the time between eviction runs that check idle ServerSessions.

### setMinEvictableIdleTimeMillis

    public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)

  Set the minimum time that an idle ServerSession can sit in the pool before it becomes subject to eviction. Default is 1800000 (30 minutes).

  Note that eviction runs need to be performed to take this setting into effect.

  See Also:
    `setTimeBetweenEvictionRunsMillis(long)`, `GenericObjectPool.setMinEvictableIdleTimeMillis(long)`

### getMinEvictableIdleTimeMillis

    public long getMinEvictableIdleTimeMillis()

  Return the minimum time that an idle ServerSession can sit in the pool.

### getServerSession

    public ServerSession getServerSession(ListenerSessionManager sessionManager)
                                   throws JMSException

  Returns a ServerSession from the pool, creating a new pool for the given session manager if necessary.

  Parameters:
    `sessionManager` - the session manager to use for creating and executing new listener sessions (implicitly indicating the target listener to invoke)
  Returns:
    the JMS ServerSession
  Throws:
    `JMSException` - if retrieval failed
  See Also:
    `createObjectPool(org.springframework.jms.listener.serversession.ListenerSessionManager)`

### createObjectPool

    protected ObjectPool createObjectPool(ListenerSessionManager sessionManager)

  Subclasses can override this if they want to return a specific Commons pool. They should apply any configuration properties to the pool here.

  Default is a GenericObjectPool instance with the given pool size.

  Parameters:
    `sessionManager` - the session manager to use for creating and executing new listener sessions
  Returns:
    an empty Commons `ObjectPool`.
  See Also:
    `GenericObjectPool`, `AbstractPoolingServerSessionFactory.setMaxSize(int)`

### createPoolableObjectFactory

    protected PoolableObjectFactory createPoolableObjectFactory(ListenerSessionManager sessionManager)

  Create a Commons PoolableObjectFactory adapter for the given session manager. Calls `createServerSession` and `destroyServerSession` as defined by the AbstractPoolingServerSessionFactory class.

  Parameters:
    `sessionManager` - the session manager to use for creating and executing new listener sessions
  Returns:
    the Commons PoolableObjectFactory
  See Also:
    `AbstractPoolingServerSessionFactory.createServerSession(org.springframework.jms.listener.serversession.ListenerSessionManager)`, `AbstractPoolingServerSessionFactory.destroyServerSession(javax.jms.ServerSession)`

### serverSessionFinished

    protected void serverSessionFinished(ServerSession serverSession,
                                         ListenerSessionManager sessionManager)

  Returns the given ServerSession, which just finished an execution of its listener, back to the pool.

  Specified by:
    `serverSessionFinished` in class `AbstractPoolingServerSessionFactory`
  Parameters:
    `serverSession` - the ServerSession that finished its execution
    `sessionManager` - the session manager that the ServerSession belongs to

### close

    public void close(ListenerSessionManager sessionManager)

  Closes all pools held by this ServerSessionFactory.

  Parameters:
    `sessionManager` - the session manager used for creating and executing new listener sessions (implicitly indicating the target listener)

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

Copyright © 2002-2007 The Spring Framework.