001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: * --------------------------------------------------------------------------
021: * $Id: ConnectionManagerPoolParams.java 5699 2004-10-29 23:33:37Z ehardesty $
022: * --------------------------------------------------------------------------
023: */package org.objectweb.jonas.resource;
024:
025: /**
026: *
027: * @author Eric Hardesty
028: * Contributor(s):
029: *
030: */
031: public class ConnectionManagerPoolParams {
032:
033: /**
034: * The number of seconds per minute
035: */
036: static final int SECS_PER_MIN = 60;
037: /**
038: * The default pstmts per ManagedConnection.
039: */
040: static final int INIT_PSTMT_SIZE = 10;
041: /**
042: * The default sampling time of the pool
043: */
044: static final int INIT_SAMPLING_TIME = 30;
045: /**
046: * Initial pool size
047: */
048: private int poolInit = 0;
049: /**
050: * Minimum pool size
051: */
052: private int poolMin = 0;
053: /**
054: * Maximum pool size, -1 unlimited
055: */
056: private int poolMax = -1;
057: /**
058: * Maximium pool age in seconds of a connection, 0 unlimited
059: */
060: private long poolMaxAge = 0L;
061: /**
062: * Maximium pool age in minutes of a connection, 0 unlimited
063: */
064: private int poolMaxAgeMinutes = 0;
065: /**
066: * Maximium open time in minutes of a connection, 0 unlimited
067: */
068: private int poolMaxOpentime = 0;
069: /**
070: * Maximum number of threads waiting for connection
071: */
072: private int poolMaxWaiters = 0;
073: /**
074: * Maximum time to wait for a connection
075: */
076: private int poolMaxWaittime = 0;
077: /**
078: * Pool statistics sampling period in seconds
079: */
080: private int poolSamplingPeriod = INIT_SAMPLING_TIME;
081: /**
082: * Maximum size of the PreparedStatement cache, -1 to disable
083: */
084: private int pstmtMax = INIT_PSTMT_SIZE;
085: /**
086: * Jdbc connection level
087: */
088: private int jdbcConnLevel = 0;
089: /**
090: * Jdbc sql string to send to a connection if level requires it
091: */
092: private String jdbcConnTestStmt = "";
093:
094: /**
095: * Default Constructor
096: *
097: */
098: public ConnectionManagerPoolParams() {
099: }
100:
101: /**
102: * Constructor to build new object based on another set of pool params
103: * @param cmpp ConnectionManagerPoolParams to initialize this object with
104: */
105: public ConnectionManagerPoolParams(ConnectionManagerPoolParams cmpp) {
106: poolInit = cmpp.getPoolInit();
107: poolMin = cmpp.getPoolMin();
108: poolMax = cmpp.getPoolMax();
109: poolMaxAge = cmpp.getPoolMaxAge();
110: poolMaxAgeMinutes = cmpp.getPoolMaxAgeMinutes();
111: poolMaxOpentime = cmpp.getPoolMaxOpentime();
112: poolMaxWaiters = cmpp.getPoolMaxWaiters();
113: poolMaxWaittime = cmpp.getPoolMaxWaittime();
114: poolSamplingPeriod = cmpp.getPoolSamplingPeriod();
115: pstmtMax = cmpp.getPstmtMax();
116: jdbcConnLevel = cmpp.getJdbcConnLevel();
117: jdbcConnTestStmt = cmpp.getJdbcConnTestStmt();
118: }
119:
120: /**
121: * Return the pool init size
122: * @return int initial size of the pool
123: */
124: public int getPoolInit() {
125: return poolInit;
126: }
127:
128: /**
129: * Set the pool init size
130: * @param val pool initial size
131: */
132: public void setPoolInit(int val) {
133: poolInit = val;
134: }
135:
136: /**
137: * Return the pool min size
138: * @return int minimum size of the pool
139: */
140: public int getPoolMin() {
141: return poolMin;
142: }
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: /**
161: * Set the pool maximum size
162: * @param val pool maximum size
163: */
164: public void setPoolMax(int val) {
165: poolMax = val;
166: }
167:
168: /**
169: * Return the pool maximum age in seconds
170: * @return long maximum age of a connection in the pool
171: */
172: public long getPoolMaxAge() {
173: return poolMaxAge;
174: }
175:
176: /**
177: * Set the pool maximum age value
178: * @param val pool maximum age value
179: */
180: public void setPoolMaxAge(long val) {
181: poolMaxAge = val;
182: }
183:
184: /**
185: * Return the pool maximum age in minutes
186: * @return int maximum age of a connection in the pool
187: */
188: public int getPoolMaxAgeMinutes() {
189: return poolMaxAgeMinutes;
190: }
191:
192: /**
193: * Set the pool maximum age value
194: * @param val pool maximum age value
195: */
196: public void setPoolMaxAgeMinutes(int val) {
197: poolMaxAgeMinutes = val;
198: }
199:
200: /**
201: * Return the pool maximum open time in minutes
202: * @return int maximum open time of a connection in the pool
203: */
204: public int getPoolMaxOpentime() {
205: return poolMaxOpentime;
206: }
207:
208: /**
209: * Set the pool maximum open time value
210: * @param val pool maximum open time value
211: */
212: public void setPoolMaxOpentime(int val) {
213: poolMaxOpentime = val;
214: }
215:
216: /**
217: * Return the pool maximum waiters size
218: * @return int maximum waiters of the pool
219: */
220: public int getPoolMaxWaiters() {
221: return poolMaxWaiters;
222: }
223:
224: /**
225: * Set the pool maximum waiters size
226: * @param val pool maximum waiters size
227: */
228: public void setPoolMaxWaiters(int val) {
229: poolMaxWaiters = val;
230: }
231:
232: /**
233: * Return the pool maximum waiter time
234: * @return int maximum waiter time of the pool
235: */
236: public int getPoolMaxWaittime() {
237: return poolMaxWaittime;
238: }
239:
240: /**
241: * Set the pool maximum waiter time
242: * @param val pool maximum waiters time
243: */
244: public void setPoolMaxWaittime(int val) {
245: poolMaxWaittime = val;
246: }
247:
248: /**
249: * Return the pool sampling period
250: * @return int pool sampling period
251: */
252: public int getPoolSamplingPeriod() {
253: return poolSamplingPeriod;
254: }
255:
256: /**
257: * Set the pool sampling period
258: * @param val pool sampling period
259: */
260: public void setPoolSamplingPeriod(int val) {
261: poolSamplingPeriod = val;
262: }
263:
264: /**
265: * Return the maximum PreparedStatement cache
266: * @return int maximum PreparedStatement cache
267: */
268: public int getPstmtMax() {
269: return pstmtMax;
270: }
271:
272: /**
273: * Set the maximum PreparedStatement cache
274: * @param val maximum PreparedStatement cache
275: */
276: public void setPstmtMax(int val) {
277: pstmtMax = val;
278: }
279:
280: /**
281: * Return the JDBC connection level
282: * @return int JDBC connection level
283: */
284: public int getJdbcConnLevel() {
285: return jdbcConnLevel;
286: }
287:
288: /**
289: * Set the JDBC connection level
290: * @param val JDBC connection level
291: */
292: public void setJdbcConnLevel(int val) {
293: jdbcConnLevel = val;
294: }
295:
296: /**
297: * Return the JDBC connection test SQL string
298: * @return String JDBC connection test SQL string
299: */
300: public String getJdbcConnTestStmt() {
301: return jdbcConnTestStmt;
302: }
303:
304: /**
305: * Set the JDBC connection test SQL string
306: * @param val JDBC connection test SQL string
307: */
308: public void setJdbcConnTestStmt(String val) {
309: jdbcConnTestStmt = val;
310: }
311:
312: /**
313: * Output pool information
314: * @return String representing the pool
315: */
316: public String toString() {
317: StringBuffer sb = new StringBuffer();
318: sb.append("poolInit=");
319: sb.append(poolInit);
320: sb.append("\npoolMin=");
321: sb.append(poolMin);
322: sb.append("\npoolMax=");
323: sb.append(poolMax);
324: sb.append("\npoolMaxAge=");
325: sb.append(poolMaxAge);
326: sb.append("\npoolMaxAgeMinutes=");
327: sb.append(poolMaxAgeMinutes);
328: sb.append("\npoolMaxOpentime=");
329: sb.append(poolMaxOpentime);
330: sb.append("\npoolMaxWaiters=");
331: sb.append(poolMaxWaiters);
332: sb.append("\npoolMaxWaittime=");
333: sb.append(poolMaxWaittime);
334: sb.append("\npoolSamplingPeriod=");
335: sb.append(poolSamplingPeriod);
336: sb.append("\npstmtMax=");
337: sb.append(pstmtMax);
338: sb.append("\njdbcConnLevel=");
339: sb.append(jdbcConnLevel);
340: sb.append("\njdbcConnTestStmt=");
341: sb.append(jdbcConnTestStmt);
342: sb.append("\n");
343: return sb.toString();
344: }
345: }
|