KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mchange > v2 > resourcepool > ResourcePool


1 /*
2  * Distributed as part of c3p0 v.0.9.1
3  *
4  * Copyright (C) 2005 Machinery For Change, Inc.
5  *
6  * Author: Steve Waldman <swaldman@mchange.com>
7  *
8  * This library is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1, as
10  * published by the Free Software Foundation.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this software; see the file LICENSE. If not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */

22
23
24 package com.mchange.v2.resourcepool;
25
26 import com.mchange.v1.util.ClosableResource;
27
28 public interface ResourcePool extends ClosableResource
29 {
30     // status in pool return values
31
final static int KNOWN_AND_AVAILABLE = 0;
32     final static int KNOWN_AND_CHECKED_OUT = 1;
33     final static int UNKNOWN_OR_PURGED = -1;
34
35     public Object JavaDoc checkoutResource()
36     throws ResourcePoolException, InterruptedException JavaDoc;
37
38     public Object JavaDoc checkoutResource( long timeout )
39     throws TimeoutException, ResourcePoolException, InterruptedException JavaDoc;
40
41     public void checkinResource( Object JavaDoc resc )
42     throws ResourcePoolException;
43
44     public void checkinAll()
45     throws ResourcePoolException;
46
47     public int statusInPool( Object JavaDoc resc )
48     throws ResourcePoolException;
49
50     /**
51      * Marks a resource as broken. If the resource is checked in,
52      * it will be destroyed immediately. Otherwise, it will be
53      * destroyed on checkin.
54      */

55     public void markBroken( Object JavaDoc resc )
56     throws ResourcePoolException;
57
58     public int getMinPoolSize()
59     throws ResourcePoolException;
60
61     public int getMaxPoolSize()
62     throws ResourcePoolException;
63
64     public int getPoolSize()
65     throws ResourcePoolException;
66
67     public void setPoolSize(int size)
68     throws ResourcePoolException;
69
70     public int getAvailableCount()
71     throws ResourcePoolException;
72
73     public int getExcludedCount()
74     throws ResourcePoolException;
75
76     public int getAwaitingCheckinCount()
77     throws ResourcePoolException;
78
79     public long getEffectiveExpirationEnforcementDelay()
80     throws ResourcePoolException;
81     
82     public long getStartTime()
83     throws ResourcePoolException;
84     
85     public long getUpTime()
86     throws ResourcePoolException;
87     
88     public long getNumFailedCheckins()
89     throws ResourcePoolException;
90
91     public long getNumFailedCheckouts()
92     throws ResourcePoolException;
93
94     public long getNumFailedIdleTests()
95     throws ResourcePoolException;
96     
97     public int getNumCheckoutWaiters()
98     throws ResourcePoolException;
99
100     public Throwable JavaDoc getLastAcquisitionFailure()
101     throws ResourcePoolException;
102
103     public Throwable JavaDoc getLastCheckinFailure()
104     throws ResourcePoolException;
105
106     public Throwable JavaDoc getLastCheckoutFailure()
107     throws ResourcePoolException;
108
109     public Throwable JavaDoc getLastIdleCheckFailure()
110     throws ResourcePoolException;
111     
112     public Throwable JavaDoc getLastResourceTestFailure()
113     throws ResourcePoolException;
114
115     
116
117     /**
118      * Discards all resources managed by the pool
119      * and reacquires new resources to populate the
120      * pool. Current checked out resources will still
121      * be valid, and should still be checked into the
122      * pool (so the pool can destroy them).
123      */

124     public void resetPool()
125     throws ResourcePoolException;
126
127     public void close()
128     throws ResourcePoolException;
129
130     public void close( boolean close_checked_out_resources )
131     throws ResourcePoolException;
132
133     public interface Manager
134     {
135     public Object JavaDoc acquireResource() throws Exception JavaDoc;
136     public void refurbishIdleResource(Object JavaDoc resc) throws Exception JavaDoc;
137     public void refurbishResourceOnCheckout(Object JavaDoc resc) throws Exception JavaDoc;
138     public void refurbishResourceOnCheckin(Object JavaDoc resc) throws Exception JavaDoc;
139     public void destroyResource(Object JavaDoc resc) throws Exception JavaDoc;
140     }
141 }
142
Popular Tags