org.apache.avalon.excalibur.pool
Class ValidatedResourceLimitingPool
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.avalon.excalibur.pool.InstrumentedResourceLimitingPool
org.apache.avalon.excalibur.pool.ValidatedResourceLimitingPool
- All Implemented Interfaces:
- Disposable, Instrumentable, LogEnabled, Pool, ThreadSafe
- Direct Known Subclasses:
- ResourceLimitingJdbcConnectionPool
- public class ValidatedResourceLimitingPool
- extends InstrumentedResourceLimitingPool
A ResourceLimitingPool which validates reused poolables before they are
returned with a call get().
- Since:
- 4.1
- Version:
- CVS $Revision: 1.6 $ $Date: 2004/03/31 08:07:28 $
- Author:
- Avalon Development Team
Method Summary |
Poolable |
get()
Gets a Poolable from the pool. |
protected Poolable |
newPoolable()
Create a new poolable instance by by calling the newInstance method
on the pool's ObjectFactory. |
protected boolean |
validatePoolable(Poolable poolable)
If the poolable implements Validatable, then its validate() method will be called to give
the poolable a chance to validate itself. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ValidatedResourceLimitingPool
public ValidatedResourceLimitingPool(ObjectFactory factory,
int max,
boolean maxStrict,
boolean blocking,
long blockTimeout,
long trimInterval)
- Creates a new ValidatedResourceLimitingPool
- Parameters:
factory
- The ObjectFactory which will be used to create new Poolables as needed by
the pool.max
- Maximum number of Poolables which can be stored in the pool, 0 implies no limit.maxStrict
- true if the pool should never allow more than max Poolable to be created.
Will cause an exception to be thrown if more than max Poolables are requested and blocking
is false.blocking
- true if the pool should cause a thread calling get() to block when Poolables
are not currently available on 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 poolables will be removed
from the pool. A value of 0 will cause the pool to never trim poolables.
get
public Poolable get()
throws java.lang.Exception
- Gets a Poolable from the pool. If there is room in the pool, a new Poolable will be
created. Depending on the parameters to the constructor, the method may block or throw
an exception if a Poolable is not available on the pool.
- Specified by:
get
in interface Pool
- Overrides:
get
in class InstrumentedResourceLimitingPool
- Returns:
- Always returns a Poolable. Contract requires that put must always be called with
the Poolable returned.
- Throws:
java.lang.Exception
- An exception may be thrown as described above or if there is an exception
thrown by the ObjectFactory's newInstance() method.
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 InstrumentedResourceLimitingPool
- Throws:
java.lang.Exception
validatePoolable
protected boolean validatePoolable(Poolable poolable)
throws java.lang.Exception
- If the poolable implements Validatable, then its validate() method will be called to give
the poolable a chance to validate itself.
Different functionality can be achieved by overriding this method.
This method is only called by threads that have m_semaphore locked.
- Parameters:
poolable
- The Poolable to be validated
- Returns:
- true if the Poolable is valid, false if it should be removed from the pool.
- Throws:
java.lang.Exception
Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.