org.jboss.portlet.forums.helper
Class AbstractPool

java.lang.Object
  extended by org.jboss.portlet.forums.helper.AbstractPool
Direct Known Subclasses:
SimpleDateFormatPool

public abstract class AbstractPool
extends java.lang.Object

A simple object pool designed for extensibility. There is no resizer thread so far.


Constructor Summary
protected AbstractPool()
           
 
Method Summary
protected  void _acquire(java.lang.Object instance)
          The method does nothing bu default, called when the client release an instance.
protected abstract  java.lang.Object _create()
          Called when the pool need a new instance.
protected  void _destroy(java.lang.Object instance)
          The method does nothing bu default, called when the client release an instance.
protected  void _release(java.lang.Object instance)
          The method does nothing bu default, called when the client release an instance.
 java.lang.Object acquire()
          Returns an object instance.
protected  void initialize(int maxSize, int initialSize)
          Initialize the pool.
 void release(java.lang.Object instance)
          Release an object and pools it if the pool is not full, otherwise discard it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPool

protected AbstractPool()
Method Detail

acquire

public java.lang.Object acquire()
Returns an object instance. If the Pool is empty a new object will be created.

Returns:
A pooled instance.

release

public void release(java.lang.Object instance)
Release an object and pools it if the pool is not full, otherwise discard it.

Parameters:
instance - the released instance.

initialize

protected void initialize(int maxSize,
                          int initialSize)
Initialize the pool.

Parameters:
maxSize - the max size of object in the pool
initialSize - the initial size. A negative value is considered as zero, a value greater than maxSize is considered as maxSize.

_destroy

protected void _destroy(java.lang.Object instance)
The method does nothing bu default, called when the client release an instance.


_acquire

protected void _acquire(java.lang.Object instance)
The method does nothing bu default, called when the client release an instance.


_release

protected void _release(java.lang.Object instance)
The method does nothing bu default, called when the client release an instance.


_create

protected abstract java.lang.Object _create()
Called when the pool need a new instance.