/* 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 PoolableObject {

    /**
     * actvite the object before it be retrived
     */
    void activate() throws Exception;

    /**
     * passivate the object before it be restored, set the status to initialized
     */
    void passivate() throws Exception;

    /**
     * 表明该对象是否能返回到池中
     * 注意，如果一个对象已在池中，该方法也应该返回 false，表明该对象不可被使用
     */
    boolean isAvailable();

    /**
     * get the time that the poolable object has sleeped in the pool
     * <p/>
     * pool can decide whether to remove it according the time
     *
     * @return
     */
    long getSleepTime();
}