KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > pool > Pool


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 //NOTE: Tabs are used instead of spaces for indentation.
25
// Make sure that your editor does not replace tabs with spaces.
26
// Set the tab length using your favourite editor to your
27
// visual preference.
28

29 /*
30  * Filename: Pool.java
31  *
32  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
33  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
34  * All rights reserved.
35  *
36  * This software is the confidential and proprietary information
37  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
38  * You shall not disclose such Confidential Information and shall
39  * use it only in accordance with the terms of the license
40  * agreement you entered into with iPlanet/Sun Microsystems.
41  */

42  
43 /**
44  * <BR> <I>$Source: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/util/pool/Pool.java,v $</I>
45  * @author $Author: tcfujii $
46  * @version $Revision: 1.3 $ $Date: 2005/12/25 04:12:27 $
47  */

48  
49 package com.sun.enterprise.util.pool;
50
51 /**
52  * Pool defines the methods that can be used by the application to access pooled objects. The basic
53  * assumption is that all objects in the pool are identical (homogeneous). This interface defines
54  * methods for a) getting an object from the pool, b) returning an object back to the pool
55  * and, c) destroying (instead of reusing) an object. In addition to these methods, the Pool has
56  * methods for adding and removing PoolEventListeners. There are six overloaded methods for
57  * getting objects from a pool.
58  */

59 public interface Pool {
60     
61     /**
62      * Get an object.
63      * @param toWait - true indicates that the calling thread agrees to wait indefinitely false if not.
64      * @param param - some value that might be used while creating the object
65      * @return an Object or null if an object could not be returned in 'waitForMillis' millisecond.
66      * @exception Throws InterruptedException if the calling thread was interrupted during the call.
67      * @exception Throws PoolException if the underlying pool implementation throws specific exception
68      * (for example, the pool is closed etc.)
69      */

70     public Object JavaDoc getObject(boolean toWait, Object JavaDoc param)
71         throws PoolException, InterruptedException JavaDoc;
72     
73     /**
74      * Get an object from the pool within the specified time.
75      * @param The amount of time the calling thread agrees to wait.
76      * @param Some value that might be used while creating the object
77      * @return an Object or null if an object could not be returned in 'waitForMillis' millisecond.
78      * @exception Throws InterruptedException if the calling thread was interrupted during the call.
79      * @exception Throws PoolException if the underlying pool implementation throws specific exception
80      * (for example, the pool is closed etc.)
81      */

82     public Object JavaDoc getObject(long waitForMillis, Object JavaDoc param)
83         throws PoolException, InterruptedException JavaDoc;
84
85    
86     /**
87      * Return an object back to the pool. An object that is obtained through
88      * getObject() must always be returned back to the pool using either
89      * returnObject(obj) or through destroyObject(obj).
90      */

91     public void returnObject(Object JavaDoc obj);
92                 
93     /**
94      * Destroys an Object. Note that applications should not ignore the reference
95      * to the object that they got from getObject(). An object that is obtained through
96      * getObject() must always be returned back to the pool using either
97      * returnObject(obj) or through destroyObject(obj). This method tells that the
98      * object should be destroyed and cannot be reused.
99      */

100     public void destroyObject(Object JavaDoc obj);
101         
102     /**
103     * Add a PoolListener
104     * @param listener The pool listener
105     */

106     public boolean addPoolListener(PoolListener listener);
107     
108     /**
109     * Add a PoolListener
110     * @param listener The pool listener
111     */

112     public boolean removePoolListener(PoolListener listener);
113     
114         
115     
116 }
117
Popular Tags