com.metamatrix.common.pooling.impl
Class BaseResource

java.lang.Object
  extended by com.metamatrix.common.pooling.impl.BaseResource
All Implemented Interfaces:
Resource
Direct Known Subclasses:
JDBCConnectionResource

public abstract class BaseResource
extends java.lang.Object
implements Resource


Field Summary
protected static java.lang.String LOG_CONTEXT
           
 
Constructor Summary
BaseResource()
           
 
Method Summary
protected abstract  boolean checkIsResourceAlive()
          This method is invoked when isAlive is called to determine if the resource is operating normally.
 void closeResource()
          This method should be invoked by the extended class to notify the pool the use of the resource is not longer needed.
 java.lang.String getCheckedOutBy()
          Returns name of user that checked out this resource
 ResourceContainer getContainer()
           
 void init(ResourceContainer resourceContainer, java.lang.String checkedOutBy)
          This method is invoked by the pool to set a reference of itself on the 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 isClosed()
           
 boolean isResourceAlive()
          Call isAlive to determine if the resource is operating normally.
protected abstract  void performInit()
          Perform initialization allows for additional initialization by the implementor before the resource object is made avaialable for use.
 
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

BaseResource

public BaseResource()
Method Detail

init

public void init(java.lang.String checkedOutBy)
          throws ResourcePoolException
Description copied from interface: Resource
Called by the adapter for the resource to initialize itself and validate it should be valid resource for use.

Specified by:
init in interface Resource
Parameters:
checkedOutBy - is the name of the user for which this resource instance is being used
Throws:
ResourcePoolException - if not a valid resource

init

public void init(ResourceContainer resourceContainer,
                 java.lang.String checkedOutBy)
          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.
Throws:
ResourcePoolException - if an error occurs initializing resource.

getCheckedOutBy

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

Specified by:
getCheckedOutBy in interface Resource
Returns:
String is the name of the user who checked out the resource

getContainer

public ResourceContainer getContainer()

closeResource

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

Specified by:
closeResource in interface Resource
Throws:
ResourcePoolConnection - if there is an error closing the resource
ResourcePoolException

isResourceAlive

public final boolean isResourceAlive()
Call isAlive to determine if the resource is operating normally. This method is called by the pool when the resource is checked in. A return of false indicates the resource should not be used. If the resource is unusable, it will be shutdown an another instance will take its place.

Specified by:
isResourceAlive in interface Resource
Returns:
boolean true if the resource is operating normally

isClosed

public final boolean isClosed()
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

performInit

protected abstract void performInit()
                             throws ResourcePoolException
Perform initialization allows for additional initialization by the implementor before the resource object is made avaialable for use.

Throws:
ResourcePoolException - if an error occurs initializing resource.

checkIsResourceAlive

protected abstract boolean checkIsResourceAlive()
This method is invoked when isAlive is called to determine if the resource is operating normally. This logic is called by the pool when the resource is checked in to verify its state prior to placing it back in the pool.

A return of false indicates the resource should not be used. If the resource is unusable, it will be shutdown an another instance will take its place.

Returns:
boolean true if the resource is operating normally


Copyright © 2009. All Rights Reserved.