org.apache.avalon.excalibur.pool
Interface ManagablePool

All Superinterfaces:
org.apache.avalon.framework.component.Component, Pool
All Known Implementing Classes:
VariableSizePool

public interface ManagablePool
extends Pool

This is the interface for Pools that are not a fixed size. This interface exposes enough explicit state so that an external asynchronous Controller can do it's job. A secondary purpose of this interface is to supply a simple authentication mechanism so that the Pool only responds to method invocations by the legitimate controller.

The key is a randomly generated number greater than one assigned by the PoolManager and given to the Pool and the PoolController. The mechanism to generate the number is up to the PoolManager's policy. Keep in mind that should the key be made publicly available, the Pool is susceptible to a replay attack. Therefore, it is suggested that the key be created at the same time the Pool is created.

Since:
4.1
Version:
CVS $Revision: 1.3 $ $Date: 2002/01/28 19:29:47 $
Author:
Berin Loritsch

Method Summary
 void grow(int amount, long key)
          Grow by the specified amount.
 void shrink(int amount, long key)
          Shrink the pool by the specified amount.
 int size(long key)
          Determine the pool's current size.
 
Methods inherited from interface org.apache.avalon.excalibur.pool.Pool
get, put
 

Method Detail

grow

public void grow(int amount,
                 long key)
          throws java.lang.IllegalAccessException
Grow by the specified amount. The pool should trust the Controller for the Grow size.
Parameters:
amount - an integer amount to increase the pool size by.
key - an integer number supplied by the PoolManager to validate that the method is called legitimately
Throws:
java.lang.IllegalAccessException - if the key does not match the controller's key.

shrink

public void shrink(int amount,
                   long key)
            throws java.lang.IllegalAccessException
Shrink the pool by the specified amount. The pool should trust the Controller, but be smart enough not to achieve a negative pool size. In other words, you should clip the shrink amount so that the pool does not go below 0.
Parameters:
amount - an integer amount to decrease the pool size by.
key - an integer number supplied by the PoolManager to validate that the method is called legitimately
Throws:
java.lang.IllegalAccessException - if the key does not match the controller's key.

size

public int size(long key)
         throws java.lang.IllegalAccessException
Determine the pool's current size. The size is defined as the number of Poolable objects in reserve.
Parameters:
key - an integer number supplied by the PoolManager to validate that the method is called legitimately
Returns:
size of pool's reserve.
Throws:
java.lang.IllegalAccessException - if the key does not match the controller's key.


Copyright 2001 Apache Jakarta Project. All Rights Reserved.