org.sadun.util.pool2
Class DefaultPassivationManager

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.sadun.util.pool2.BasePassivationManager
          extended byorg.sadun.util.pool2.DefaultPassivationManager
All Implemented Interfaces:
java.lang.Runnable, Terminable

public class DefaultPassivationManager
extends BasePassivationManager

The default passivation manager.

This passivation manager:

Author:
Cristiano Sadun

Field Summary
 
Fields inherited from class org.sadun.util.pool2.BasePassivationManager
logStream, monitoredPools, rotatePools, rotationRate, sleepTime
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DefaultPassivationManager()
          Constructor for DefaultPassivationManager.
DefaultPassivationManager(ObjectPool pool, java.lang.String name, int sleepTime)
          Constructor for DefaultPassivationManager.
DefaultPassivationManager(java.lang.String name)
          Constructor for DefaultPassivationManager.
DefaultPassivationManager(java.lang.String name, int sleepTime)
          Constructor for DefaultPassivationManager.
 
Method Summary
protected  void createState(ObjectPool pool, PooledObject obj)
          Used by a subclass to define an state information for a certain object belonging to a certain pool when a pool is added to the monitored set
static long getDefaultPassivationThreshold()
          Returns the defaultPassivationThreshold.
static DefaultPassivationManager getInstance()
          Returns the instance.
 long getPassivationThreshold()
          Returns the passivation threshold.
protected  void handleAcquired(ObjectPool pool, PooledObject obj)
          This method is used by the subclass to determine what to do when a pooled object is aquired.
protected  void handleInvoked(ObjectPool pool, PooledObject obj)
          This method is is used by the subclass to determine what to do when a pooled object is actually invoked.
protected  void handleReleased(ObjectPool pool, PooledObject obj)
          This method is invoked by the pool when a pooled object is released.
protected  boolean isToPassivate(ObjectPool pool, PooledObject obj, java.lang.Object preparationResult)
          This method is invoked to check whether an object is to passivate or not.
protected  java.lang.Object prepareForPassivationCheck(ObjectPool pool)
          This method is invoked just before a pool is checked for passivation, and therefore before any isToPassivate() is invoked.
protected  void removeState(ObjectPool pool, PooledObject obj)
          Used by a subclass to remove the state information for a certain object belonging to a certain pool when a pool is removed from the monitored set
static void setDefaultPassivationThreshold(long defaultPassivationThreshold)
          Sets the defaultPassivationThreshold.
 void setPassivationThreshold(long passivationThreshold)
          Sets the passivation threshold.
 
Methods inherited from class org.sadun.util.pool2.BasePassivationManager
addPool, canPassivate, countPools, getRotationRate, getSleepTime, isRotatePools, isShuttingDown, removePool, run, setLogStream, setRotatePools, setRotationRate, setSleepTime, shutdown
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultPassivationManager

public DefaultPassivationManager()
Constructor for DefaultPassivationManager.


DefaultPassivationManager

public DefaultPassivationManager(java.lang.String name)
Constructor for DefaultPassivationManager.

Parameters:
name -

DefaultPassivationManager

public DefaultPassivationManager(java.lang.String name,
                                 int sleepTime)
Constructor for DefaultPassivationManager.

Parameters:
name -

DefaultPassivationManager

public DefaultPassivationManager(ObjectPool pool,
                                 java.lang.String name,
                                 int sleepTime)
Constructor for DefaultPassivationManager.

Parameters:
pool -
name -
sleepTime -
Method Detail

createState

protected void createState(ObjectPool pool,
                           PooledObject obj)
Description copied from class: BasePassivationManager
Used by a subclass to define an state information for a certain object belonging to a certain pool when a pool is added to the monitored set

Specified by:
createState in class BasePassivationManager
Parameters:
obj - the object
pool - the pool the object belongs to

removeState

protected void removeState(ObjectPool pool,
                           PooledObject obj)
Description copied from class: BasePassivationManager
Used by a subclass to remove the state information for a certain object belonging to a certain pool when a pool is removed from the monitored set

Specified by:
removeState in class BasePassivationManager
Parameters:
obj - the object
pool - the pool the object belongs to
See Also:
BasePassivationManager.removeState(ObjectPool, PooledObject)

handleInvoked

protected void handleInvoked(ObjectPool pool,
                             PooledObject obj)
Description copied from class: BasePassivationManager
This method is is used by the subclass to determine what to do when a pooled object is actually invoked.

The passivation thread may collect this information to implements its passivation policy.

Specified by:
handleInvoked in class BasePassivationManager
Parameters:
obj - the PooledObject which is being invoked
See Also:
BasePassivationManager.handleInvoked(org.sadun.util.pool2.ObjectPool, org.sadun.util.pool2.PooledObject)

isToPassivate

protected boolean isToPassivate(ObjectPool pool,
                                PooledObject obj,
                                java.lang.Object preparationResult)
Description copied from class: BasePassivationManager
This method is invoked to check whether an object is to passivate or not.

Specified by:
isToPassivate in class BasePassivationManager
See Also:
BasePassivationManager.isToPassivate(org.sadun.util.pool2.ObjectPool, org.sadun.util.pool2.PooledObject, java.lang.Object)

handleAcquired

protected void handleAcquired(ObjectPool pool,
                              PooledObject obj)
Description copied from class: BasePassivationManager
This method is used by the subclass to determine what to do when a pooled object is aquired.

The passivation thread may collect this information to implements its passivation policy.

Specified by:
handleAcquired in class BasePassivationManager
Parameters:
obj - the PooledObject which is being acquired
See Also:
BasePassivationManager.handleAcquired(ObjectPool, PooledObject)

handleReleased

protected void handleReleased(ObjectPool pool,
                              PooledObject obj)
Description copied from class: BasePassivationManager
This method is invoked by the pool when a pooled object is released.

The passivation thread may collect this information to implements its passivation policy.

Specified by:
handleReleased in class BasePassivationManager
Parameters:
obj - the PooledObject which is being released
See Also:
BasePassivationManager.handleReleased(ObjectPool, PooledObject)

prepareForPassivationCheck

protected java.lang.Object prepareForPassivationCheck(ObjectPool pool)
Description copied from class: BasePassivationManager
This method is invoked just before a pool is checked for passivation, and therefore before any isToPassivate() is invoked.

A subclass may execute some preparation before the pool's object are actually scanned, and return an object as result. Such object is the passed to each subsequent isToPassivate() invocation.

Specified by:
prepareForPassivationCheck in class BasePassivationManager
Parameters:
pool -
See Also:
BasePassivationManager.prepareForPassivationCheck(ObjectPool)

getInstance

public static DefaultPassivationManager getInstance()
Returns the instance.

Returns:
DefaultPassivationManager

getPassivationThreshold

public long getPassivationThreshold()
Returns the passivation threshold.

Returns:
long

setPassivationThreshold

public void setPassivationThreshold(long passivationThreshold)
Sets the passivation threshold.

Parameters:
passivationThreshold - The passivationThreshold to set

getDefaultPassivationThreshold

public static long getDefaultPassivationThreshold()
Returns the defaultPassivationThreshold.

Returns:
long

setDefaultPassivationThreshold

public static void setDefaultPassivationThreshold(long defaultPassivationThreshold)
Sets the defaultPassivationThreshold.

Parameters:
defaultPassivationThreshold - The defaultPassivationThreshold to set