net.xoetrope.optional.pool
Class PoolManager

java.lang.Object
  extended by net.xoetrope.optional.pool.PoolManager
Direct Known Subclasses:
ConnectionManager

public abstract class PoolManager
extends java.lang.Object

Manages object pools

Copyright (c) Xoetrope Ltd. 2001-2003

$Revision: 2.3 $


Field Summary
protected  java.util.Vector objects
          The object pool data store
 
Constructor Summary
PoolManager(int size)
          Creates a new pool.
 
Method Summary
 void closeObjects()
          Closes and removes all objects in the pool
abstract  PoolObject getNewObject(java.lang.String name)
          Construct an new instance of a pooled object
 PoolObject getObject(java.lang.String name)
          Get a new object from the pool.
 void reapObjects()
          Removes dead objects from the pool
 void returnObject(PoolObject poolObject)
          return an object to the pool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objects

protected java.util.Vector objects
The object pool data store

Constructor Detail

PoolManager

public PoolManager(int size)
Creates a new pool.

Parameters:
size - the number of objects for the initial pool size
Method Detail

reapObjects

public void reapObjects()
Removes dead objects from the pool


closeObjects

public void closeObjects()
Closes and removes all objects in the pool


getObject

public PoolObject getObject(java.lang.String name)
                     throws java.lang.Exception
Get a new object from the pool. A lease is granted to the new object

Parameters:
name - the name of the resource, for example the connection name
Returns:
a new PoolObject
Throws:
java.lang.Exception - some problem was encounter when trying to get the object. Depends on the specific resource type. Please check this exception

getNewObject

public abstract PoolObject getNewObject(java.lang.String name)
                                 throws java.lang.Exception
Construct an new instance of a pooled object

Parameters:
name - the name of the new object
Returns:
the new object
Throws:
java.lang.Exception - problems...

returnObject

public void returnObject(PoolObject poolObject)
return an object to the pool

Parameters:
poolObject - the object being returned