org.huihoo.jfox.pool
Class SimpleObjectPool

org.huihoo.jfox.service.ComponentSupport
  |
  +--org.huihoo.jfox.pool.AbstractObjectPool
        |
        +--org.huihoo.jfox.pool.SimpleObjectPool
All Implemented Interfaces:
Component, ComponentSupportMBean, Loggable, ObjectPool, ObjectPoolMBean, Persistentable, java.io.Serializable, SimpleObjectPoolMBean

public class SimpleObjectPool
extends AbstractObjectPool
implements SimpleObjectPoolMBean

Author:
Young Yang
See Also:
Serialized Form

Fields inherited from class org.huihoo.jfox.pool.AbstractObjectPool
factory
 
Fields inherited from class org.huihoo.jfox.service.ComponentSupport
logger, name, objectName, proxyInstance, sequence, server, 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.AbstractObjectPool
getObjectClass, getObjectFactory
 
Methods inherited from class org.huihoo.jfox.service.ComponentSupport
destroy, getLogger, getName, getObjectName, getProxyInstance, getState, handleNotification, init, parseName, postDeregister, postRegister, preDeregister, preRegister, setLogger, setName
 
Methods inherited from interface org.huihoo.jfox.pool.ObjectPoolMBean
getObjectClass, getObjectFactory
 
Methods inherited from interface org.huihoo.jfox.service.ComponentSupportMBean
getObjectName, getProxyInstance
 
Methods inherited from interface org.huihoo.jfox.service.Component
destroy, getName, getState, init
 
Methods inherited from interface org.huihoo.jfox.service.Loggable
getLogger
 

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
Returns:
 

restoreObject

public boolean restoreObject(PoolableObject obj)
restore the retrived object to object pool
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
Following copied from interface: org.huihoo.jfox.pool.ObjectPool
Parameters:
obj -  
Returns:
 

clear

public void clear()
Description copied from interface: ObjectPoolMBean
Clears any objects sitting idle in the pool, releasing any associated resources
Specified by:
clear in interface ObjectPoolMBean
Overrides:
clear in class AbstractObjectPool

getWorking

public int getWorking()
Description copied from interface: ObjectPoolMBean
get the count of working object
Specified by:
getWorking in interface ObjectPoolMBean
Overrides:
getWorking in class AbstractObjectPool
Following copied from interface: org.huihoo.jfox.pool.ObjectPoolMBean
Returns:
 

getRest

public int getRest()
Description copied from interface: ObjectPoolMBean
get the count of rest object
Specified by:
getRest in interface ObjectPoolMBean
Overrides:
getRest in class AbstractObjectPool
Following copied from interface: org.huihoo.jfox.pool.ObjectPoolMBean
Returns:
 

doInit

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

doDestroy

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

getInitNum

public int getInitNum()
Description copied from interface: SimpleObjectPoolMBean
初始化池中对象的数目
Specified by:
getInitNum in interface SimpleObjectPoolMBean
Following copied from interface: org.huihoo.jfox.pool.SimpleObjectPoolMBean
Returns:
 

getMaxRest

public int getMaxRest()
Description copied from interface: SimpleObjectPoolMBean
池中对象最大的空闲数,超过这个空闲数之后,返回池的对象将不在池中保存
Specified by:
getMaxRest in interface SimpleObjectPoolMBean
Following copied from interface: org.huihoo.jfox.pool.SimpleObjectPoolMBean
Returns:
 

main

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