/* 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;

/**
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */


public interface IndexableObjectPool {
    /**
     * retrieve Object from object pool with the key
     * 如果这个 key 还不存在，就新建该 key ，并返回和该 key 关联的对象
     *
     * @return
     */
    PoolableObject retrieveObject(Object key) throws Exception;

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

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

    /**
     * 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 count of working object
     *
     * @return
     */
    int getWorking();

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