org.openmobileis.common.util
Class ObjectPool

java.lang.Object
  extended byorg.openmobileis.common.util.ObjectPool
Direct Known Subclasses:
ServerThreadPool

public abstract class ObjectPool
extends java.lang.Object

Title: OpenMobileIS project source
Description: Implement a generic object pool. The pool contain a set of object and client get and dispose object depending on there need. When an object is retreive fro; the pool (getObject ()), it must be disposed. If not it can leads to memory link ( object not garbage collected). So to insure this behaviour put object use in a try / finally clause. example :

Object obj = ObjectPool.getObject(); try { // use the object } finally [ ObjectPool.disposeObject(obj); }

A pool can only create a single type of object. The size of the pool is initialized with the minimum size at the begining and grow by the specified increment size.

Since:
JDK 1.1
Version:
1.0.
Author:
Philippe Delrieu

Field Summary
protected  Array arrayPool
           
protected  int incSize_
           
protected  int minSize_
           
protected  java.lang.Class objectClass_
           
protected  java.util.Stack pool_
           
 
Constructor Summary
protected ObjectPool(java.lang.String objectClass, int minSize, int incSize)
           
 
Method Summary
protected  java.lang.Object createNewInstance(java.lang.Class objectClass)
          A factory method that you may override to instantiate the proper object Default implementation does a newInstance()
 void disposeObject(java.lang.Object object)
           
protected  java.lang.Object getObject()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool_

protected java.util.Stack pool_

arrayPool

protected Array arrayPool

objectClass_

protected java.lang.Class objectClass_

minSize_

protected int minSize_

incSize_

protected int incSize_
Constructor Detail

ObjectPool

protected ObjectPool(java.lang.String objectClass,
                     int minSize,
                     int incSize)
              throws java.lang.ClassNotFoundException,
                     java.lang.IllegalAccessException,
                     java.lang.InstantiationException
Parameters:
objectClass -
minSize -
incSize -
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
Since:
See Also:
Method Detail

createNewInstance

protected java.lang.Object createNewInstance(java.lang.Class objectClass)
                                      throws java.lang.IllegalAccessException,
                                             java.lang.InstantiationException
A factory method that you may override to instantiate the proper object Default implementation does a newInstance()

Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException

getObject

protected final java.lang.Object getObject()
Returns:
Object
Throws:
Since:
See Also:

disposeObject

public void disposeObject(java.lang.Object object)
Parameters:
object -
Returns:
void
Throws:
Since:
See Also:


Copyright 2005 e-Care. All Rights Reserved.