/* 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 abstract class AbstractPoolableObject implements PoolableObject {
    private boolean available = false;

    private long passivateTime = System.currentTimeMillis();

    public void activate() throws Exception {
        available = true;
        passivateTime = System.currentTimeMillis();
    }

    // 该对象返回到池中，不再可用
    public void passivate() throws Exception {
        available = false;
        passivateTime = System.currentTimeMillis();
    }

    public boolean isAvailable() {
        return available;
    }

    public long getSleepTime() {
        return System.currentTimeMillis() - passivateTime;
    }
}