KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
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.1 of the License, or 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
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Pool.java 940 2006-07-26 09:05:27Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.api.pool;
27
28
29 /**
30  * Defines a common pool interface used to manage objects.
31  * @param <InstanceType> the type of the object that are managed by the pool
32  * (could be EasyBeansSLSB, etc.)
33  * @param <Clue> a clue to retrieve a specific instance in the pool
34  * @author Florent Benoit
35  */

36 public interface Pool<InstanceType, Clue> extends PoolAttributes {
37
38     /**
39      * Gets an object from the pool.
40      * @return an instance of an object with type Type.
41      * @throws PoolException if instance cannot be returned.
42      */

43     InstanceType get() throws PoolException;
44
45     /**
46      * Gets an object by using a specific hint.
47      * @param clue attribute used to retrieve a given instance
48      * @return a specific instance of the resource.
49      * @throws PoolException if instance cannot be returned.
50      */

51     InstanceType get(Clue clue) throws PoolException;
52
53     /**
54      * Puts back the instance in the pool so it can be reused.
55      * @param instance which will be put back in the pool.
56      * @throws PoolException if instance is not released.
57      */

58     void release(InstanceType instance) throws PoolException;
59
60     /**
61      * Discard the instance which is in the pool.
62      * @param instance which will be discarded.
63      * @throws PoolException if instance is not discarded.
64      */

65     void discard(InstanceType instance) throws PoolException;
66
67     /**
68      * Start the pool.<br>
69      * It could create initial instances if specified.
70      * @throws PoolException if initialization fails
71      */

72     void start() throws PoolException;
73
74     /**
75      * Stop this pool.
76      * @throws PoolException if destroy fails
77      */

78     void stop() throws PoolException;
79 }
80
Popular Tags