com.sapportals.portal.prt.util

Class AbstractPool

java.lang.Object
  extended by com.sapportals.portal.prt.util.AbstractPool
Direct Known Subclasses:
StringBufferPool

public abstract class AbstractPool
extends Object

Manages a pool of objects. Unused objects are removed after a certain period of time. The maximum number of objects managed by the pool is by default 100.
This property can be overriden when constructing the pool


Field Summary
protected  int mm_maxPoolSize
           
protected  List mm_unlocked
          Contains pool objects that are available for use
 
Constructor Summary
AbstractPool(int initialCapacity)
          Construct a pool given an initial capacity and the maximum number set to 100 to manage
AbstractPool(int initialCapacity, int nbInitialInstance)
          Construct a pool given an initial capacity and the number of initial items to manage
AbstractPool(int initialCapacity, int nbInitialInstance, int maxNumberObjects)
          Construct a pool given an initial capacity and the maximum number of items to manage
 
Method Summary
protected abstract  Object createPoolObject()
          Factory method to create pool objects
protected abstract  void expirePoolObject(Object o)
          Callback when object are not managed anymore by the pool.
 Object getPoolObject()
          Returns an object from the pool.
 void releasePoolObject(Object o)
          Tells the pool to release an object and make it available in the pool.
protected  void updateController(Object buffer, boolean add)
           
protected abstract  boolean validatePoolObject(Object o)
          Method called to validate an object that has been put back in the pool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mm_maxPoolSize

protected int mm_maxPoolSize

mm_unlocked

protected List mm_unlocked
Contains pool objects that are available for use

Constructor Detail

AbstractPool

public AbstractPool(int initialCapacity)
Construct a pool given an initial capacity and the maximum number set to 100 to manage

Parameters:
initialCapacity - the initial container capacity

AbstractPool

public AbstractPool(int initialCapacity,
                    int nbInitialInstance)
Construct a pool given an initial capacity and the number of initial items to manage

Parameters:
initialCapacity - the initial container capacity. You should here choose a value that is as close as the given maxNumberObjects.
nbInitialInstance - the initial number of objects to manage in the pool

AbstractPool

public AbstractPool(int initialCapacity,
                    int nbInitialInstance,
                    int maxNumberObjects)
Construct a pool given an initial capacity and the maximum number of items to manage

Parameters:
initialCapacity - the initial container capacity. You should here choose a value that is as close as the given maxNumberObjects.
nbInitialInstance - the initial number of objects to manage in the pool
maxNumberObjects - the maximum number of objects to manage in the pool. value -1 means infinite.
Method Detail

createPoolObject

protected abstract Object createPoolObject()
                                    throws Exception
Factory method to create pool objects

Returns:
the object to be pooled
Throws:
Exception

validatePoolObject

protected abstract boolean validatePoolObject(Object o)
Method called to validate an object that has been put back in the pool

Parameters:
o - the object to validate
Returns:
true is the object is valid for reuse.

expirePoolObject

protected abstract void expirePoolObject(Object o)
Callback when object are not managed anymore by the pool.

Parameters:
o - the object that is to be expired

getPoolObject

public Object getPoolObject()
                     throws Exception
Returns an object from the pool.
If no object was available, the object factory is called to instantiate an object

Returns:
an object coming form the pool, either newly created or and old valid one.
Throws:
Exception

releasePoolObject

public void releasePoolObject(Object o)
Tells the pool to release an object and make it available in the pool. If the maximum number of pool objects is reached, the object is not managed anymore by the pool.

Parameters:
o - the object to release.

updateController

protected void updateController(Object buffer,
                                boolean add)
Access Rights

This class can be accessed from:


SC DC Public Part ACH
[sap.com] EP-BASIS-API [sap.com] epbc.prtapi._apideprecated default EP-PIN-PRT
[sap.com] EP-BASIS-API [sap.com] tc/epbc/prt/api api EP-PIN
[sap.com] EP-BASIS-API [sap.com] tc/epbc/prt/lib/api api EP-PIN
[sap.com] EP-RUNTIME [sap.com] tc/ep/semantics/api api EP-PIN
[sap.com] KMC-WPC [sap.com] tc/kmc/wpc/wpcfacade api EP-PIN-WPC-WCM


Copyright 2015 SAP AG Complete Copyright Notice