|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objecttoolbox.pooling.ResourcePoolImpl
public abstract class ResourcePoolImpl
A generic implementation of ResourcePool interface. Provides abstract methods that must be overridden to do resource specific creation,validation and cleanup.
| Field Summary | |
|---|---|
protected java.util.Properties |
m_customProps
Custom properties configured for specific pool implementation. |
| Constructor Summary | |
|---|---|
ResourcePoolImpl()
|
|
| Method Summary | |
|---|---|
protected abstract java.lang.Object |
createResource(XMLProperties xmlProps,
int count)
Subclasses of this class must implement this method with resource specific initialisation code. |
void |
destroy()
Destroy this pool |
protected abstract void |
destroyResource(java.lang.Object resource)
Subclasses of this class must implement this method with resource specific cleanup code. |
protected java.lang.String |
getName()
Returns the name of this pool. |
java.lang.Object |
getResource()
Returns a resource from this pool. |
java.lang.String |
getStatus()
Returns the current status of this pool. |
protected java.lang.String |
getStatusString()
Return the status of the pool |
void |
init(java.lang.String name,
XMLProperties xmlProps)
Initialises the lists, sizes, custom properties and initial resources for this pool. |
protected abstract boolean |
isResourceValid(java.lang.Object resource)
Validates the resource and returns a state indicator. |
protected abstract void |
preInit(XMLProperties xmlProps)
Subclasses may choose to override this method to perform custom initialisation before the init() method of this class starts calling the createResource() method. |
void |
releaseResource(java.lang.Object resource)
Releases a resource back to this pool. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Properties m_customProps
| Constructor Detail |
|---|
public ResourcePoolImpl()
| Method Detail |
|---|
protected abstract void preInit(XMLProperties xmlProps)
throws ResourcePoolException
xmlProps - XML configuration properties.
ResourcePoolException - if the custom initialisation fails.
protected abstract java.lang.Object createResource(XMLProperties xmlProps,
int count)
throws ResourcePoolException
xmlProps - XML configuration properties.count - int indicating how many times this method has been
called. Will be context specific.
ResourcePoolException - if an exception occurs while creating a
resource.
protected abstract void destroyResource(java.lang.Object resource)
throws ResourcePoolException
resource - Resource to destroy.
ResourcePoolException - if the given resource cannot be destroyed.
protected abstract boolean isResourceValid(java.lang.Object resource)
throws ResourcePoolException
resource - Resource to validate.
ResourcePoolException - if the resource cannot be validated.public java.lang.String getStatus()
getStatus in interface ResourcePoolprotected java.lang.String getStatusString()
protected java.lang.String getName()
public void init(java.lang.String name,
XMLProperties xmlProps)
throws ResourcePoolException
init in interface ResourcePoolname - Name of this pool.xmlProps - XML configuration properties.
ResourcePoolException - if the pool cannot be initialised.
public java.lang.Object getResource()
throws ResourcePoolException
The available list is checked for resources. If none are available a new resource is created if the maximum number of resources have not yet been reached.
If the maximum number of resources have been reached this call blocks until a resource becomes available.
getResource in interface ResourcePoolResourcePoolException - if the a resource could not be returned.public void releaseResource(java.lang.Object resource)
releaseResource in interface ResourcePoolresource - Resource to release back to the pool.
public void destroy()
throws ResourcePoolException
destroy in interface ResourcePoolResourcePoolException - if this pool cannot be destroyed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||