/* JFox, the OpenSource J2EE Application Server
 *
 * Distributable under GNU LGPL license by gun.org
 * more details please visit http://www.huihoo.org/jfox
 */

package org.jfox.pool;

/**
 * the method a object pool needed
 *
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */


public interface ObjectPool {
    /**
     * retrieve Object from object pool
     *
     * @return
     */
    PoolableObject retrieveObject() throws Exception;

    /**
     * restore the retrived object to object pool
     *
     * @return true if success, false if failed
     */
    boolean restoreObject(PoolableObject obj);

    /**
     * remove a poolable object from the pool
     *
     * @param obj
     * @return
     */
    boolean removeObject(PoolableObject obj);

    /**
     * Clears any objects sitting idle in the pool, releasing any associated resources
     */
    void clear();

    /**
     * get the factory use to create new instances
     */
    ObjectFactory getObjectFactory();

    /**
     * get the pooled object's class type, it return by object pool's factory
     *
     * @return
     */
    String getObjectClass();

    /**
     * get the count of working object
     *
     * @return
     */
    int getWorking();

    /**
     * get the count of rest object
     *
     * @return
     */
    int getRest();

    /**
     * 初始化池中对象的数目
     *
     * @return
     */
    int getInitNum();

    /**
     * 池中对象最大的空闲数，超过这个空闲数之后，返回池的对象将不在池中保存
     *
     * @return
     */
    int getMaxRest();

}
