com.metamatrix.common.pooling.api
Interface Resource

All Known Implementing Classes:
BaseResource, JDBCConnectionResource

public interface Resource

The Resource is used as a wrapper for the physical resource object. This interface dictates the behavior the resource pooling framework requires in order to provide, share and manage resources in a pool. Therefore, any physical resource must implement this interface in order to be managed in a resource pool. The implementor should extend BaseResource to create a wrapper class for their specific business object. This wrapper will be created when it is being checked out so that a reference can be kept to the ResourceContainer from which it came and also track the user who currently has it checkedout.


Method Summary
 void closeResource()
          This method should be invoked by user to indicate the use of the resource is not longer needed.
 java.lang.String getCheckedOutBy()
          Returns the name of the user that has checked out this resource.
 void init(java.lang.String checkedOutBy)
          Called by the adapter for the resource to initialize itself and validate it should be valid resource for use.
 boolean isResourceAlive()
          isResourceAlive is called to determine if the resource is operating normally.
 

Method Detail

init

void init(java.lang.String checkedOutBy)
          throws ResourcePoolException
Called by the adapter for the resource to initialize itself and validate it should be valid resource for use.

Parameters:
checkedOutBy - is the name of the user for which this resource instance is being used
Throws:
ResourcePoolException - if not a valid resource

getCheckedOutBy

java.lang.String getCheckedOutBy()
Returns the name of the user that has checked out this resource.

Returns:
String user name

closeResource

void closeResource()
                   throws ResourcePoolException
This method should be invoked by user to indicate the use of the resource is not longer needed. This is where the resource will be returned back to the pool for possible reuse.

Throws:
ResourcePoolConnection - if there is an error closing the resource
ResourcePoolException

isResourceAlive

boolean isResourceAlive()
                        throws ResourcePoolException
isResourceAlive is called to determine if the resource is operating normally. This method is called when the resource is checked in and during shrink processing. A return of false indicates the resource should not be used. If the resource is unusable, it will be shutdown and possibly another instance will take its place.

Returns:
boolean true if the resource is operating normally
Throws:
ResourcePoolException


Copyright © 2009. All Rights Reserved.