org.openejb.cache
Class SimpleInstancePool

java.lang.Object
  extended byorg.openejb.cache.SimpleInstancePool
All Implemented Interfaces:
InstancePool

public final class SimpleInstancePool
extends Object
implements InstancePool

Version:
$Revision: 444624 $ $Date: 2004-03-01 08:17:26 +0100 (Mon, 01 Mar 2004) $

Constructor Summary
SimpleInstancePool(InstanceFactory factory, int maxSize, boolean hardLimit)
           
 
Method Summary
 Object acquire()
          Get an instance from the pool.
 void fill()
           
 int getAllocatedSize()
          Gets the number of allocated instances.
 int getMaxSize()
          Get the maximum size of the pool.
 int getSize()
          Return the size of the pool.
 boolean isHardLimit()
          Determines if this pool has a hard limit.
 boolean release(Object instance)
          Releases the hold on the instance.
 void remove(Object instance)
          Drop an instance permanently from the pool.
 void startPooling()
           
 List stopPooling()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleInstancePool

public SimpleInstancePool(InstanceFactory factory,
                          int maxSize,
                          boolean hardLimit)
Method Detail

fill

public void fill()
          throws Exception
Throws:
Exception

acquire

public Object acquire()
               throws Exception
Description copied from interface: InstancePool
Get an instance from the pool. This method may block indefinately if the pool has a strict limit.

Specified by:
acquire in interface InstancePool
Returns:
an instance
Throws:
Exception - if object demand object construction was required and an error occured during construction

release

public boolean release(Object instance)
Description copied from interface: InstancePool
Releases the hold on the instance. This method may or may not reinsert the instance into the pool. This method can not block.

Specified by:
release in interface InstancePool
Parameters:
instance - the instance to return to the pool
Returns:
true is the instance was reinserted into the pool.

remove

public void remove(Object instance)
Description copied from interface: InstancePool
Drop an instance permanently from the pool. The instance will never be used again. This method can not block.

Specified by:
remove in interface InstancePool
Parameters:
instance - the instance to discard

stopPooling

public List stopPooling()

startPooling

public void startPooling()

getSize

public int getSize()
Return the size of the pool.

Returns:
the size of the pool

getAllocatedSize

public int getAllocatedSize()
Gets the number of allocated instances. This may be larger then the max if the pools is using a soft limit.


getMaxSize

public int getMaxSize()
Get the maximum size of the pool.

Returns:
the size of the pool

isHardLimit

public boolean isHardLimit()
Determines if this pool has a hard limit.

Returns:
true if this pool is using a hard limit


Copyright © 1999-2006 OpenEJB. All Rights Reserved.