KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > resource > ConnectionManagerPoolParams


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@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  * $Id: ConnectionManagerPoolParams.java,v 1.1 2004/10/29 23:33:37 ehardesty Exp $
22  * --------------------------------------------------------------------------
23  */

24 package org.objectweb.jonas.resource;
25
26
27 /**
28  *
29  * @author Eric Hardesty
30  * Contributor(s):
31  *
32  */

33 public class ConnectionManagerPoolParams {
34
35     /**
36      * The number of seconds per minute
37      */

38     static final int SECS_PER_MIN = 60;
39     /**
40      * The default pstmts per ManagedConnection.
41      */

42     static final int INIT_PSTMT_SIZE = 10;
43     /**
44      * The default sampling time of the pool
45      */

46     static final int INIT_SAMPLING_TIME = 30;
47     /**
48      * Initial pool size
49      */

50     private int poolInit = 0;
51     /**
52      * Minimum pool size
53      */

54     private int poolMin = 0;
55     /**
56      * Maximum pool size, -1 unlimited
57      */

58     private int poolMax = -1;
59     /**
60      * Maximium pool age in seconds of a connection, 0 unlimited
61      */

62     private long poolMaxAge = 0L;
63     /**
64      * Maximium pool age in minutes of a connection, 0 unlimited
65      */

66     private int poolMaxAgeMinutes = 0;
67     /**
68      * Maximium open time in minutes of a connection, 0 unlimited
69      */

70     private int poolMaxOpentime = 0;
71     /**
72      * Maximum number of threads waiting for connection
73      */

74     private int poolMaxWaiters = 0;
75     /**
76      * Maximum time to wait for a connection
77      */

78     private int poolMaxWaittime = 0;
79     /**
80      * Pool statistics sampling period in seconds
81      */

82     private int poolSamplingPeriod = INIT_SAMPLING_TIME;
83     /**
84      * Maximum size of the PreparedStatement cache, -1 to disable
85      */

86     private int pstmtMax = INIT_PSTMT_SIZE;
87     /**
88      * Jdbc connection level
89      */

90     private int jdbcConnLevel = 0;
91     /**
92      * Jdbc sql string to send to a connection if level requires it
93      */

94     private String JavaDoc jdbcConnTestStmt = "";
95
96
97     /**
98      * Default Constructor
99      *
100      */

101     public ConnectionManagerPoolParams() {
102     }
103
104     /**
105      * Constructor to build new object based on another set of pool params
106      * @param cmpp ConnectionManagerPoolParams to initialize this object with
107      */

108     public ConnectionManagerPoolParams(ConnectionManagerPoolParams cmpp) {
109         poolInit = cmpp.getPoolInit();
110         poolMin = cmpp.getPoolMin();
111         poolMax = cmpp.getPoolMax();
112         poolMaxAge = cmpp.getPoolMaxAge();
113         poolMaxAgeMinutes = cmpp.getPoolMaxAgeMinutes();
114         poolMaxOpentime = cmpp.getPoolMaxOpentime();
115         poolMaxWaiters = cmpp.getPoolMaxWaiters();
116         poolMaxWaittime = cmpp.getPoolMaxWaittime();
117         poolSamplingPeriod = cmpp.getPoolSamplingPeriod();
118         pstmtMax = cmpp.getPstmtMax();
119         jdbcConnLevel = cmpp.getJdbcConnLevel();
120         jdbcConnTestStmt = cmpp.getJdbcConnTestStmt();
121     }
122     /**
123      * Return the pool init size
124      * @return int initial size of the pool
125      */

126     public int getPoolInit() {
127         return poolInit;
128     }
129     /**
130      * Set the pool init size
131      * @param val pool initial size
132      */

133     public void setPoolInit(int val) {
134         poolInit = val;
135     }
136
137     /**
138      * Return the pool min size
139      * @return int minimum size of the pool
140      */

141     public int getPoolMin() {
142         return poolMin;
143     }
144     /**
145      * Set the pool minimum size
146      * @param val pool minimum size
147      */

148     public void setPoolMin(int val) {
149         poolMin = val;
150     }
151
152     /**
153      * Return the pool maximum size
154      * @return int maximum size of the pool
155      */

156     public int getPoolMax() {
157         return poolMax;
158     }
159     /**
160      * Set the pool maximum size
161      * @param val pool maximum size
162      */

163     public void setPoolMax(int val) {
164         poolMax = val;
165     }
166
167     /**
168      * Return the pool maximum age in seconds
169      * @return long maximum age of a connection in the pool
170      */

171     public long getPoolMaxAge() {
172         return poolMaxAge;
173     }
174     /**
175      * Set the pool maximum age value
176      * @param val pool maximum age value
177      */

178     public void setPoolMaxAge(long val) {
179         poolMaxAge = val;
180     }
181
182     /**
183      * Return the pool maximum age in minutes
184      * @return int maximum age of a connection in the pool
185      */

186     public int getPoolMaxAgeMinutes() {
187         return poolMaxAgeMinutes;
188     }
189     /**
190      * Set the pool maximum age value
191      * @param val pool maximum age value
192      */

193     public void setPoolMaxAgeMinutes(int val) {
194         poolMaxAgeMinutes = val;
195     }
196
197     /**
198      * Return the pool maximum open time in minutes
199      * @return int maximum open time of a connection in the pool
200      */

201     public int getPoolMaxOpentime() {
202         return poolMaxOpentime;
203     }
204     /**
205      * Set the pool maximum open time value
206      * @param val pool maximum open time value
207      */

208     public void setPoolMaxOpentime(int val) {
209         poolMaxOpentime = val;
210     }
211
212     /**
213      * Return the pool maximum waiters size
214      * @return int maximum waiters of the pool
215      */

216     public int getPoolMaxWaiters() {
217         return poolMaxWaiters;
218     }
219     /**
220      * Set the pool maximum waiters size
221      * @param val pool maximum waiters size
222      */

223     public void setPoolMaxWaiters(int val) {
224         poolMaxWaiters = val;
225     }
226
227     /**
228      * Return the pool maximum waiter time
229      * @return int maximum waiter time of the pool
230      */

231     public int getPoolMaxWaittime() {
232         return poolMaxWaittime;
233     }
234     /**
235      * Set the pool maximum waiter time
236      * @param val pool maximum waiters time
237      */

238     public void setPoolMaxWaittime(int val) {
239         poolMaxWaittime = val;
240     }
241
242     /**
243      * Return the pool sampling period
244      * @return int pool sampling period
245      */

246     public int getPoolSamplingPeriod() {
247         return poolSamplingPeriod;
248     }
249     /**
250      * Set the pool sampling period
251      * @param val pool sampling period
252      */

253     public void setPoolSamplingPeriod(int val) {
254         poolSamplingPeriod = val;
255     }
256
257     /**
258      * Return the maximum PreparedStatement cache
259      * @return int maximum PreparedStatement cache
260      */

261     public int getPstmtMax() {
262         return pstmtMax;
263     }
264     /**
265      * Set the maximum PreparedStatement cache
266      * @param val maximum PreparedStatement cache
267      */

268     public void setPstmtMax(int val) {
269         pstmtMax = val;
270     }
271
272     /**
273      * Return the JDBC connection level
274      * @return int JDBC connection level
275      */

276     public int getJdbcConnLevel() {
277         return jdbcConnLevel;
278     }
279     /**
280      * Set the JDBC connection level
281      * @param val JDBC connection level
282      */

283     public void setJdbcConnLevel(int val) {
284         jdbcConnLevel = val;
285     }
286
287     /**
288      * Return the JDBC connection test SQL string
289      * @return String JDBC connection test SQL string
290      */

291     public String JavaDoc getJdbcConnTestStmt() {
292         return jdbcConnTestStmt;
293     }
294     /**
295      * Set the JDBC connection test SQL string
296      * @param val JDBC connection test SQL string
297      */

298     public void setJdbcConnTestStmt(String JavaDoc val) {
299         jdbcConnTestStmt = val;
300     }
301
302     /**
303      * Output pool information
304      * @return String representing the pool
305      */

306     public String JavaDoc toString() {
307         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
308         sb.append("poolInit=");
309         sb.append(poolInit);
310         sb.append("\npoolMin=");
311         sb.append(poolMin);
312         sb.append("\npoolMax=");
313         sb.append(poolMax);
314         sb.append("\npoolMaxAge=");
315         sb.append(poolMaxAge);
316         sb.append("\npoolMaxAgeMinutes=");
317         sb.append(poolMaxAgeMinutes);
318         sb.append("\npoolMaxOpentime=");
319         sb.append(poolMaxOpentime);
320         sb.append("\npoolMaxWaiters=");
321         sb.append(poolMaxWaiters);
322         sb.append("\npoolMaxWaittime=");
323         sb.append(poolMaxWaittime);
324         sb.append("\npoolSamplingPeriod=");
325         sb.append(poolSamplingPeriod);
326         sb.append("\npstmtMax=");
327         sb.append(pstmtMax);
328         sb.append("\njdbcConnLevel=");
329         sb.append(jdbcConnLevel);
330         sb.append("\njdbcConnTestStmt=");
331         sb.append(jdbcConnTestStmt);
332         sb.append("\n");
333         return sb.toString();
334     }
335 }
336
Popular Tags