KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > pool > AbstractPoolableObject


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

6
7 package org.jfox.pool;
8
9 /**
10  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
11  */

12
13 public abstract class AbstractPoolableObject implements PoolableObject {
14     private boolean available = false;
15
16     private long passivateTime = System.currentTimeMillis();
17
18     public void activate() throws Exception JavaDoc {
19         available = true;
20         passivateTime = System.currentTimeMillis();
21     }
22
23     // 该对象返回到池中,不再可用
24
public void passivate() throws Exception JavaDoc {
25         available = false;
26         passivateTime = System.currentTimeMillis();
27     }
28
29     public boolean isAvailable() {
30         return available;
31     }
32
33     public long getSleepTime() {
34         return System.currentTimeMillis() - passivateTime;
35     }
36 }
Popular Tags