PooliT v2.0

org.ascentphase.poolit.poolers
Class LimitedPooler

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

public class LimitedPooler
extends java.lang.Object
implements Pooler

Wraps another Pooler class to limit the objects fetched by the pool. If the number of objects being pooled needs to be capped at a certain value (because of resource restrictions, eg: only 10 database connections allowed), use this class to prevent a pool from fetching or creating more objects than allowed.

Author:
Huy Duong

Constructor Summary
LimitedPooler(Pooler pool, int max)
          Caps the Pooler specified to only allow a maximum number of objects out of the pool at any one time.
 
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.
 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
 

Constructor Detail

LimitedPooler

public LimitedPooler(Pooler pool,
                     int max)
Caps the Pooler specified to only allow a maximum number of objects out of the pool at any one time.

Parameters:
pool - - the Pooler to wrap
max - - the maximum number of objects allowed out of pool
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.

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

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.