JThreadKitTM
v1.1.0
(public members only)

com.jthreadkit.pool
Interface ResourceManager


public interface ResourceManager

Classes implement this interface to work with some of the implementations of ResourcePool. A resource pool will call back on the methods of this inferface at various times. The ResourceManager is usually specified at the time of construction of a resource pool. Whenever another resource needs to be allocated, createResource() is called (typically when the pool's idle level is below the low water mark - see ResourcePool) and the new resource returned is added to the idle pool. When a previously allocated resource is no longer needed, destroyResource is called after that resource has been permanently removed from the pool. Occasionally, some implementations will want to see if a resource in the pool is still in a valid state. To do this, the pool will call the healthCheck method to have the resource validated.

See Also:
GenericResourcePool, ResourcePool

Method Summary
 Object createResource()
          Called when a new resource is needed for the pool.
 void destroyResource(Object obj)
          Called when a resource has been permanently removed from the pool.
 boolean healthCheck(Object obj)
          Called when the pool wants to validate that the specified resource is still in a valid state.
 

Method Detail

createResource

public Object createResource()
Called when a new resource is needed for the pool.
Returns:
the newly allocated resource.

destroyResource

public void destroyResource(Object obj)
Called when a resource has been permanently removed from the pool.
Parameters:
obj - the resource that should be deallocated, closed, or whatever is necessary to properly release the resource.

healthCheck

public boolean healthCheck(Object obj)
Called when the pool wants to validate that the specified resource is still in a valid state. For example, in a database connection pool a "connection" may have its health checked if an exception was just thrown; and the implementation of this method would probably run a simple and lighweight query to validate the connection.
Parameters:
obj - the resource to validate
Returns:
true if the passed resource is still valid, false if the resource is invalid or corrupt and should be permanently removed from the pool.

JThreadKitTM
v1.1.0
(public members only)

© Copyright 2000-2001 Programix Incorporated. All rights reserved. JThreadKit home