KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > pool > api > Pool


1 /**
2  * Copyright (C) 2001-2002
3  * - France Telecom R&D
4  * - Laboratoire Logiciels, Systemes, Reseaux - UMR 5526, CNRS-INPG-UJF
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Release: 1.0
21  *
22  * Authors:
23  *
24  */

25
26 package org.objectweb.perseus.pool.api;
27
28 import org.objectweb.perseus.dependency.api.DeadLockException;
29
30 import java.util.Collection JavaDoc;
31
32
33 /**
34  * The interface <b>Pool</b> defines an object that pools resources of any
35  * kind. Resources must be requested (getResource) and released
36  * (releaseResource) on demand. A Pool object can be parameterized along
37  * different dimensions. All these dimensions are represented by PoolAttributes
38  * interface.
39  */

40 public interface Pool {
41
42     /**
43      * <b>getResource</b> is used to allocate a PoolResource from the Pool.
44      * Some hints are passed in order to specialise the matching or creation
45      * of PoolResource.
46      * @param hints Some properties to specialise the matching or the creation
47      * of PoolResource.
48      * @return The PoolResource allocated from the Pool.
49      */

50     Object JavaDoc getResource(Object JavaDoc hints) throws PoolException;
51
52     /**
53      * <b>getResource</b> is used to allocate a PoolResource from the Pool.
54      * Some hints are passed in order to specialise the matching or creation
55      * of PoolResource. The user parameter avoids dead lock by the use of a
56      * dependency graph.
57      * @param hints Some properties to specialise the matching or the creation
58      * of PoolResource.
59      * @param user is an identifier of the context wanting a resource in the
60      * pool.
61      * @return The PoolResource allocated from the Pool.
62      */

63     Object JavaDoc getResource(Object JavaDoc hints, Object JavaDoc user)
64             throws PoolException, DeadLockException;
65
66     /**
67      * <b>releaseResource</b> releases a PoolResource in order to allow the
68      * Pool to recycle this PoolResource.
69      * @param resource The PoolResource to be released.
70      */

71     void releaseResource(Object JavaDoc resource) throws PoolException;
72     
73     /**
74      * @return the number resource used and free
75      */

76     int getSize();
77     
78     /**
79      * @return the number of unsused resource
80      */

81     int getFreeResourceNumber();
82
83     /**
84      * @return the number of used resource
85      */

86     int getUsedResourceNumber();
87     
88     /**
89      * @return collection of user. The collection can be empty even if resource
90      * are used, in case of the user did not specify any reference on
91      * getResource.
92      */

93     Collection JavaDoc getUsers();
94
95
96 }
97
Popular Tags