org.apache.avalon.excalibur.datasource
Class ResourceLimitingJdbcConnectionPool

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool
          extended byorg.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool
              extended byorg.apache.avalon.excalibur.datasource.ResourceLimitingJdbcConnectionPool
All Implemented Interfaces:
Disposable, Instrumentable, LogEnabled, Pool, ThreadSafe

public class ResourceLimitingJdbcConnectionPool
extends ValidatedResourceLimitingPool

A ResourceLimiting JdbcConnectionPool which allows for fine configuration of how the pool scales to loads. The pool supports; weak and strong pool size limits, optional blocking gets when connections are not available, and automatic trimming of unused connections.

Since:
4.1
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:14 $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from class org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool
DEFAULT_INSTRUMENTABLE_NAME, INSTRUMENT_BLOCKS_NAME, INSTRUMENT_CREATES_NAME, INSTRUMENT_DECOMMISSIONS_NAME, INSTRUMENT_GETS_NAME, INSTRUMENT_PUTS_NAME, INSTRUMENT_READY_SIZE_NAME, INSTRUMENT_SIZE_NAME, m_semaphore
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
ResourceLimitingJdbcConnectionPool(ObjectFactory factory, int max, boolean maxStrict, boolean blocking, long blockTimeout, long trimInterval, boolean autoCommit)
          Creates a new ResourceLimitingJdbcConnectionPool
 
Method Summary
protected  Poolable newPoolable()
          Create a new poolable instance by by calling the newInstance method on the pool's ObjectFactory.
protected  boolean validatePoolable(Poolable poolable)
          Validates the poolable before it is provided to the caller of get on this pool.
 
Methods inherited from class org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool
get
 
Methods inherited from class org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool
dispose, getChildInstrumentables, getInstrumentableName, getInstruments, getReadySize, getSize, permanentlyRemovePoolable, put, removePoolable, setInstrumentableName, trim
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled
enableLogging
 

Constructor Detail

ResourceLimitingJdbcConnectionPool

public ResourceLimitingJdbcConnectionPool(ObjectFactory factory,
                                          int max,
                                          boolean maxStrict,
                                          boolean blocking,
                                          long blockTimeout,
                                          long trimInterval,
                                          boolean autoCommit)
Creates a new ResourceLimitingJdbcConnectionPool

Parameters:
factory - The ObjectFactory which will be used to create new connections as needed by the pool.
max - Maximum number of connections which can be stored in the pool, 0 implies no limit.
maxStrict - true if the pool should never allow more than max connections to be created. Will cause an exception to be thrown if more than max connections are requested and blocking is false.
blocking - true if the pool should cause a thread calling get() to block when connections are not currently available in the pool.
blockTimeout - The maximum amount of time, in milliseconds, that a call to get() will block before an exception is thrown. A value of 0 implies an indefinate wait.
trimInterval - The minimum interval with which old unused connections will be removed from the pool. A value of 0 will cause the pool to never trim old connections.
autoCommit - true if connections created by this pool should have autoCommit enabled.
Method Detail

newPoolable

protected Poolable newPoolable()
                        throws java.lang.Exception
Create a new poolable instance by by calling the newInstance method on the pool's ObjectFactory. This is the method to override when you need to enforce creational policies. This method is only called by threads that have m_semaphore locked.

Overrides:
newPoolable in class ValidatedResourceLimitingPool
Throws:
java.lang.Exception

validatePoolable

protected boolean validatePoolable(Poolable poolable)
Validates the poolable before it is provided to the caller of get on this pool. This implementation of the validation method always returns true indicating that the Poolable is valid. The pool is not locked by the current thread when this method is called.

Overrides:
validatePoolable in class ValidatedResourceLimitingPool
Parameters:
poolable - The Poolable to be validated
Returns:
true if the Poolable is valid, false if it should be removed from the pool.


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.