PooliT v2.0

org.ascentphase.poolit.poolers
Class NotifierPooler

java.lang.Object
  extended byorg.ascentphase.poolit.poolers.NotifierPooler
All Implemented Interfaces:
Pooler

public class NotifierPooler
extends java.lang.Object
implements Pooler

Notifies listeners who are interested in knowing when objects are being fetched and released. Classes wishing to be notified must implement the NotifierPoolListener interface and be registered with this Pooler by calling the addListener() method. Listeners' fetched() method is called after the underlying Poolers fetch() is called. The listeners' released() method is called before the underlying Poolers release() method is called. This Pooler wraps another Pooler that implements the actual pooling algorithm.

Author:
huyd

Field Summary
protected  java.util.Collection listeners
           
protected  Pooler pool
           
 
Constructor Summary
NotifierPooler(Pooler p)
           
 
Method Summary
 void addListener(NotifierPoolListener listener)
          Adds a listener to this Pooler to be notified when objects are fetched and released.
 void close()
          Releases all objects in the pool and any resources held by these objects.
 java.lang.Object fetch()
          Retrieves an object from the pool.
 void release(java.lang.Object o)
          Returns an object to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

protected Pooler pool

listeners

protected java.util.Collection listeners
Constructor Detail

NotifierPooler

public NotifierPooler(Pooler p)
Method Detail

fetch

public java.lang.Object fetch()
                       throws FetchException
Description copied from interface: Pooler
Retrieves an object from the pool.

Specified by:
fetch in interface Pooler
Returns:
an object from the pool
Throws:
FetchException - if the pooler is unable to return an object from the pool.
See Also:
Pooler.fetch()

release

public void release(java.lang.Object o)
Description copied from interface: Pooler
Returns an object to the pool.

Specified by:
release in interface Pooler
Parameters:
o - the object
See Also:
Pooler.release(java.lang.Object)

close

public void close()
Description copied from interface: Pooler
Releases all objects in the pool and any resources held by these objects.

Specified by:
close in interface Pooler
See Also:
Pooler.close()

addListener

public void addListener(NotifierPoolListener listener)
Adds a listener to this Pooler to be notified when objects are fetched and released.

Parameters:
listener - a NotifierPoolListener to be notified of Pooler events.

PooliT v2.0

Copyright © 2005 Ascent Phase Corp.