KickJava   Java API By Example, From Geeks To Geeks.

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


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  * the method a object pool needed
11  *
12  * @author <a HREF="mailto:young_yy@hotmail.com">Young Yang</a>
13  */

14
15
16 public interface ObjectPool {
17     /**
18      * retrieve Object from object pool
19      *
20      * @return
21      */

22     PoolableObject retrieveObject() throws Exception JavaDoc;
23
24     /**
25      * restore the retrived object to object pool
26      *
27      * @return true if success, false if failed
28      */

29     boolean restoreObject(PoolableObject obj);
30
31     /**
32      * remove a poolable object from the pool
33      *
34      * @param obj
35      * @return
36      */

37     boolean removeObject(PoolableObject obj);
38
39     /**
40      * Clears any objects sitting idle in the pool, releasing any associated resources
41      */

42     void clear();
43
44     /**
45      * get the factory use to create new instances
46      */

47     ObjectFactory getObjectFactory();
48
49     /**
50      * get the pooled object's class type, it return by object pool's factory
51      *
52      * @return
53      */

54     String JavaDoc getObjectClass();
55
56     /**
57      * get the count of working object
58      *
59      * @return
60      */

61     int getWorking();
62
63     /**
64      * get the count of rest object
65      *
66      * @return
67      */

68     int getRest();
69
70     /**
71      * 初始化池中对象的数目
72      *
73      * @return
74      */

75     int getInitNum();
76
77     /**
78      * 池中对象最大的空闲数,超过这个空闲数之后,返回池的对象将不在池中保存
79      *
80      * @return
81      */

82     int getMaxRest();
83
84 }
85
Popular Tags