org.geotools.arcsde.pool
Class SessionPool

Object
  extended by SessionPool
Direct Known Subclasses:
ArcSDEConnectionReference

public class SessionPool
extends Object

Maintains SeConnection's for a single set of connection properties (for instance: by server, port, user and password) in a pool to recycle used connections.

We are making use of an Apache Commons ObjectPool to maintain connections. This connection pool is configurable in the sense that some parameters can be passed to establish the pooling policy. To pass parameters to the connection pool, you should set properties in the parameters Map passed to SdeDataStoreFactory.createDataStore, which will invoke SdeConnectionPoolFactory to get the SDE instance's pool singleton. That instance singleton will be created with the preferences passed the first time createDataStore is called for a given SDE instance/user, if subsequent calls change that preferences, they will be ignored.

The expected optional parameters that you can set up in the argument Map for createDataStore are:

Author:
Gabriel Roldan

Nested Class Summary
protected  class SessionPool.SeConnectionFactory
          PoolableObjectFactory intended to be used by a Jakarta's commons-pool objects pool, that provides ArcSDE's SeConnections.
 
Field Summary
protected  ArcSDEConnectionConfig config
          this connection pool connection's parameters
static int DEFAULT_CONNECTIONS
          default number of connections a pool creates at first population
static int DEFAULT_MAX_CONNECTIONS
          default number of maximun allowable connections a pool can hold
static int DEFAULT_MAX_WAIT_TIME
           
protected static Level INFO_LOG_LEVEL
          DOCUMENT ME!
protected  GenericObjectPool pool
          Apache commons-pool used to pool arcsde connections
 
Constructor Summary
protected SessionPool(ArcSDEConnectionConfig config)
          Creates a new SdeConnectionPool object with the connection parameters holded by config
 
Method Summary
 void close()
          closes all connections in this pool.
protected  SessionPool.SeConnectionFactory createConnectionFactory()
          SeConnectionFactory used to create ISession instances for the pool.
protected  void finalize()
          Ensures proper closure of connection pool at this object's finalization stage.
 int getAvailableCount()
          TODO: Document this method!
 List<String> getAvailableLayerNames()
          Gets the list of available layer names on the database
 ArcSDEConnectionConfig getConfig()
          DOCUMENT ME!
 int getInUseCount()
          Number of active sessions.
 int getPoolSize()
          returns the number of actual connections held by this connection pool.
 ISession getSession()
          Grab a session from the pool, this session is the responsibility of the calling code and must be closed after use.
 ISession getSession(Transaction transaction)
          Retrieve the connection for the provided transaction.
 boolean isClosed()
          Returns whether this pool is closed
 String toString()
           
 
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INFO_LOG_LEVEL

protected static final Level INFO_LOG_LEVEL
DOCUMENT ME!


DEFAULT_CONNECTIONS

public static final int DEFAULT_CONNECTIONS
default number of connections a pool creates at first population

See Also:
Constant Field Values

DEFAULT_MAX_CONNECTIONS

public static final int DEFAULT_MAX_CONNECTIONS
default number of maximun allowable connections a pool can hold

See Also:
Constant Field Values

DEFAULT_MAX_WAIT_TIME

public static final int DEFAULT_MAX_WAIT_TIME
See Also:
Constant Field Values

config

protected ArcSDEConnectionConfig config
this connection pool connection's parameters


pool

protected GenericObjectPool pool
Apache commons-pool used to pool arcsde connections

Constructor Detail

SessionPool

protected SessionPool(ArcSDEConnectionConfig config)
               throws IOException
Creates a new SdeConnectionPool object with the connection parameters holded by config

Parameters:
config - holds connection options such as server, user and password, as well as tuning options as maximum number of connections allowed
Throws:
IOException - If connection could not be established
NullPointerException - If config is null
Method Detail

createConnectionFactory

protected SessionPool.SeConnectionFactory createConnectionFactory()
SeConnectionFactory used to create ISession instances for the pool.

Subclass may overide to customize this behaviour.

Returns:
SeConnectionFactory.

getPoolSize

public int getPoolSize()
returns the number of actual connections held by this connection pool. In other words, the sum of used and available connections, regardless

Returns:
DOCUMENT ME!

close

public void close()
closes all connections in this pool. The first call closes all SeConnections, further calls have no effect.


isClosed

public boolean isClosed()
Returns whether this pool is closed

Returns:

finalize

protected void finalize()
Ensures proper closure of connection pool at this object's finalization stage.

Overrides:
finalize in class Object

getAvailableCount

public int getAvailableCount()
TODO: Document this method!

Returns:
DOCUMENT ME!

getInUseCount

public int getInUseCount()
Number of active sessions.

Returns:
Number of active session; used to monitor the live pool.

getSession

public ISession getSession(Transaction transaction)
                    throws IOException
Retrieve the connection for the provided transaction.

The connection is held open until while the transaction is underway. A a Transaction.State is registered for this SessionPool in order to hold the session.

Parameters:
transaction -
Returns:
the session associated with the transaction
Throws:
IOException

getSession

public ISession getSession()
                    throws DataSourceException,
                           UnavailableArcSDEConnectionException
Grab a session from the pool, this session is the responsibility of the calling code and must be closed after use.

Returns:
A Session, when close() is called it will be recycled into the pool
Throws:
DataSourceException - If we could not get a connection
UnavailableArcSDEConnectionException - If we are out of connections
IllegalStateException - If pool has been closed.

getAvailableLayerNames

public List<String> getAvailableLayerNames()
                                    throws IOException
Gets the list of available layer names on the database

Returns:
a List<String> with the registered featureclasses on the ArcSDE database
Throws:
DataSourceException
IOException

getConfig

public ArcSDEConnectionConfig getConfig()
DOCUMENT ME!

Returns:
DOCUMENT ME!

toString

public String toString()
Overrides:
toString in class Object


Copyright © 1996-2009 Geotools. All Rights Reserved.