PooliT v2.0

org.ascentphase.poolit.poolers
Class NotifyPooler

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

public class NotifyPooler
extends java.lang.Object
implements Pooler

Notifies objects when they are fetched from and released to the pool. This Pooler works by notifying objects in the pool that implement the NotifyPoolListener when the object leaves the pool and is returned to the pool. If the object does not implement NotifyPoolListener, nothing happens. This class wraps another Pooler that implements a specific pooling algorithm and permits notification of objects when leaving/entering the pool.

Author:
huyd

Constructor Summary
NotifyPooler(Pooler p)
          Creates a new instance of NotifyPooler
 
Method Summary
 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 and if the object implements the NotifyPoolListener interface, then it calls the objects fetched() method.
 void release(java.lang.Object o)
          Returns an object to the pool and if the object implements the NotifyPoolListener interface, then it calls the objects released() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotifyPooler

public NotifyPooler(Pooler p)
Creates a new instance of NotifyPooler

Method Detail

fetch

public java.lang.Object fetch()
                       throws FetchException
Retrieves an object from the pool and if the object implements the NotifyPoolListener interface, then it calls the objects fetched() method.

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.

release

public void release(java.lang.Object o)
Returns an object to the pool and if the object implements the NotifyPoolListener interface, then it calls the objects released() method.

Specified by:
release in interface Pooler
Parameters:
o - the 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()

PooliT v2.0

Copyright © 2005 Ascent Phase Corp.