com.waveset.adapter
Class ResourceConnectionPool

java.lang.Object
  extended bycom.waveset.adapter.ResourceConnectionPool
Direct Known Subclasses:
ScriptedConnectionPool

public class ResourceConnectionPool
extends java.lang.Object


Field Summary
protected  int _connectionsInUse
           
protected  boolean _shutdown
           
protected static Trace _trace
           
static java.lang.String code_id
           
static long IDLE_TIME_DEFAULT
           
static int MAX_CONNECTIONS_DEFAULT
           
static java.lang.String RA_CONNECTIONS_IDLETIME
           
static java.lang.String RA_CONNECTIONS_MAX
           
 
Constructor Summary
ResourceConnectionPool()
           
ResourceConnectionPool(Resource resource)
           
 
Method Summary
static void addStaleConnections(long idleTime, java.util.Iterator idle, java.util.List stale)
           
 ResourceConnection getConnection(java.util.HashMap args, java.lang.String type, boolean pooled)
           
 ResourceConnection getConnection(java.util.HashMap args, java.lang.String type, long timeout, boolean pooled)
          Returns a connection.
 long getIdleTime()
           
protected  ResourceConnection getPooledConnection(java.util.HashMap args, java.lang.String type)
          Returns a pooled connection.
protected  ResourceConnection getPooledConnection(java.util.HashMap args, java.lang.String type, java.util.ArrayList idle)
          Assumes caller has synchronized this.
 Resource getResource()
           
protected  java.lang.String getResourceAttributeValue(java.lang.String name)
           
 boolean isEmpty()
          If the pool has no connections pooled and none in use then it is considered to be empty.
 boolean isNoneInUse()
           
protected  ResourceConnection newConnection(java.util.HashMap args, java.lang.String type, boolean pooled)
          Creates a new connection object of the specified type.
 java.util.ArrayList reapConnections()
          Removes from the pool those connections which have been idle longer than the specified timeout.
 void releaseConnection(ResourceConnection connection, boolean force)
          Releases the specified connection.
protected  void releaseConnection(ResourceConnection connection, boolean force, java.util.List idle)
          Assumes caller has synchronized on this
 void setResource(Resource resource)
           
 void shutdown()
          Begins shutdown of the pool by disconnecting all idle connections.
static void shutdown(java.util.List idle)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

_trace

protected static Trace _trace

RA_CONNECTIONS_IDLETIME

public static final java.lang.String RA_CONNECTIONS_IDLETIME
See Also:
Constant Field Values

RA_CONNECTIONS_MAX

public static final java.lang.String RA_CONNECTIONS_MAX
See Also:
Constant Field Values

IDLE_TIME_DEFAULT

public static final long IDLE_TIME_DEFAULT
See Also:
Constant Field Values

MAX_CONNECTIONS_DEFAULT

public static final int MAX_CONNECTIONS_DEFAULT
See Also:
Constant Field Values

_connectionsInUse

protected int _connectionsInUse

_shutdown

protected boolean _shutdown
Constructor Detail

ResourceConnectionPool

public ResourceConnectionPool()
                       throws WavesetException

ResourceConnectionPool

public ResourceConnectionPool(Resource resource)
                       throws WavesetException
Method Detail

setResource

public void setResource(Resource resource)
                 throws WavesetException
Throws:
WavesetException

getResource

public Resource getResource()

getResourceAttributeValue

protected java.lang.String getResourceAttributeValue(java.lang.String name)

isNoneInUse

public boolean isNoneInUse()

isEmpty

public boolean isEmpty()
If the pool has no connections pooled and none in use then it is considered to be empty.


newConnection

protected ResourceConnection newConnection(java.util.HashMap args,
                                           java.lang.String type,
                                           boolean pooled)
                                    throws java.lang.IllegalArgumentException,
                                           WavesetException
Creates a new connection object of the specified type. The connection type must be of ResourceConnection or a subclass and must be based from the com.waveset.adapter package.

Throws:
java.lang.IllegalArgumentException
WavesetException

getPooledConnection

protected ResourceConnection getPooledConnection(java.util.HashMap args,
                                                 java.lang.String type)
                                          throws WavesetException
Returns a pooled connection. The first valid connection from the pool is returned. Otherwise a new connection is created. If there are no connections in the pool and the connections in use are at the limit for the pool no connection is returned, (null).

Throws:
WavesetException

getPooledConnection

protected ResourceConnection getPooledConnection(java.util.HashMap args,
                                                 java.lang.String type,
                                                 java.util.ArrayList idle)
                                          throws WavesetException
Assumes caller has synchronized this.

Parameters:
args -
type -
idle -
Returns:
Throws:
WavesetException

getConnection

public ResourceConnection getConnection(java.util.HashMap args,
                                        java.lang.String type,
                                        long timeout,
                                        boolean pooled)
                                 throws WavesetException
Returns a connection. If a pooled connection is requested and none is immediately available, a wait is set until one becomes available. If the timeout expires before a connection becomes available no connection is returned. A timeout value of zero indicates an infinite wait request.

Throws:
WavesetException

getConnection

public ResourceConnection getConnection(java.util.HashMap args,
                                        java.lang.String type,
                                        boolean pooled)
                                 throws WavesetException
Throws:
WavesetException

releaseConnection

public void releaseConnection(ResourceConnection connection,
                              boolean force)
                       throws WavesetException
Releases the specified connection. If the connection is pooled it is returned to the pool. If force is true or the connection is not pooled the connection is disconnected.

Throws:
WavesetException

releaseConnection

protected void releaseConnection(ResourceConnection connection,
                                 boolean force,
                                 java.util.List idle)
                          throws WavesetException
Assumes caller has synchronized on this

Parameters:
connection -
force -
idle -
Throws:
WavesetException

getIdleTime

public long getIdleTime()

reapConnections

public java.util.ArrayList reapConnections()
Removes from the pool those connections which have been idle longer than the specified timeout. Returns a list of the connections which were removed.


addStaleConnections

public static void addStaleConnections(long idleTime,
                                       java.util.Iterator idle,
                                       java.util.List stale)

shutdown

public void shutdown()
Begins shutdown of the pool by disconnecting all idle connections. The _shutdown attribute is set so active connections will not be returned to the pool when becoming idle.


shutdown

public static void shutdown(java.util.List idle)