com.atomikos.util
Interface ObjectPool

All Known Implementing Classes:
BaseObjectPool, LRUPool, SynchronizedObjectPool

public interface ObjectPool

Copyright © 2001, Atomikos. All rights reserved. An object pool is for efficient (re)use of objects.


Method Summary
 Identifiable add(Identifiable identifiable)
          Add an identifiable instance to the pool.
 Enumeration elements()
          Retrieve an enummeration of all elements in the pool.
 long getMaxSize()
          Get the maximum size of the pool.
 long getSize()
          Get the current size of the pool.
 boolean isEmpty()
          Test if pool is empty.
 boolean isFull()
          Test if pool is full.
 Identifiable remove()
          Remove an arbitrary element from the pool.
 Identifiable remove(Object id)
          Remove an object from the pool.
 Identifiable retrieve()
          Get an arbitrary element from the pool.
 Identifiable retrieve(Object id)
          Retrieve an object from the pool.
 

Method Detail

getMaxSize

long getMaxSize()
Get the maximum size of the pool.

Returns:
long The max size.

getSize

long getSize()
Get the current size of the pool.

Returns:
long The current size.

isFull

boolean isFull()
Test if pool is full.

Returns:
boolean True iff pool is full.

isEmpty

boolean isEmpty()
Test if pool is empty.

Returns:
boolean True iff pool is empty.

add

Identifiable add(Identifiable identifiable)
Add an identifiable instance to the pool. If the pool is full at its maximum, this method will return a victim that is thrown out of the pool. It is up to the client to treat those cases appropriately.

Parameters:
Identifiable - The object to put in the pool.
Returns:
Identifiable The object thrown out, or null if none.

retrieve

Identifiable retrieve(Object id)
                      throws ObjectNotFoundException
Retrieve an object from the pool.

Parameters:
id - The id of the object wanted.
Returns:
Identifiable The instance wanted.
Throws:
ObjectNotFoundException - If not found.

retrieve

Identifiable retrieve()
                      throws ObjectNotFoundException
Get an arbitrary element from the pool.

Returns:
Identifiable The selected element.
Throws:
ObjectNotFoundException - If empty.

elements

Enumeration elements()
                     throws ObjectNotFoundException
Retrieve an enummeration of all elements in the pool.

Returns:
Enumeration All elements.
Throws:
ObjectNotFoundException - If empty.

remove

Identifiable remove()
                    throws ObjectNotFoundException
Remove an arbitrary element from the pool.

Returns:
Identifiable The removed element.
Throws:
ObjectNotFoundException - If empty.

remove

Identifiable remove(Object id)
                    throws ObjectNotFoundException
Remove an object from the pool.

Parameters:
id - The identifier for the object.
Returns:
Identifiable The object removed.
Throws:
ObjectNotFoundException - If the id was not in the pool.