org.openmobileis.common.util
Class ObjectPool

java.lang.Object
  extended byorg.openmobileis.common.util.ObjectPool
Direct Known Subclasses:
FileSystemObjectPool, 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 2006 OpenMobileIS. All Rights Reserved.