org.huihoo.jfox.pool
Class SimpleObjectPool

java.lang.Object
  extended byorg.huihoo.jfox.system.ComponentSupport
      extended byorg.huihoo.jfox.pool.ObjectPoolSupport
          extended byorg.huihoo.jfox.pool.SimpleObjectPool
All Implemented Interfaces:
Component, Loggable, ObjectPool, Persistentable, java.io.Serializable, SimpleObjectPoolInterface

public class SimpleObjectPool
extends ObjectPoolSupport
implements SimpleObjectPoolInterface

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.huihoo.jfox.pool.ObjectPoolSupport
factory
 
Fields inherited from class org.huihoo.jfox.system.ComponentSupport
logger, name, proxyInstance, sequence, state
 
Constructor Summary
SimpleObjectPool(ObjectFactory factory)
           
SimpleObjectPool(ObjectFactory factory, int initNum, int maxRest)
           
SimpleObjectPool(java.lang.String objectFactoryClassName, java.lang.String poolableClassName)
           
SimpleObjectPool(java.lang.String objectFactoryClassName, java.lang.String poolableClassName, int initNum, int maxRest)
           
 
Method Summary
 void clear()
          Clears any objects sitting idle in the pool, releasing any associated resources
protected  void doDestroy()
          do actually destory action
protected  void doInit()
          do actually create action
 int getInitNum()
          初始化池中对象的数目
 int getMaxRest()
          池中对象最大的空闲数,超过这个空闲数之后,返回池的对象将不在池中保存
 int getRest()
          get the count of rest object
 int getWorking()
          get the count of working object
static void main(java.lang.String[] args)
           
 boolean removeObject(PoolableObject obj)
          remove a poolable object from the pool
 boolean restoreObject(PoolableObject obj)
          restore the retrived object to object pool
 PoolableObject retrieveObject()
          retrieve Object from object pool
 
Methods inherited from class org.huihoo.jfox.pool.ObjectPoolSupport
getObjectClass, getObjectFactory
 
Methods inherited from class org.huihoo.jfox.system.ComponentSupport
destroy, getLogger, getName, getState, init, parseName, setLogger, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.huihoo.jfox.pool.ObjectPool
getObjectClass, getObjectFactory
 

Constructor Detail

SimpleObjectPool

public SimpleObjectPool(ObjectFactory factory)

SimpleObjectPool

public SimpleObjectPool(ObjectFactory factory,
                        int initNum,
                        int maxRest)

SimpleObjectPool

public SimpleObjectPool(java.lang.String objectFactoryClassName,
                        java.lang.String poolableClassName)

SimpleObjectPool

public SimpleObjectPool(java.lang.String objectFactoryClassName,
                        java.lang.String poolableClassName,
                        int initNum,
                        int maxRest)
Method Detail

retrieveObject

public PoolableObject retrieveObject()
                              throws java.lang.Exception
retrieve Object from object pool

Specified by:
retrieveObject in interface ObjectPool
Returns:
Throws:
java.lang.Exception

restoreObject

public boolean restoreObject(PoolableObject obj)
restore the retrived object to object pool

Specified by:
restoreObject in interface ObjectPool
Returns:
true if object passivate && push success, false if failed

removeObject

public boolean removeObject(PoolableObject obj)
Description copied from interface: ObjectPool
remove a poolable object from the pool

Specified by:
removeObject in interface ObjectPool
Parameters:
obj -
Returns:

clear

public void clear()
Description copied from interface: ObjectPool
Clears any objects sitting idle in the pool, releasing any associated resources

Specified by:
clear in interface ObjectPool
Overrides:
clear in class ObjectPoolSupport

getWorking

public int getWorking()
Description copied from interface: ObjectPool
get the count of working object

Specified by:
getWorking in interface ObjectPool
Overrides:
getWorking in class ObjectPoolSupport
Returns:

getRest

public int getRest()
Description copied from interface: ObjectPool
get the count of rest object

Specified by:
getRest in interface ObjectPool
Overrides:
getRest in class ObjectPoolSupport
Returns:

doInit

protected void doInit()
               throws java.lang.Exception
Description copied from class: ComponentSupport
do actually create action

Overrides:
doInit in class ObjectPoolSupport
Throws:
java.lang.Exception

doDestroy

protected void doDestroy()
                  throws java.lang.Exception
Description copied from class: ComponentSupport
do actually destory action

Overrides:
doDestroy in class ObjectPoolSupport
Throws:
java.lang.Exception

getInitNum

public int getInitNum()
Description copied from interface: SimpleObjectPoolInterface
初始化池中对象的数目

Specified by:
getInitNum in interface SimpleObjectPoolInterface
Returns:

getMaxRest

public int getMaxRest()
Description copied from interface: SimpleObjectPoolInterface
池中对象最大的空闲数,超过这个空闲数之后,返回池的对象将不在池中保存

Specified by:
getMaxRest in interface SimpleObjectPoolInterface
Returns:

main

public static void main(java.lang.String[] args)