KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > logicalcobwebs > proxool > ConnectionPoolDefinition


1 /*
2  * This software is released under a licence similar to the Apache Software Licence.
3  * See org.logicalcobwebs.proxool.package.html for details.
4  * The latest version is available at http://proxool.sourceforge.net
5  */

6 package org.logicalcobwebs.proxool;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import java.sql.Driver JavaDoc;
12 import java.sql.DriverManager JavaDoc;
13 import java.sql.SQLException JavaDoc;
14 import java.util.HashSet JavaDoc;
15 import java.util.Iterator JavaDoc;
16 import java.util.Properties JavaDoc;
17 import java.util.Set JavaDoc;
18 import java.util.StringTokenizer JavaDoc;
19 import java.lang.reflect.Modifier JavaDoc;
20
21 /**
22  * This defines a connection pool: the URL to connect to the database, the
23  * delegate driver to use, and how the pool behaves.
24  * @version $Revision: 1.34 $, $Date: 2006/01/18 14:40:01 $
25  * @author billhorsman
26  * @author $Author: billhorsman $ (current maintainer)
27  */

28 class ConnectionPoolDefinition implements ConnectionPoolDefinitionIF {
29
30     // TODO Should we check for defintion reads whilst updating?
31

32     private static final Log LOG = LogFactory.getLog(ConnectionPoolDefinition.class);
33
34     /**
35      * This log has a category based on the alias
36      */

37     private Log poolLog = LOG;;
38
39     private String JavaDoc alias;
40
41     // JNDI properties
42

43     private String JavaDoc jndiName;
44
45     private String JavaDoc initialContextFactory;
46
47     private String JavaDoc providerUrl;
48
49     private String JavaDoc securityAuthentication;
50
51     private String JavaDoc securityPrincipal;
52
53     private String JavaDoc securityCredentials;
54
55     private Properties JavaDoc delegateProperties = new Properties JavaDoc();
56
57     private Properties JavaDoc completeInfo = new Properties JavaDoc();
58
59     private Properties JavaDoc changedInfo = new Properties JavaDoc();
60
61     /**
62      * Whether any of the properties that effect an individual
63      * connection have changed. If they have, we need to kill
64      * all the existing connections.
65      */

66     private boolean connectionPropertiesChanged;
67
68     private String JavaDoc url;
69
70     private String JavaDoc completeUrl;
71
72     private String JavaDoc driver;
73
74     private int maximumConnectionLifetime;;
75
76     private int prototypeCount;
77
78     private int minimumConnectionCount;
79
80     private int maximumConnectionCount;
81
82     private int houseKeepingSleepTime;
83
84     private int simultaneousBuildThrottle;
85
86     private int recentlyStartedThreshold;
87
88     private int overloadWithoutRefusalLifetime;
89
90     private int maximumActiveTime;
91
92     private boolean verbose;
93
94     private boolean trace;
95
96     private String JavaDoc statistics;
97
98     private String JavaDoc statisticsLogLevel;
99
100     private Set JavaDoc fatalSqlExceptions = new HashSet JavaDoc();
101
102     /**
103      * A String of all the fatalSqlExceptions delimited by
104      * {@link ConnectionPoolDefinitionIF#FATAL_SQL_EXCEPTIONS_DELIMITER}
105      */

106     private String JavaDoc fatalSqlExceptionsAsString;
107
108     private String JavaDoc fatalSqlExceptionWrapper = null;
109
110     private String JavaDoc houseKeepingTestSql;
111
112     private boolean testBeforeUse;
113
114     private boolean testAfterUse;
115
116     private boolean jmx;
117
118     private String JavaDoc jmxAgentId;
119
120     private Class JavaDoc injectableConnectionInterface;
121
122     private Class JavaDoc injectableStatementInterface;
123
124     private Class JavaDoc injectablePreparedStatementInterface;
125
126     private Class JavaDoc injectableCallableStatementInterface;
127
128     /**
129      * So we can set the values one by one if we want
130      */

131     public ConnectionPoolDefinition() {
132     }
133
134     /**
135      * Construct a new definition
136      * @param url the url that defines this pool
137      * @param info additional properties (for Proxool and the delegate
138      * driver)
139      * @param explicitRegister set to true if we are registering a new pool explicitly, or false
140      * if it's just because we are serving a url that we haven't come across before
141      * @throws ProxoolException if anything goes wrong
142      */

143     protected ConnectionPoolDefinition(String JavaDoc url, Properties JavaDoc info, boolean explicitRegister) throws ProxoolException {
144         this.alias = ProxoolFacade.getAlias(url);
145         poolLog = LogFactory.getLog("org.logicalcobwebs.proxool." + alias);
146         reset();
147         doChange(url, info, false, !explicitRegister);
148     }
149
150     /**
151      * Update the definition. All existing properties are retained
152      * and only overwritten if included in the info parameter
153      * @param url the url that defines this pool
154      * @param info additional properties (for Proxool and the delegate
155      * driver)
156      * @throws ProxoolException if anything goes wrong
157      */

158     protected void update(String JavaDoc url, Properties JavaDoc info) throws ProxoolException {
159         changedInfo.clear();
160         connectionPropertiesChanged = false;
161         poolLog.debug("Updating definition");
162         doChange(url, info, false, false);
163         if (connectionPropertiesChanged) {
164             poolLog.info("Mercifully killing all current connections because of definition changes");
165             ProxoolFacade.killAllConnections(alias, "of definition changes", true);
166         }
167     }
168
169     /**
170      * Redefine the definition. All existing properties are reset to their
171      * default values
172      * @param url the url that defines this pool
173      * @param info additional properties (for Proxool and the delegate
174      * driver)
175      * @throws ProxoolException if anything goes wrong
176      */

177     protected void redefine(String JavaDoc url, Properties JavaDoc info) throws ProxoolException {
178         reset();
179         changedInfo.clear();
180         connectionPropertiesChanged = false;
181         poolLog.debug("Redefining definition");
182         doChange(url, info, false, false);
183
184         // Check for minimum information
185
if (getUrl() == null || getDriver() == null) {
186             throw new ProxoolException("The URL is not defined properly: " + getCompleteUrl());
187         }
188
189         if (connectionPropertiesChanged) {
190             LOG.info("Mercifully killing all current connections because of definition changes");
191             ProxoolFacade.killAllConnections(alias, "definition has changed", true);
192         }
193     }
194
195     private boolean doChange(String JavaDoc url, Properties JavaDoc info, boolean pretend, boolean implicitRegister) throws ProxoolException {
196
197         boolean changed = false;
198
199         try {
200             int endOfPrefix = url.indexOf(':');
201             int endOfDriver = url.indexOf(':', endOfPrefix + 1);
202
203             if (endOfPrefix > -1 && endOfDriver > -1) {
204                 final String JavaDoc driver = url.substring(endOfPrefix + 1, endOfDriver);
205                 if (isChanged(getDriver(), driver)) {
206                     changed = true;
207                     if (!pretend) {
208                         logChange(true, ProxoolConstants.DELEGATE_DRIVER_PROPERTY, driver);
209                         setDriver(driver);
210                     }
211                 }
212
213                 final String JavaDoc delegateUrl = url.substring(endOfDriver + 1);
214                 if (isChanged(getUrl(), delegateUrl)) {
215                     changed = true;
216                     if (!pretend) {
217                         logChange(true, ProxoolConstants.DELEGATE_URL_PROPERTY, delegateUrl);
218                         setUrl(delegateUrl);
219                     }
220                 }
221             } else {
222                 // Using alias. Nothing to do
223
}
224         } catch (IndexOutOfBoundsException JavaDoc e) {
225             LOG.error("Invalid URL: '" + url + "'", e);
226             throw new ProxoolException("Invalid URL: '" + url + "'");
227         }
228
229         if (!pretend) {
230             setCompleteUrl(url);
231         }
232
233         if (info != null) {
234             Iterator JavaDoc i = info.keySet().iterator();
235             while (i.hasNext()) {
236                 String JavaDoc key = (String JavaDoc) i.next();
237                 String JavaDoc value = info.getProperty(key);
238                 changed = changed | setAnyProperty(key, value, pretend);
239                 if (!pretend) {
240                     completeInfo.setProperty(key, value);
241                 }
242             }
243         }
244
245         if (!pretend) {
246             ProxoolFacade.definitionUpdated(getAlias(), this, completeInfo, changedInfo);
247         }
248
249         if ((getDriver() == null || getUrl() == null) && implicitRegister) {
250             throw new ProxoolException("Attempt to refer to a unregistered pool by its alias '" + getAlias() + "'");
251         }
252
253         return changed;
254     }
255
256     private void logChange(boolean proxoolProperty, String JavaDoc key, String JavaDoc value) {
257         if (poolLog.isDebugEnabled()) {
258             String JavaDoc displayValue = value;
259             if (key.toLowerCase().indexOf("password") > -1) {
260                 displayValue = "********";
261             }
262             poolLog.debug((proxoolProperty ? "Recognised proxool property: " : "Delegating property to driver: ") + key + "=" + displayValue);
263         }
264     }
265
266     private boolean setAnyProperty(String JavaDoc key, String JavaDoc value, boolean pretend) throws ProxoolException {
267         boolean proxoolProperty = true;
268         boolean changed = false;
269
270         // These groups of properties have been split off to make this method smaller
271
changed = changed || setHouseKeeperProperty(key, value, pretend);
272         changed = changed || setLoggingProperty(key, value, pretend);
273         changed = changed || setInjectableProperty(key, value, pretend);
274         changed = changed || setJndiProperty(key, value, pretend);
275
276         if (key.equals(ProxoolConstants.USER_PROPERTY)) {
277             proxoolProperty = false;
278             if (isChanged(getUser(), value)) {
279                 changed = true;
280                 if (!pretend) {
281                     setUser(value);
282                 }
283             }
284         } else if (key.equals(ProxoolConstants.PASSWORD_PROPERTY)) {
285             proxoolProperty = false;
286             if (isChanged(getPassword(), value)) {
287                 changed = true;
288                 if (!pretend) {
289                     setPassword(value);
290                 }
291             }
292         } else if (key.equals(ProxoolConstants.DELEGATE_DRIVER_PROPERTY)) {
293             if (isChanged(getDriver(), value)) {
294                 changed = true;
295                 if (!pretend) {
296                     setDriver(value);
297                 }
298             }
299         } else if (key.equals(ProxoolConstants.DELEGATE_URL_PROPERTY)) {
300             if (isChanged(getUrl(), value)) {
301                 changed = true;
302                 if (!pretend) {
303                     setUrl(value);
304                 }
305             }
306         } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY)) {
307             if (getMaximumConnectionCount() != getInt(key, value)) {
308                 changed = true;
309                 if (!pretend) {
310                     setMaximumConnectionCount(getInt(key, value));
311                 }
312             }
313         } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME_PROPERTY)) {
314             if (getMaximumConnectionLifetime() != getInt(key, value)) {
315                 changed = true;
316                 if (!pretend) {
317                     setMaximumConnectionLifetime(getInt(key, value));
318                 }
319             }
320         } else if (key.equals(ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY)) {
321             poolLog.warn("Use of " + ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY + " is deprecated. Use more descriptive " + ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY + " instead.");
322             if (getSimultaneousBuildThrottle() != getInt(key, value)) {
323                 changed = true;
324                 if (!pretend) {
325                     setSimultaneousBuildThrottle(getInt(key, value));
326                 }
327             }
328         } else if (key.equals(ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY)) {
329             if (getSimultaneousBuildThrottle() != getInt(key, value)) {
330                 changed = true;
331                 setSimultaneousBuildThrottle(getInt(key, value));
332             }
333         } else if (key.equals(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY)) {
334             if (getMinimumConnectionCount() != getInt(key, value)) {
335                 changed = true;
336                 if (!pretend) {
337                     setMinimumConnectionCount(getInt(key, value));
338                 }
339             }
340         } else if (key.equals(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY)) {
341             if (getPrototypeCount() != getInt(key, value)) {
342                 changed = true;
343                 if (!pretend) {
344                     setPrototypeCount(getInt(key, value));
345                 }
346             }
347         } else if (key.equals(ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY)) {
348             if (getRecentlyStartedThreshold() != getInt(key, value)) {
349                 changed = true;
350                 if (!pretend) {
351                     setRecentlyStartedThreshold(getInt(key, value));
352                 }
353             }
354         } else if (key.equals(ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY)) {
355             if (getOverloadWithoutRefusalLifetime() != getInt(key, value)) {
356                 changed = true;
357                 if (!pretend) {
358                     setOverloadWithoutRefusalLifetime(getInt(key, value));
359                 }
360             }
361         } else if (key.equals(ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY)) {
362             if (getMaximumActiveTime() != getInt(key, value)) {
363                 changed = true;
364                 if (!pretend) {
365                     setMaximumActiveTime(getInt(key, value));
366                 }
367             }
368         } else if (key.equals(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY)) {
369             if (isChanged(fatalSqlExceptionsAsString, value)) {
370                 changed = true;
371                 if (!pretend) {
372                     setFatalSqlExceptionsAsString(value.length() > 0 ? value : null);
373                 }
374             }
375         } else if (key.equals(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY)) {
376             if (isChanged(fatalSqlExceptionWrapper, value)) {
377                 changed = true;
378                 if (!pretend) {
379                     setFatalSqlExceptionWrapper(value.length() > 0 ? value : null);
380                 }
381             }
382         } else if (key.equals(ProxoolConstants.STATISTICS_PROPERTY)) {
383             if (isChanged(getStatistics(), value)) {
384                 changed = true;
385                 if (!pretend) {
386                     setStatistics(value.length() > 0 ? value : null);
387                 }
388             }
389         } else if (key.equals(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY)) {
390             if (isChanged(getStatisticsLogLevel(), value)) {
391                 changed = true;
392                 if (!pretend) {
393                     setStatisticsLogLevel(value.length() > 0 ? value : null);
394                 }
395             }
396         }
397
398         if (!key.startsWith(ProxoolConstants.PROPERTY_PREFIX)) {
399             if (isChanged(getDelegateProperty(key), value)) {
400                 changed = true;
401                 if (!pretend) {
402                     setDelegateProperty(key, value);
403                 }
404             }
405             proxoolProperty = false;
406         }
407
408         if (changed && !pretend) {
409             logChange(proxoolProperty, key, value);
410             changedInfo.setProperty(key, value);
411         }
412         return changed;
413     }
414
415     /**
416      * Subset of {@link #setAnyProperty} to avoid overly long method
417      * @see #setAnyProperty
418      */

419     private boolean setLoggingProperty(String JavaDoc key, String JavaDoc value, boolean pretend) {
420         boolean changed = false;
421         if (key.equals(ProxoolConstants.DEBUG_LEVEL_PROPERTY)) {
422             if (value != null && value.equals("1")) {
423                 poolLog.warn("Use of " + ProxoolConstants.DEBUG_LEVEL_PROPERTY + "=1 is deprecated. Use " + ProxoolConstants.VERBOSE_PROPERTY + "=true instead.");
424                 if (!isVerbose()) {
425                     changed = true;
426                     if (!pretend) {
427                         setVerbose(true);
428                     }
429                 }
430             } else {
431                 poolLog.warn("Use of " + ProxoolConstants.DEBUG_LEVEL_PROPERTY + "=0 is deprecated. Use " + ProxoolConstants.VERBOSE_PROPERTY + "=false instead.");
432                 if (isVerbose()) {
433                     changed = true;
434                     if (!pretend) {
435                         setVerbose(false);
436                     }
437                 }
438             }
439         } else if (key.equals(ProxoolConstants.VERBOSE_PROPERTY)) {
440             final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue();
441             if (isVerbose() != valueAsBoolean) {
442                 changed = true;
443                 if (!pretend) {
444                     setVerbose(valueAsBoolean);
445                 }
446             }
447         } else if (key.equals(ProxoolConstants.TRACE_PROPERTY)) {
448             final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue();
449             if (isTrace() != valueAsBoolean) {
450                 changed = true;
451                 if (!pretend) {
452                     setTrace(valueAsBoolean);
453                 }
454             }
455         }
456         return changed;
457     }
458
459     /**
460      * Subset of {@link #setAnyProperty} to avoid overly long method
461      * @see #setAnyProperty
462      */

463     private boolean setInjectableProperty(String JavaDoc key, String JavaDoc value, boolean pretend) {
464         boolean changed = false;
465         if (key.equals(ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY)) {
466             if (isChanged(getInjectableConnectionInterfaceName(), value)) {
467                 changed = true;
468                 if (!pretend) {
469                     setInjectableConnectionInterfaceName(value.length() > 0 ? value : null);
470                 }
471             }
472         } else if (key.equals(ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) {
473             if (isChanged(getInjectableStatementInterfaceName(), value)) {
474                 changed = true;
475                 if (!pretend) {
476                     setInjectableStatementInterfaceName(value.length() > 0 ? value : null);
477                 }
478             }
479         } else if (key.equals(ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY)) {
480             if (isChanged(getInjectablePreparedStatementInterfaceName(), value)) {
481                 changed = true;
482                 if (!pretend) {
483                     setInjectablePreparedStatementInterfaceName(value.length() > 0 ? value : null);
484                 }
485             }
486         } else if (key.equals(ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) {
487             if (isChanged(getInjectableCallableStatememtInterfaceName(), value)) {
488                 changed = true;
489                 if (!pretend) {
490                     setInjectableCallableStatementInterfaceName(value.length() > 0 ? value : null);
491                 }
492             }
493         }
494         return changed;
495     }
496
497     /**
498      * Subset of {@link #setAnyProperty} to avoid overly long method.
499      * @see #setAnyProperty
500      */

501     private boolean setHouseKeeperProperty(String JavaDoc key, String JavaDoc value, boolean pretend) throws ProxoolException {
502         boolean changed = false;
503         if (key.equals(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY)) {
504             if (getHouseKeepingSleepTime() != getInt(key, value)) {
505                 changed = true;
506                 if (!pretend) {
507                     setHouseKeepingSleepTime(getInt(key, value));
508                 }
509             }
510         } else if (key.equals(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY)) {
511             if (isChanged(getHouseKeepingTestSql(), value)) {
512                 changed = true;
513                 if (!pretend) {
514                     setHouseKeepingTestSql(value.length() > 0 ? value : null);
515                 }
516             }
517         } else if (key.equals(ProxoolConstants.TEST_BEFORE_USE_PROPERTY)) {
518             final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue();
519             if (isTestBeforeUse() != valueAsBoolean) {
520                 changed = true;
521                 if (!pretend) {
522                     setTestBeforeUse(valueAsBoolean);
523                 }
524             }
525         } else if (key.equals(ProxoolConstants.TEST_AFTER_USE_PROPERTY)) {
526             final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue();
527             if (isTestAfterUse() != valueAsBoolean) {
528                 changed = true;
529                 if (!pretend) {
530                     setTestAfterUse(valueAsBoolean);
531                 }
532             }
533         }
534         return changed;
535     }
536
537     /**
538      * Subset of {@link #setAnyProperty} to avoid overly long method
539      * @see #setAnyProperty
540      */

541     private boolean setJndiProperty(String JavaDoc key, String JavaDoc value, boolean pretend) {
542         boolean changed = false;
543         if (key.equals(ProxoolConstants.JNDI_NAME_PROPERTY)) {
544             if (isChanged(getJndiName(), value)) {
545                 changed = true;
546                 if (!pretend) {
547                     setJndiName(value.length() > 0 ? value : null);
548                 }
549             }
550         } else {
551
552         }
553         return changed;
554     }
555     private int getInt(String JavaDoc key, String JavaDoc value) throws ProxoolException {
556         try {
557             return Integer.parseInt(value);
558         } catch (NumberFormatException JavaDoc e) {
559             throw new ProxoolException("'" + key + "' property must be an integer. Found '" + value + "' instead.");
560         }
561     }
562
563     private static boolean isChanged(String JavaDoc oldValue, String JavaDoc newValue) {
564         boolean changed = false;
565         if (oldValue == null) {
566             if (newValue != null) {
567                 changed = true;
568             }
569         } else if (newValue == null) {
570             changed = true;
571         } else if (!oldValue.equals(newValue)) {
572             changed = true;
573         }
574         return changed;
575     }
576
577     /**
578      * Deep clone of definition
579      * @return the new definition
580      * @throws CloneNotSupportedException
581      */

582     protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
583         ConnectionPoolDefinition clone = new ConnectionPoolDefinition();
584
585         clone.setCompleteUrl(completeUrl);
586         clone.setDelegateProperties((Properties JavaDoc) delegateProperties.clone());
587         clone.setCompleteInfo((Properties JavaDoc) completeInfo.clone());
588         clone.clearChangedInfo();
589
590         clone.setAlias(alias);
591         clone.setUrl(url);
592         clone.setDriver(driver);
593         clone.setMaximumConnectionLifetime(maximumConnectionLifetime);
594         clone.setPrototypeCount(prototypeCount);
595         clone.setMinimumConnectionCount(minimumConnectionCount);
596         clone.setMaximumConnectionCount(maximumConnectionCount);
597         clone.setHouseKeepingSleepTime(houseKeepingSleepTime);
598         clone.setHouseKeepingTestSql(houseKeepingTestSql);
599         clone.setTestAfterUse(testAfterUse);
600         clone.setTestBeforeUse(testBeforeUse);
601         clone.setSimultaneousBuildThrottle(simultaneousBuildThrottle);
602         clone.setRecentlyStartedThreshold(recentlyStartedThreshold);
603         clone.setOverloadWithoutRefusalLifetime(overloadWithoutRefusalLifetime);
604         clone.setMaximumActiveTime(maximumActiveTime);
605         clone.setVerbose(verbose);
606         clone.setTrace(trace);
607         clone.setStatistics(statistics);
608         clone.setStatisticsLogLevel(statisticsLogLevel);
609         clone.setFatalSqlExceptionsAsString(fatalSqlExceptionsAsString);
610         try {
611             clone.setFatalSqlExceptionWrapper(fatalSqlExceptionWrapper);
612         } catch (ProxoolException e) {
613             throw new IllegalArgumentException JavaDoc("Problem cloning fatalSqlExceptionWrapper: " + fatalSqlExceptionWrapper);
614         }
615         return clone;
616     }
617
618     private void clearChangedInfo() {
619         changedInfo.clear();
620     }
621
622     /**
623      * Reset all properties to their default values
624      */

625     private void reset() {
626         completeUrl = null;
627         delegateProperties.clear();
628         completeInfo.clear();
629         changedInfo.clear();
630
631         url = null;
632         driver = null;
633         maximumConnectionLifetime = DEFAULT_MAXIMUM_CONNECTION_LIFETIME;
634         prototypeCount = DEFAULT_PROTOTYPE_COUNT;
635         minimumConnectionCount = DEFAULT_MINIMUM_CONNECTION_COUNT;
636         maximumConnectionCount = DEFAULT_MAXIMUM_CONNECTION_COUNT;
637         houseKeepingSleepTime = DEFAULT_HOUSE_KEEPING_SLEEP_TIME;
638         houseKeepingTestSql = null;
639         testAfterUse = false;
640         testBeforeUse = false;
641         simultaneousBuildThrottle = DEFAULT_SIMULTANEOUS_BUILD_THROTTLE;
642         recentlyStartedThreshold = DEFAULT_RECENTLY_STARTED_THRESHOLD;
643         overloadWithoutRefusalLifetime = DEFAULT_OVERLOAD_WITHOUT_REFUSAL_THRESHOLD;
644         maximumActiveTime = DEFAULT_MAXIMUM_ACTIVE_TIME;
645         verbose = false;
646         trace = false;
647         statistics = null;
648         statisticsLogLevel = null;
649         fatalSqlExceptions.clear();
650         fatalSqlExceptionWrapper = null;
651     }
652
653     /**
654      * Get all the properties used to define this pool
655      * @return
656      */

657     protected Properties JavaDoc getCompleteInfo() {
658         return completeInfo;
659     }
660
661     /**
662      * Overwrite the complete info
663      * @param completeInfo the new properties
664      * @see #getCompleteInfo()
665      */

666     public void setCompleteInfo(Properties JavaDoc completeInfo) {
667         this.completeInfo = completeInfo;
668     }
669
670     /**
671      * @see ConnectionPoolDefinitionIF#getUser
672      */

673     public String JavaDoc getUser() {
674         return getDelegateProperty(USER_PROPERTY);
675     }
676
677     /**
678      * @see ConnectionPoolDefinitionIF#getUser
679      */

680     public void setUser(String JavaDoc user) {
681         setDelegateProperty(USER_PROPERTY, user);
682     }
683
684     /**
685      * @see ConnectionPoolDefinitionIF#getPassword
686      */

687     public String JavaDoc getPassword() {
688         return getDelegateProperty(PASSWORD_PROPERTY);
689     }
690
691     /**
692      * @see ConnectionPoolDefinitionIF#getPassword
693      */

694     public void setPassword(String JavaDoc password) {
695         setDelegateProperty(PASSWORD_PROPERTY, password);
696     }
697
698     /**
699      * @see ConnectionPoolDefinitionIF#getJdbcDriverVersion
700      */

701     public String JavaDoc getJdbcDriverVersion() {
702
703         try {
704             Driver JavaDoc driver = DriverManager.getDriver(getUrl());
705             return driver.getMajorVersion() + "." + driver.getMinorVersion();
706         } catch (SQLException JavaDoc e) {
707             return "Trying to locate driver version for '" + getUrl() + "' caused: " + e.toString();
708         } catch (NullPointerException JavaDoc e) {
709             return "Couldn't locate driver for '" + getUrl() + "'!";
710         }
711
712     }
713
714     /**
715      * @see Object#toString
716      */

717     public String JavaDoc toString() {
718         return getCompleteUrl();
719     }
720
721     /**
722      * @see ConnectionPoolDefinitionIF#getName
723      * @deprecated use {@link #getAlias}
724      */

725     public String JavaDoc getName() {
726         return alias;
727     }
728
729     /**
730      * @see ConnectionPoolDefinitionIF#getAlias
731      */

732     public String JavaDoc getAlias() {
733         return alias;
734     }
735
736     /**
737      * @see ConnectionPoolDefinitionIF#getAlias
738      */

739     public void setAlias(String JavaDoc alias) {
740         this.alias = alias;
741     }
742
743     /**
744      * @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
745      */

746     public int getMaximumConnectionLifetime() {
747         return maximumConnectionLifetime;
748     }
749
750     /**
751      * @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
752      */

753     public void setMaximumConnectionLifetime(int maximumConnectionLifetime) {
754         this.maximumConnectionLifetime = maximumConnectionLifetime;
755     }
756
757     /**
758      * @see ConnectionPoolDefinitionIF#getPrototypeCount
759      */

760     public int getPrototypeCount() {
761         return prototypeCount;
762     }
763
764     /**
765      * @see ConnectionPoolDefinitionIF#getPrototypeCount
766      */

767     public void setPrototypeCount(int prototypeCount) {
768         this.prototypeCount = prototypeCount;
769     }
770
771     /**
772      * @see ConnectionPoolDefinitionIF#getMinimumConnectionCount
773      */

774     public int getMinimumConnectionCount() {
775         return minimumConnectionCount;
776     }
777
778     /**
779      * @see ConnectionPoolDefinitionIF#getMinimumConnectionCount
780      */

781     public void setMinimumConnectionCount(int minimumConnectionCount) {
782         this.minimumConnectionCount = minimumConnectionCount;
783     }
784
785     /**
786      * @see ConnectionPoolDefinitionIF#getMaximumConnectionCount
787      */

788     public int getMaximumConnectionCount() {
789         return maximumConnectionCount;
790     }
791
792     /**
793      * @see ConnectionPoolDefinitionIF#getMaximumConnectionCount
794      */

795     public void setMaximumConnectionCount(int maximumConnectionCount) {
796         this.maximumConnectionCount = maximumConnectionCount;
797     }
798
799     /**
800      * @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
801      */

802     public int getHouseKeepingSleepTime() {
803         return houseKeepingSleepTime;
804     }
805
806     /**
807      * @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
808      */

809     public void setHouseKeepingSleepTime(int houseKeepingSleepTime) {
810         this.houseKeepingSleepTime = houseKeepingSleepTime;
811     }
812
813     /**
814      * @see ConnectionPoolDefinitionIF#