com.metamatrix.common.pooling.impl
Class BasicResourceContainer

java.lang.Object
  extended by com.metamatrix.common.pooling.impl.BasicResourceContainer
All Implemented Interfaces:
ResourceContainer

public class BasicResourceContainer
extends java.lang.Object
implements ResourceContainer

The ResourceContainer is what is used by the pool to contain and manage the number of Resources that are made available.


Field Summary
protected static java.lang.String LOG_CONTEXT
           
 
Constructor Summary
BasicResourceContainer(long containerID)
           
 
Method Summary
 boolean checkin(Resource resource, java.lang.String userName)
          Returns the resource object request for the userName
 Resource checkOut(java.lang.String userName)
          Returns the resource object request for the userName
 java.util.Properties getProperties()
          Returns the resource 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.
protected  ResourcePool getResourcePool()
           
 ResourceStatistics getStats()
          Returns the statistics for this resource
 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()
          This method is invoked by the pool when the resource will have all its resources cleaned up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CONTEXT

protected static final java.lang.String LOG_CONTEXT
See Also:
Constant Field Values
Constructor Detail

BasicResourceContainer

public BasicResourceContainer(long containerID)
Method Detail

init

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

Specified by:
init in interface ResourceContainer
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

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

Specified by:
getResourceDescriptor in interface ResourceContainer
Returns:
ResourceDescriptor is the descriptor

getProperties

public java.util.Properties getProperties()
Returns the resource properties

Specified by:
getProperties in interface ResourceContainer
Returns:
Properties for the resource

hasAvailableResource

public boolean hasAvailableResource()
Description copied from interface: ResourceContainer
Returns true if one or more rescources are available for checkout in the specific container instance.

Specified by:
hasAvailableResource in interface ResourceContainer
Returns:
boolean true if a resource can be checked out.

isAlive

public boolean isAlive()
                throws ResourcePoolException
Description copied from interface: ResourceContainer
Return true if the physical resource is alive.

Specified by:
isAlive in interface ResourceContainer
Returns:
boolean true if the phsical resource is operational
Throws:
ResourcePoolException - is an error ocurrs when checking the state of the physical resource

checkOut

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

Specified by:
checkOut in interface ResourceContainer
Returns:
Resource object
Throws:
ResourcePoolException

checkin

public boolean checkin(Resource resource,
                       java.lang.String userName)
                throws ResourcePoolException
Returns the resource object request for the userName

Specified by:
checkin in interface ResourceContainer
Returns:
Resource object
Throws:
ResourcePoolException - is an error ocurrs when checking in resource

getResourceObject

public java.lang.Object getResourceObject()
Description copied from interface: ResourceContainer
Returns the physical resource object Do not call this method to checkout the resource.

Specified by:
getResourceObject in interface ResourceContainer
Returns:
Object object

shutDown

public final void shutDown()
                    throws ResourcePoolException
This method is invoked by the pool when the resource will have all its resources cleaned up. This resource will no longer be available for use. After calling this method, isAlive() should return false.

Specified by:
shutDown in interface ResourceContainer
Throws:
ResourcePoolException

getStats

public ResourceStatistics getStats()
Returns the statistics for this resource

Specified by:
getStats in interface ResourceContainer
Returns:
ResourceStatistics state

getResourcePool

protected ResourcePool getResourcePool()


Copyright © 2009. All Rights Reserved.