org.apache.geronimo.cache
Interface InstancePool

All Known Implementing Classes:
SimpleInstancePool

public interface InstancePool

Instance pool holds a number if instances that can be borrowed from the pool. Once an instance has been acquired it must be returned to the pool by calling release, which puts the instance back into the pool, or by calling remove, which marks the instance as no longer used but does not put it back in the pool. An implementation will have to refill the pool as entries are removed.

Version:
$Revision: 1.4 $ $Date: 2004/03/10 09:58:41 $

Method Summary
 Object acquire()
          Get an instance from the pool.
 boolean release(Object instance)
          Releases the hold on the instance.
 void remove(Object instance)
          Drop an instance permanently from the pool.
 

Method Detail

acquire

public Object acquire()
               throws InterruptedException,
                      Exception
Get an instance from the pool. This method may block indefinately if the pool has a strict limit.

Returns:
an instance
Throws:
InterruptedException - if pool is using hard limits and thread was interrupted while waiting for an instance to become available
Exception - if object demand object construction was required and an error occured during construction

release

public boolean release(Object instance)
Releases the hold on the instance. This method may or may not reinsert the instance into the pool. This method can not block.

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)
Drop an instance permanently from the pool. The instance will never be used again. This method can not block.

Parameters:
instance - the instance to discard


Copyright © 2003-2005 Apache Software Foundation. All Rights Reserved.