org.d_haven.mpool
public abstract class AbstractPool extends Object implements Pool
| Field Summary | |
|---|---|
| ObjectFactory | m_factory |
| Collection | m_listeners |
| Constructor Summary | |
|---|---|
| protected | AbstractPool(ObjectFactory factory)
Initialize this instance of an AbstractPool using the supplied
ObjectFactory.
|
| Method Summary | |
|---|---|
| Object | acquire()
Acquire an instance of the pooled object.
|
| void | addPoolListener(PoolListener listener)
Add a pool listener to the pool. |
| protected void | disposeInstance(Object pooledObject)
Dispose an instance of a pooled object. |
| protected abstract Object | doAcquire()
Perform the actual work of acquiring the object from the pool.
|
| protected abstract boolean | doRelease(Object pooledObject)
Perform the actual logic to release the pooled object back to the
pool.
|
| protected void | fireAquiredEvent(Object pooledObject)
Fire the objectAquired event to all
the listeners.
|
| protected void | fireCreatedEvent(Object pooledObject)
Fire the objectCreated event to all
the listeners.
|
| protected void | fireCreationFailedEvent(Exception exception)
Fire the objectCreationFailed
event to all the listeners.
|
| protected void | fireDisposedEvent(Object pooledObject)
Fire the objectDisposed event to all
the listeners.
|
| protected void | fireDisposeFailedEvent(Object pooledObject, Exception exception)
Fire the PoolListener event to all the listeners.
|
| protected void | fireReleasedEvent(Object pooledObject)
Fire the objectReleased event to all
the listeners.
|
| Collection | getPoolListeners()
Get the list of pool listeners.
|
| Iterator | listenerIterator() |
| Object | newInstance()
Create a new instance of the object being pooled.
|
| void | release(Object pooledObject)
Release the instance of the pooled object.
|
| void | removePoolListener(PoolListener listener)
Remove a pool listener from the pool. |
Parameters: factory the ObjectFactory used to create new instances.
Returns: the pooled Object instance
Throws: Exception if the Pool is not able to return an object.
Parameters: listener the listener to add.
Parameters: pooledObject the object to dispose of
Returns: the acquired object or null if there are none left
Throws: Exception if there was a problem acquiring the object
Parameters: pooledObject the object to release
Returns: true if we also need to dispose of the
object
Parameters: pooledObject the object acquired from the pool
Parameters: pooledObject the object created
Parameters: exception the exception causing the failure
Parameters: pooledObject the object disposed
Parameters: pooledObject the object disposed exception the exception thrown during disposal
Parameters: pooledObject the object released to the pool
Returns: all the listeners
Returns: the pooled Object instance
Throws: Exception if the instance cannot be created
Parameters: pooledObject The pooled object to release to the pool.
Parameters: listener the listener to remove