com.metamatrix.common.pooling.api
Interface ResourceContainer

All Known Implementing Classes:
BasicResourceContainer

public interface ResourceContainer

The ResourceContainer represents one instance of a physical resource in the pool. For each physical resource created for the pool, a new container instance will be created to hold and manage the physical instance. Each container instance will manage the statistics related to that instance. This would include how many users are currently using this instance and who are they.


Method Summary
 boolean checkin(Resource resource, java.lang.String userName)
          Called to checkin the
 Resource checkOut(java.lang.String userName)
          Returns the resource object request for the userName
 java.util.Properties getProperties()
          Returns the properties
 ResourceDescriptor getResourceDescriptor()
          Returns the resource descriptor that describes this resource
 java.lang.Object getResourceObject()
          Returns the physical resource object Do not call this method to checkout the resource.
 ResourceStatistics getStats()
          Returns the statistics for this container
 boolean hasAvailableResource()
          Returns true if one or more rescources are available for checkout in the specific container instance.
 void init(ResourcePool resourcePool, java.lang.Object physicalResourceObject, int maxConcurrentUsers)
          This method is invoked by the pool to set a reference of itself on the resource
 boolean isAlive()
          Return true if the physical resource is alive.
 void shutDown()
          Called to shutdown the container and cleanup resource references.
 

Method Detail

init

void init(ResourcePool resourcePool,
          java.lang.Object physicalResourceObject,
          int maxConcurrentUsers)
          throws ResourcePoolException
This method is invoked by the pool to set a reference of itself on the resource

Parameters:
resourcePool - is the resource pool from which the resource is managed.
physicalResourceObject - is the physical object to be managed by the container
maxConcurrentUsers - indicates the maximum number of users that can share the physicalResourceObject
Throws:
ResourcePoolException - if an error occurs initializing resource.

getResourceDescriptor

ResourceDescriptor getResourceDescriptor()
Returns the resource descriptor that describes this resource

Returns:
ResourceDescriptor is the descriptor

getProperties

java.util.Properties getProperties()
Returns the properties

Returns:
Properties for the resource

isAlive

boolean isAlive()
                throws ResourcePoolException
Return true if the physical resource is alive.

Returns:
boolean true if the phsical resource is operational
Throws:
ResourcePoolException - is an error ocurrs when checking the state of the physical resource

hasAvailableResource

boolean hasAvailableResource()
Returns true if one or more rescources are available for checkout in the specific container instance.

Returns:
boolean true if a resource can be checked out.

checkOut

Resource checkOut(java.lang.String userName)
                  throws ResourcePoolException
Returns the resource object request for the userName

Returns:
Resource object
Throws:
ResourcePoolException

checkin

boolean checkin(Resource resource,
                java.lang.String userName)
                throws ResourcePoolException
Called to checkin the

Returns:
boolean true if the resource was checked in
Throws:
ResourcePoolException - is an error ocurrs when checking in resource

getResourceObject

java.lang.Object getResourceObject()
Returns the physical resource object Do not call this method to checkout the resource.

Returns:
Object object

getStats

ResourceStatistics getStats()
Returns the statistics for this container

Returns:
ResourceStatistics state

shutDown

void shutDown()
              throws ResourcePoolException
Called to shutdown the container and cleanup resource references. This should not call close on the Resource

Throws:
ResourcePoolException


Copyright © 2009. All Rights Reserved.