org.sadun.util.pool2
Class BasePooledObject

java.lang.Object
  extended byorg.sadun.util.pool2.BasePooledObject
All Implemented Interfaces:
PooledObject

public abstract class BasePooledObject
extends java.lang.Object
implements PooledObject

A base implementation of a pooled object employing file serialization for passivation purposes.

This class offer support for handling the passivability and passivation state, and for object passivation/activation.

Version:
1.0
Author:
Cristiano Sadun

Constructor Summary
protected BasePooledObject(ObjectPool objectPool, java.lang.Object original)
           
 
Method Summary
 void _activate()
          Activate the object.
 java.lang.Object _getOriginal()
          Activate the object, if necessary, and returns the original object.
 boolean _isPassivable()
          Return the invariant passivable.state, as determined by the passivation manager associated to this pooled object.
 boolean _isPassivableNow()
          Return the current passivable.state.
 boolean _isPassivated()
          Returns the passivated state.
 void _passivate()
          This method passivates objects via serialization.
 void _releaseOriginal()
          Release the original, marking it as passivable.
 ObjectPool getObjectPool()
          Returns the objectPool.
protected  java.lang.Object getOriginal()
          Returns the original.
 java.io.File getSerializedFile()
          Return the serialized File, or null if the object is not passivated.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasePooledObject

protected BasePooledObject(ObjectPool objectPool,
                           java.lang.Object original)
Method Detail

_getOriginal

public final java.lang.Object _getOriginal()
                                    throws ActivationException
Description copied from interface: PooledObject
Activate the object, if necessary, and returns the original object. The object stays in core until is released by releaseOriginal().

Specified by:
_getOriginal in interface PooledObject
Throws:
ActivationException
See Also:
PooledObject._getOriginal()

_releaseOriginal

public final void _releaseOriginal()
Description copied from interface: PooledObject
Release the original, marking it as passivable.

Specified by:
_releaseOriginal in interface PooledObject
See Also:
PooledObject._releaseOriginal()

_activate

public final void _activate()
                     throws ActivationException
Activate the object. If the object has not been passivated, this method does nothing.

Specified by:
_activate in interface PooledObject
Throws:
ActivationException
See Also:
PooledObject._activate()

_passivate

public final void _passivate()
                      throws PassivationException
This method passivates objects via serialization.

The original object must be Serializable.

The object is assigned an unique file name in a directory whose name is the class name of the original object; it is then serialized using an ObjectOutputStream.

Specified by:
_passivate in interface PooledObject
Throws:
PassivationException
See Also:
PooledObject._passivate()

_isPassivableNow

public boolean _isPassivableNow()
Return the current passivable.state.

Specified by:
_isPassivableNow in interface PooledObject
Returns:
boolean

_isPassivable

public boolean _isPassivable()
Return the invariant passivable.state, as determined by the passivation manager associated to this pooled object.

For example, a passivation manager may require that an object be serializable or implement a specific interface.

Specified by:
_isPassivable in interface PooledObject
Returns:
boolean
See Also:
BasePassivationManager.canPassivate(java.lang.Class)

_isPassivated

public boolean _isPassivated()
Returns the passivated state.

Specified by:
_isPassivated in interface PooledObject
Returns:
boolean

getSerializedFile

public java.io.File getSerializedFile()
Return the serialized File, or null if the object is not passivated.

Returns:
File

toString

public java.lang.String toString()

getOriginal

protected java.lang.Object getOriginal()
Returns the original.

Returns:
Object

getObjectPool

public final ObjectPool getObjectPool()
Returns the objectPool.

Returns:
ExtendedObjectPool