com.metamatrix.common.pooling.impl
Class ResourcePoolMgrImpl

java.lang.Object
  extended by com.metamatrix.common.pooling.impl.ResourcePoolMgrImpl
All Implemented Interfaces:
ResourcePoolMgr

public class ResourcePoolMgrImpl
extends java.lang.Object
implements ResourcePoolMgr

The ResourcePoolMgr is the center point for managing and sharing a common object type among common users. The benefit of managing an object as a resource is so that common users can share the object without the overhead of reoccurring object creation, desctruction and cleanup. To utilize the resource pooling feature the following needs to be done:

    k
  1. the resource type categorically identifies the resource (e.g., JDBCConnectionResourceType). The resource type can provide defaults that will be applied to all the specific ResourceDescriptor implementations that are of that type. Therefore, there is a one-to-many relationship between the resource type and descriptor, respectfully.

Once the appropriate set of classes have been implemented for a resource, the following are the steps for using a resource:

  • Instantiate the specific ResourceDescriptor and call ResourcePoolMgr.getResource(com.metamatrix.common.config.api.ResourceDescriptor, java.lang.String) to obtain a resource instance from the pool.
  • When the user is finished with the resource, Resource.closeResource() method must be called in order to release the resource back to the pool for reuse.

  • Constructor Summary
    ResourcePoolMgrImpl()
               
     
    Method Summary
     java.util.Collection getAllResourceDescriptorIDs()
              Call to get id's for all the current resource pools.
     java.util.Collection getAllResourceDescriptors()
              Call to get all the resource descriptors for the current pools.
    protected  ResourcePoolMgrImpl getInstance()
               
     Resource getResource(ResourceDescriptor descriptor, java.lang.String userName)
              Call to get a resource from the pool defined by descriptor.
     ResourceDescriptor getResourceDescriptor(ResourceDescriptorID descriptorID)
              Call to get the resource descriptor for the specified id
     ResourcePool getResourcePool(ResourceDescriptor descriptor)
              Do Not call this method to update the resource pool This method was made available for testing
     ResourcePool getResourcePool(ResourceDescriptorID descriptorID)
              Do Not call this method to update the resource pool This method was made available for testing
     java.util.Collection getResourcePools()
              Do Not call this method to update the resource pool This method was made available for testing
     java.util.Collection getResourcePoolStatistics()
              Returns all the ResourcePoolStatistics currently active.
     ResourcePoolStatistics getResourcePoolStatistics(ResourceDescriptorID descriptorID)
              Returns the statistics for a specific resource descriptor id.
     java.util.Collection getResourcesStatisticsForPool(ResourceDescriptorID descriptorID)
              Returns all the ResourceStatistics for the pool.
    protected  void init()
               
    protected  java.util.Collection rd1$()
               
    protected  java.util.Collection rd2$()
               
    protected  ResourceDescriptor rd3$(ResourceDescriptorID descriptorID)
               
    protected  ResourcePool rp1$(ResourceDescriptor descriptor)
               
    protected  ResourcePool rp2$(ResourceDescriptorID descriptorID)
               
    protected  java.util.Collection rp4$()
               
    protected  java.util.Collection rps1$()
               
    protected  ResourcePoolStatistics rps2$(ResourceDescriptorID descriptorID)
               
    protected  java.util.Collection rsp1$(ResourceDescriptorID descriptorID)
               
    protected  void sd1$()
               
    protected  void sd2$(ResourceDescriptorID descriptorID)
               
    protected  void setIsBeingShutDown(boolean shutDown)
               
     void shutDown()
              Call to shutdown all resource pools and all the resources within those pools.
     void shutDown(ResourceDescriptorID descriptorID)
              Call to shutdown all resources in the specific pool identified by the descriptor ID.
     void updateResourcePool(ResourceDescriptorID descriptorID, java.util.Properties props)
              Call to update the pool management parameters based on the resource descriptor.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    ResourcePoolMgrImpl

    public ResourcePoolMgrImpl()
    Method Detail

    getResource

    public Resource getResource(ResourceDescriptor descriptor,
                                java.lang.String userName)
                         throws ResourcePoolException
    Call to get a resource from the pool defined by descriptor.

    Specified by:
    getResource in interface ResourcePoolMgr
    Parameters:
    descriptor - that describes the resource to obtain
    userName - of the one requesting the resource
    Returns:
    Resource that is defined by the descriptor
    Throws:
    ResourcePoolException - is thrown if an error ocurrs. Check for type ResourceWaitTimeOutException

    getAllResourceDescriptorIDs

    public java.util.Collection getAllResourceDescriptorIDs()
                                                     throws ResourcePoolException
    Call to get id's for all the current resource pools.

    Specified by:
    getAllResourceDescriptorIDs in interface ResourcePoolMgr
    Returns:
    Collection of type ResourcePoolIDs for all the resource pools.
    Throws:
    ResourcePoolException - is thrown if an error ocurrs. Check for type ResourceWaitTimeOutException

    getAllResourceDescriptors

    public java.util.Collection getAllResourceDescriptors()
                                                   throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Call to get all the resource descriptors for the current pools.

    Specified by:
    getAllResourceDescriptors in interface ResourcePoolMgr
    Returns:
    Collection of type ResourceDescriptor for all the resource pools.
    Throws:
    ResourcePoolException - is thrown if an error occurs. ResourceDescriptor

    getResourceDescriptor

    public ResourceDescriptor getResourceDescriptor(ResourceDescriptorID descriptorID)
                                             throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Call to get the resource descriptor for the specified id

    Specified by:
    getResourceDescriptor in interface ResourcePoolMgr
    Parameters:
    descriptorID - is the id that identifies the resource descriptor
    Returns:
    ResourceDescriptor identified by the id
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    updateResourcePool

    public void updateResourcePool(ResourceDescriptorID descriptorID,
                                   java.util.Properties props)
                            throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Call to update the pool management parameters based on the resource descriptor. This could include changing the size of the pool.

    Specified by:
    updateResourcePool in interface ResourcePoolMgr
    Parameters:
    descriptorID - identifies the pool to update
    props - are the changes to be applied
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    getResourcePoolStatistics

    public java.util.Collection getResourcePoolStatistics()
                                                   throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Returns all the ResourcePoolStatistics currently active. An empty collection will be returned if no resource pools are active.

    Specified by:
    getResourcePoolStatistics in interface ResourcePoolMgr
    Returns:
    Collection of type ResourcePoolStatistics
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    getResourcePoolStatistics

    public ResourcePoolStatistics getResourcePoolStatistics(ResourceDescriptorID descriptorID)
                                                     throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Returns the statistics for a specific resource descriptor id. If the ResourcePool does not exist for the descriptorID, then a null will be returned.

    Specified by:
    getResourcePoolStatistics in interface ResourcePoolMgr
    Returns:
    ResourcePoolStatistics for a specific resource pool; null if resource pool does not exit.
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    getResourcesStatisticsForPool

    public java.util.Collection getResourcesStatisticsForPool(ResourceDescriptorID descriptorID)
                                                       throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Returns all the ResourceStatistics for the pool. An empty collection will be returned if no resources exist in the pool.

    Specified by:
    getResourcesStatisticsForPool in interface ResourcePoolMgr
    Returns:
    Collection of type ResourceStatistics
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    shutDown

    public void shutDown(ResourceDescriptorID descriptorID)
                  throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Call to shutdown all resources in the specific pool identified by the descriptor ID.

    Specified by:
    shutDown in interface ResourcePoolMgr
    Parameters:
    descriptorID - for the pool to be shutdown
    Throws:
    ResourcePoolException - is thrown if an error occurs.

    shutDown

    public void shutDown()
                  throws ResourcePoolException
    Description copied from interface: ResourcePoolMgr
    Call to shutdown all resource pools and all the resources within those pools.

    Specified by:
    shutDown in interface ResourcePoolMgr
    Throws:
    ResourcePoolException

    getResourcePool

    public ResourcePool getResourcePool(ResourceDescriptorID descriptorID)
                                 throws ResourcePoolException
    Do Not call this method to update the resource pool This method was made available for testing

    Throws:
    ResourcePoolException

    getResourcePool

    public ResourcePool getResourcePool(ResourceDescriptor descriptor)
                                 throws ResourcePoolException
    Do Not call this method to update the resource pool This method was made available for testing

    Throws:
    ResourcePoolException

    getResourcePools

    public java.util.Collection getResourcePools()
                                          throws ResourcePoolException
    Do Not call this method to update the resource pool This method was made available for testing

    Throws:
    ResourcePoolException

    getInstance

    protected ResourcePoolMgrImpl getInstance()
                                       throws ResourcePoolException
    Throws:
    ResourcePoolException

    init

    protected void init()
                 throws ResourcePoolException
    Throws:
    ResourcePoolException

    setIsBeingShutDown

    protected void setIsBeingShutDown(boolean shutDown)

    rp1$

    protected ResourcePool rp1$(ResourceDescriptor descriptor)

    rp2$

    protected ResourcePool rp2$(ResourceDescriptorID descriptorID)

    rd2$

    protected java.util.Collection rd2$()
                                 throws ResourcePoolException
    Throws:
    ResourcePoolException

    rd1$

    protected java.util.Collection rd1$()
                                 throws ResourcePoolException
    Throws:
    ResourcePoolException

    rd3$

    protected ResourceDescriptor rd3$(ResourceDescriptorID descriptorID)
                               throws ResourcePoolException
    Throws:
    ResourcePoolException

    rp4$

    protected java.util.Collection rp4$()

    rps1$

    protected java.util.Collection rps1$()
                                  throws ResourcePoolException
    Throws:
    ResourcePoolException

    rps2$

    protected ResourcePoolStatistics rps2$(ResourceDescriptorID descriptorID)
                                    throws ResourcePoolException
    Throws:
    ResourcePoolException

    rsp1$

    protected java.util.Collection rsp1$(ResourceDescriptorID descriptorID)
                                  throws ResourcePoolException
    Throws:
    ResourcePoolException

    sd1$

    protected void sd1$()
                 throws ResourcePoolException
    Throws:
    ResourcePoolException

    sd2$

    protected void sd2$(ResourceDescriptorID descriptorID)
                 throws ResourcePoolException
    Throws:
    ResourcePoolException


    Copyright © 2009. All Rights Reserved.