0001: /*
0002: * This software is released under a licence similar to the Apache Software Licence.
0003: * See org.logicalcobwebs.proxool.package.html for details.
0004: * The latest version is available at http://proxool.sourceforge.net
0005: */
0006: package org.logicalcobwebs.proxool;
0007:
0008: import org.apache.commons.logging.Log;
0009: import org.apache.commons.logging.LogFactory;
0010:
0011: import java.sql.Driver;
0012: import java.sql.DriverManager;
0013: import java.sql.SQLException;
0014: import java.util.HashSet;
0015: import java.util.Iterator;
0016: import java.util.Properties;
0017: import java.util.Set;
0018: import java.util.StringTokenizer;
0019: import java.lang.reflect.Modifier;
0020:
0021: /**
0022: * This defines a connection pool: the URL to connect to the database, the
0023: * delegate driver to use, and how the pool behaves.
0024: * @version $Revision: 1.34 $, $Date: 2006/01/18 14:40:01 $
0025: * @author billhorsman
0026: * @author $Author: billhorsman $ (current maintainer)
0027: */
0028: class ConnectionPoolDefinition implements ConnectionPoolDefinitionIF {
0029:
0030: // TODO Should we check for defintion reads whilst updating?
0031:
0032: private static final Log LOG = LogFactory
0033: .getLog(ConnectionPoolDefinition.class);
0034:
0035: /**
0036: * This log has a category based on the alias
0037: */
0038: private Log poolLog = LOG;;
0039:
0040: private String alias;
0041:
0042: // JNDI properties
0043:
0044: private String jndiName;
0045:
0046: private String initialContextFactory;
0047:
0048: private String providerUrl;
0049:
0050: private String securityAuthentication;
0051:
0052: private String securityPrincipal;
0053:
0054: private String securityCredentials;
0055:
0056: private Properties delegateProperties = new Properties();
0057:
0058: private Properties completeInfo = new Properties();
0059:
0060: private Properties changedInfo = new Properties();
0061:
0062: /**
0063: * Whether any of the properties that effect an individual
0064: * connection have changed. If they have, we need to kill
0065: * all the existing connections.
0066: */
0067: private boolean connectionPropertiesChanged;
0068:
0069: private String url;
0070:
0071: private String completeUrl;
0072:
0073: private String driver;
0074:
0075: private int maximumConnectionLifetime;;
0076:
0077: private int prototypeCount;
0078:
0079: private int minimumConnectionCount;
0080:
0081: private int maximumConnectionCount;
0082:
0083: private int houseKeepingSleepTime;
0084:
0085: private int simultaneousBuildThrottle;
0086:
0087: private int recentlyStartedThreshold;
0088:
0089: private int overloadWithoutRefusalLifetime;
0090:
0091: private int maximumActiveTime;
0092:
0093: private boolean verbose;
0094:
0095: private boolean trace;
0096:
0097: private String statistics;
0098:
0099: private String statisticsLogLevel;
0100:
0101: private Set fatalSqlExceptions = new HashSet();
0102:
0103: /**
0104: * A String of all the fatalSqlExceptions delimited by
0105: * {@link ConnectionPoolDefinitionIF#FATAL_SQL_EXCEPTIONS_DELIMITER}
0106: */
0107: private String fatalSqlExceptionsAsString;
0108:
0109: private String fatalSqlExceptionWrapper = null;
0110:
0111: private String houseKeepingTestSql;
0112:
0113: private boolean testBeforeUse;
0114:
0115: private boolean testAfterUse;
0116:
0117: private boolean jmx;
0118:
0119: private String jmxAgentId;
0120:
0121: private Class injectableConnectionInterface;
0122:
0123: private Class injectableStatementInterface;
0124:
0125: private Class injectablePreparedStatementInterface;
0126:
0127: private Class injectableCallableStatementInterface;
0128:
0129: /**
0130: * So we can set the values one by one if we want
0131: */
0132: public ConnectionPoolDefinition() {
0133: }
0134:
0135: /**
0136: * Construct a new definition
0137: * @param url the url that defines this pool
0138: * @param info additional properties (for Proxool and the delegate
0139: * driver)
0140: * @param explicitRegister set to true if we are registering a new pool explicitly, or false
0141: * if it's just because we are serving a url that we haven't come across before
0142: * @throws ProxoolException if anything goes wrong
0143: */
0144: protected ConnectionPoolDefinition(String url, Properties info,
0145: boolean explicitRegister) throws ProxoolException {
0146: this .alias = ProxoolFacade.getAlias(url);
0147: poolLog = LogFactory.getLog("org.logicalcobwebs.proxool."
0148: + alias);
0149: reset();
0150: doChange(url, info, false, !explicitRegister);
0151: }
0152:
0153: /**
0154: * Update the definition. All existing properties are retained
0155: * and only overwritten if included in the info parameter
0156: * @param url the url that defines this pool
0157: * @param info additional properties (for Proxool and the delegate
0158: * driver)
0159: * @throws ProxoolException if anything goes wrong
0160: */
0161: protected void update(String url, Properties info)
0162: throws ProxoolException {
0163: changedInfo.clear();
0164: connectionPropertiesChanged = false;
0165: poolLog.debug("Updating definition");
0166: doChange(url, info, false, false);
0167: if (connectionPropertiesChanged) {
0168: poolLog
0169: .info("Mercifully killing all current connections because of definition changes");
0170: ProxoolFacade.killAllConnections(alias,
0171: "of definition changes", true);
0172: }
0173: }
0174:
0175: /**
0176: * Redefine the definition. All existing properties are reset to their
0177: * default values
0178: * @param url the url that defines this pool
0179: * @param info additional properties (for Proxool and the delegate
0180: * driver)
0181: * @throws ProxoolException if anything goes wrong
0182: */
0183: protected void redefine(String url, Properties info)
0184: throws ProxoolException {
0185: reset();
0186: changedInfo.clear();
0187: connectionPropertiesChanged = false;
0188: poolLog.debug("Redefining definition");
0189: doChange(url, info, false, false);
0190:
0191: // Check for minimum information
0192: if (getUrl() == null || getDriver() == null) {
0193: throw new ProxoolException(
0194: "The URL is not defined properly: "
0195: + getCompleteUrl());
0196: }
0197:
0198: if (connectionPropertiesChanged) {
0199: LOG
0200: .info("Mercifully killing all current connections because of definition changes");
0201: ProxoolFacade.killAllConnections(alias,
0202: "definition has changed", true);
0203: }
0204: }
0205:
0206: private boolean doChange(String url, Properties info,
0207: boolean pretend, boolean implicitRegister)
0208: throws ProxoolException {
0209:
0210: boolean changed = false;
0211:
0212: try {
0213: int endOfPrefix = url.indexOf(':');
0214: int endOfDriver = url.indexOf(':', endOfPrefix + 1);
0215:
0216: if (endOfPrefix > -1 && endOfDriver > -1) {
0217: final String driver = url.substring(endOfPrefix + 1,
0218: endOfDriver);
0219: if (isChanged(getDriver(), driver)) {
0220: changed = true;
0221: if (!pretend) {
0222: logChange(
0223: true,
0224: ProxoolConstants.DELEGATE_DRIVER_PROPERTY,
0225: driver);
0226: setDriver(driver);
0227: }
0228: }
0229:
0230: final String delegateUrl = url
0231: .substring(endOfDriver + 1);
0232: if (isChanged(getUrl(), delegateUrl)) {
0233: changed = true;
0234: if (!pretend) {
0235: logChange(true,
0236: ProxoolConstants.DELEGATE_URL_PROPERTY,
0237: delegateUrl);
0238: setUrl(delegateUrl);
0239: }
0240: }
0241: } else {
0242: // Using alias. Nothing to do
0243: }
0244: } catch (IndexOutOfBoundsException e) {
0245: LOG.error("Invalid URL: '" + url + "'", e);
0246: throw new ProxoolException("Invalid URL: '" + url + "'");
0247: }
0248:
0249: if (!pretend) {
0250: setCompleteUrl(url);
0251: }
0252:
0253: if (info != null) {
0254: Iterator i = info.keySet().iterator();
0255: while (i.hasNext()) {
0256: String key = (String) i.next();
0257: String value = info.getProperty(key);
0258: changed = changed | setAnyProperty(key, value, pretend);
0259: if (!pretend) {
0260: completeInfo.setProperty(key, value);
0261: }
0262: }
0263: }
0264:
0265: if (!pretend) {
0266: ProxoolFacade.definitionUpdated(getAlias(), this ,
0267: completeInfo, changedInfo);
0268: }
0269:
0270: if ((getDriver() == null || getUrl() == null)
0271: && implicitRegister) {
0272: throw new ProxoolException(
0273: "Attempt to refer to a unregistered pool by its alias '"
0274: + getAlias() + "'");
0275: }
0276:
0277: return changed;
0278: }
0279:
0280: private void logChange(boolean proxoolProperty, String key,
0281: String value) {
0282: if (poolLog.isDebugEnabled()) {
0283: String displayValue = value;
0284: if (key.toLowerCase().indexOf("password") > -1) {
0285: displayValue = "********";
0286: }
0287: poolLog
0288: .debug((proxoolProperty ? "Recognised proxool property: "
0289: : "Delegating property to driver: ")
0290: + key + "=" + displayValue);
0291: }
0292: }
0293:
0294: private boolean setAnyProperty(String key, String value,
0295: boolean pretend) throws ProxoolException {
0296: boolean proxoolProperty = true;
0297: boolean changed = false;
0298:
0299: // These groups of properties have been split off to make this method smaller
0300: changed = changed
0301: || setHouseKeeperProperty(key, value, pretend);
0302: changed = changed || setLoggingProperty(key, value, pretend);
0303: changed = changed || setInjectableProperty(key, value, pretend);
0304: changed = changed || setJndiProperty(key, value, pretend);
0305:
0306: if (key.equals(ProxoolConstants.USER_PROPERTY)) {
0307: proxoolProperty = false;
0308: if (isChanged(getUser(), value)) {
0309: changed = true;
0310: if (!pretend) {
0311: setUser(value);
0312: }
0313: }
0314: } else if (key.equals(ProxoolConstants.PASSWORD_PROPERTY)) {
0315: proxoolProperty = false;
0316: if (isChanged(getPassword(), value)) {
0317: changed = true;
0318: if (!pretend) {
0319: setPassword(value);
0320: }
0321: }
0322: } else if (key
0323: .equals(ProxoolConstants.DELEGATE_DRIVER_PROPERTY)) {
0324: if (isChanged(getDriver(), value)) {
0325: changed = true;
0326: if (!pretend) {
0327: setDriver(value);
0328: }
0329: }
0330: } else if (key.equals(ProxoolConstants.DELEGATE_URL_PROPERTY)) {
0331: if (isChanged(getUrl(), value)) {
0332: changed = true;
0333: if (!pretend) {
0334: setUrl(value);
0335: }
0336: }
0337: } else if (key
0338: .equals(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY)) {
0339: if (getMaximumConnectionCount() != getInt(key, value)) {
0340: changed = true;
0341: if (!pretend) {
0342: setMaximumConnectionCount(getInt(key, value));
0343: }
0344: }
0345: } else if (key
0346: .equals(ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME_PROPERTY)) {
0347: if (getMaximumConnectionLifetime() != getInt(key, value)) {
0348: changed = true;
0349: if (!pretend) {
0350: setMaximumConnectionLifetime(getInt(key, value));
0351: }
0352: }
0353: } else if (key
0354: .equals(ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY)) {
0355: poolLog
0356: .warn("Use of "
0357: + ProxoolConstants.MAXIMUM_NEW_CONNECTIONS_PROPERTY
0358: + " is deprecated. Use more descriptive "
0359: + ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY
0360: + " instead.");
0361: if (getSimultaneousBuildThrottle() != getInt(key, value)) {
0362: changed = true;
0363: if (!pretend) {
0364: setSimultaneousBuildThrottle(getInt(key, value));
0365: }
0366: }
0367: } else if (key
0368: .equals(ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY)) {
0369: if (getSimultaneousBuildThrottle() != getInt(key, value)) {
0370: changed = true;
0371: setSimultaneousBuildThrottle(getInt(key, value));
0372: }
0373: } else if (key
0374: .equals(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY)) {
0375: if (getMinimumConnectionCount() != getInt(key, value)) {
0376: changed = true;
0377: if (!pretend) {
0378: setMinimumConnectionCount(getInt(key, value));
0379: }
0380: }
0381: } else if (key
0382: .equals(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY)) {
0383: if (getPrototypeCount() != getInt(key, value)) {
0384: changed = true;
0385: if (!pretend) {
0386: setPrototypeCount(getInt(key, value));
0387: }
0388: }
0389: } else if (key
0390: .equals(ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY)) {
0391: if (getRecentlyStartedThreshold() != getInt(key, value)) {
0392: changed = true;
0393: if (!pretend) {
0394: setRecentlyStartedThreshold(getInt(key, value));
0395: }
0396: }
0397: } else if (key
0398: .equals(ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY)) {
0399: if (getOverloadWithoutRefusalLifetime() != getInt(key,
0400: value)) {
0401: changed = true;
0402: if (!pretend) {
0403: setOverloadWithoutRefusalLifetime(getInt(key, value));
0404: }
0405: }
0406: } else if (key
0407: .equals(ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY)) {
0408: if (getMaximumActiveTime() != getInt(key, value)) {
0409: changed = true;
0410: if (!pretend) {
0411: setMaximumActiveTime(getInt(key, value));
0412: }
0413: }
0414: } else if (key
0415: .equals(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY)) {
0416: if (isChanged(fatalSqlExceptionsAsString, value)) {
0417: changed = true;
0418: if (!pretend) {
0419: setFatalSqlExceptionsAsString(value.length() > 0 ? value
0420: : null);
0421: }
0422: }
0423: } else if (key
0424: .equals(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY)) {
0425: if (isChanged(fatalSqlExceptionWrapper, value)) {
0426: changed = true;
0427: if (!pretend) {
0428: setFatalSqlExceptionWrapper(value.length() > 0 ? value
0429: : null);
0430: }
0431: }
0432: } else if (key.equals(ProxoolConstants.STATISTICS_PROPERTY)) {
0433: if (isChanged(getStatistics(), value)) {
0434: changed = true;
0435: if (!pretend) {
0436: setStatistics(value.length() > 0 ? value : null);
0437: }
0438: }
0439: } else if (key
0440: .equals(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY)) {
0441: if (isChanged(getStatisticsLogLevel(), value)) {
0442: changed = true;
0443: if (!pretend) {
0444: setStatisticsLogLevel(value.length() > 0 ? value
0445: : null);
0446: }
0447: }
0448: }
0449:
0450: if (!key.startsWith(ProxoolConstants.PROPERTY_PREFIX)) {
0451: if (isChanged(getDelegateProperty(key), value)) {
0452: changed = true;
0453: if (!pretend) {
0454: setDelegateProperty(key, value);
0455: }
0456: }
0457: proxoolProperty = false;
0458: }
0459:
0460: if (changed && !pretend) {
0461: logChange(proxoolProperty, key, value);
0462: changedInfo.setProperty(key, value);
0463: }
0464: return changed;
0465: }
0466:
0467: /**
0468: * Subset of {@link #setAnyProperty} to avoid overly long method
0469: * @see #setAnyProperty
0470: */
0471: private boolean setLoggingProperty(String key, String value,
0472: boolean pretend) {
0473: boolean changed = false;
0474: if (key.equals(ProxoolConstants.DEBUG_LEVEL_PROPERTY)) {
0475: if (value != null && value.equals("1")) {
0476: poolLog.warn("Use of "
0477: + ProxoolConstants.DEBUG_LEVEL_PROPERTY
0478: + "=1 is deprecated. Use "
0479: + ProxoolConstants.VERBOSE_PROPERTY
0480: + "=true instead.");
0481: if (!isVerbose()) {
0482: changed = true;
0483: if (!pretend) {
0484: setVerbose(true);
0485: }
0486: }
0487: } else {
0488: poolLog.warn("Use of "
0489: + ProxoolConstants.DEBUG_LEVEL_PROPERTY
0490: + "=0 is deprecated. Use "
0491: + ProxoolConstants.VERBOSE_PROPERTY
0492: + "=false instead.");
0493: if (isVerbose()) {
0494: changed = true;
0495: if (!pretend) {
0496: setVerbose(false);
0497: }
0498: }
0499: }
0500: } else if (key.equals(ProxoolConstants.VERBOSE_PROPERTY)) {
0501: final boolean valueAsBoolean = Boolean.valueOf(value)
0502: .booleanValue();
0503: if (isVerbose() != valueAsBoolean) {
0504: changed = true;
0505: if (!pretend) {
0506: setVerbose(valueAsBoolean);
0507: }
0508: }
0509: } else if (key.equals(ProxoolConstants.TRACE_PROPERTY)) {
0510: final boolean valueAsBoolean = Boolean.valueOf(value)
0511: .booleanValue();
0512: if (isTrace() != valueAsBoolean) {
0513: changed = true;
0514: if (!pretend) {
0515: setTrace(valueAsBoolean);
0516: }
0517: }
0518: }
0519: return changed;
0520: }
0521:
0522: /**
0523: * Subset of {@link #setAnyProperty} to avoid overly long method
0524: * @see #setAnyProperty
0525: */
0526: private boolean setInjectableProperty(String key, String value,
0527: boolean pretend) {
0528: boolean changed = false;
0529: if (key
0530: .equals(ProxoolConstants.INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY)) {
0531: if (isChanged(getInjectableConnectionInterfaceName(), value)) {
0532: changed = true;
0533: if (!pretend) {
0534: setInjectableConnectionInterfaceName(value.length() > 0 ? value
0535: : null);
0536: }
0537: }
0538: } else if (key
0539: .equals(ProxoolConstants.INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) {
0540: if (isChanged(getInjectableStatementInterfaceName(), value)) {
0541: changed = true;
0542: if (!pretend) {
0543: setInjectableStatementInterfaceName(value.length() > 0 ? value
0544: : null);
0545: }
0546: }
0547: } else if (key
0548: .equals(ProxoolConstants.INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY)) {
0549: if (isChanged(
0550: getInjectablePreparedStatementInterfaceName(),
0551: value)) {
0552: changed = true;
0553: if (!pretend) {
0554: setInjectablePreparedStatementInterfaceName(value
0555: .length() > 0 ? value : null);
0556: }
0557: }
0558: } else if (key
0559: .equals(ProxoolConstants.INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY)) {
0560: if (isChanged(
0561: getInjectableCallableStatememtInterfaceName(),
0562: value)) {
0563: changed = true;
0564: if (!pretend) {
0565: setInjectableCallableStatementInterfaceName(value
0566: .length() > 0 ? value : null);
0567: }
0568: }
0569: }
0570: return changed;
0571: }
0572:
0573: /**
0574: * Subset of {@link #setAnyProperty} to avoid overly long method.
0575: * @see #setAnyProperty
0576: */
0577: private boolean setHouseKeeperProperty(String key, String value,
0578: boolean pretend) throws ProxoolException {
0579: boolean changed = false;
0580: if (key
0581: .equals(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY)) {
0582: if (getHouseKeepingSleepTime() != getInt(key, value)) {
0583: changed = true;
0584: if (!pretend) {
0585: setHouseKeepingSleepTime(getInt(key, value));
0586: }
0587: }
0588: } else if (key
0589: .equals(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY)) {
0590: if (isChanged(getHouseKeepingTestSql(), value)) {
0591: changed = true;
0592: if (!pretend) {
0593: setHouseKeepingTestSql(value.length() > 0 ? value
0594: : null);
0595: }
0596: }
0597: } else if (key
0598: .equals(ProxoolConstants.TEST_BEFORE_USE_PROPERTY)) {
0599: final boolean valueAsBoolean = Boolean.valueOf(value)
0600: .booleanValue();
0601: if (isTestBeforeUse() != valueAsBoolean) {
0602: changed = true;
0603: if (!pretend) {
0604: setTestBeforeUse(valueAsBoolean);
0605: }
0606: }
0607: } else if (key.equals(ProxoolConstants.TEST_AFTER_USE_PROPERTY)) {
0608: final boolean valueAsBoolean = Boolean.valueOf(value)
0609: .booleanValue();
0610: if (isTestAfterUse() != valueAsBoolean) {
0611: changed = true;
0612: if (!pretend) {
0613: setTestAfterUse(valueAsBoolean);
0614: }
0615: }
0616: }
0617: return changed;
0618: }
0619:
0620: /**
0621: * Subset of {@link #setAnyProperty} to avoid overly long method
0622: * @see #setAnyProperty
0623: */
0624: private boolean setJndiProperty(String key, String value,
0625: boolean pretend) {
0626: boolean changed = false;
0627: if (key.equals(ProxoolConstants.JNDI_NAME_PROPERTY)) {
0628: if (isChanged(getJndiName(), value)) {
0629: changed = true;
0630: if (!pretend) {
0631: setJndiName(value.length() > 0 ? value : null);
0632: }
0633: }
0634: } else {
0635:
0636: }
0637: return changed;
0638: }
0639:
0640: private int getInt(String key, String value)
0641: throws ProxoolException {
0642: try {
0643: return Integer.parseInt(value);
0644: } catch (NumberFormatException e) {
0645: throw new ProxoolException("'" + key
0646: + "' property must be an integer. Found '" + value
0647: + "' instead.");
0648: }
0649: }
0650:
0651: private static boolean isChanged(String oldValue, String newValue) {
0652: boolean changed = false;
0653: if (oldValue == null) {
0654: if (newValue != null) {
0655: changed = true;
0656: }
0657: } else if (newValue == null) {
0658: changed = true;
0659: } else if (!oldValue.equals(newValue)) {
0660: changed = true;
0661: }
0662: return changed;
0663: }
0664:
0665: /**
0666: * Deep clone of definition
0667: * @return the new definition
0668: * @throws CloneNotSupportedException
0669: */
0670: protected Object clone() throws CloneNotSupportedException {
0671: ConnectionPoolDefinition clone = new ConnectionPoolDefinition();
0672:
0673: clone.setCompleteUrl(completeUrl);
0674: clone.setDelegateProperties((Properties) delegateProperties
0675: .clone());
0676: clone.setCompleteInfo((Properties) completeInfo.clone());
0677: clone.clearChangedInfo();
0678:
0679: clone.setAlias(alias);
0680: clone.setUrl(url);
0681: clone.setDriver(driver);
0682: clone.setMaximumConnectionLifetime(maximumConnectionLifetime);
0683: clone.setPrototypeCount(prototypeCount);
0684: clone.setMinimumConnectionCount(minimumConnectionCount);
0685: clone.setMaximumConnectionCount(maximumConnectionCount);
0686: clone.setHouseKeepingSleepTime(houseKeepingSleepTime);
0687: clone.setHouseKeepingTestSql(houseKeepingTestSql);
0688: clone.setTestAfterUse(testAfterUse);
0689: clone.setTestBeforeUse(testBeforeUse);
0690: clone.setSimultaneousBuildThrottle(simultaneousBuildThrottle);
0691: clone.setRecentlyStartedThreshold(recentlyStartedThreshold);
0692: clone
0693: .setOverloadWithoutRefusalLifetime(overloadWithoutRefusalLifetime);
0694: clone.setMaximumActiveTime(maximumActiveTime);
0695: clone.setVerbose(verbose);
0696: clone.setTrace(trace);
0697: clone.setStatistics(statistics);
0698: clone.setStatisticsLogLevel(statisticsLogLevel);
0699: clone.setFatalSqlExceptionsAsString(fatalSqlExceptionsAsString);
0700: try {
0701: clone.setFatalSqlExceptionWrapper(fatalSqlExceptionWrapper);
0702: } catch (ProxoolException e) {
0703: throw new IllegalArgumentException(
0704: "Problem cloning fatalSqlExceptionWrapper: "
0705: + fatalSqlExceptionWrapper);
0706: }
0707: return clone;
0708: }
0709:
0710: private void clearChangedInfo() {
0711: changedInfo.clear();
0712: }
0713:
0714: /**
0715: * Reset all properties to their default values
0716: */
0717: private void reset() {
0718: completeUrl = null;
0719: delegateProperties.clear();
0720: completeInfo.clear();
0721: changedInfo.clear();
0722:
0723: url = null;
0724: driver = null;
0725: maximumConnectionLifetime = DEFAULT_MAXIMUM_CONNECTION_LIFETIME;
0726: prototypeCount = DEFAULT_PROTOTYPE_COUNT;
0727: minimumConnectionCount = DEFAULT_MINIMUM_CONNECTION_COUNT;
0728: maximumConnectionCount = DEFAULT_MAXIMUM_CONNECTION_COUNT;
0729: houseKeepingSleepTime = DEFAULT_HOUSE_KEEPING_SLEEP_TIME;
0730: houseKeepingTestSql = null;
0731: testAfterUse = false;
0732: testBeforeUse = false;
0733: simultaneousBuildThrottle = DEFAULT_SIMULTANEOUS_BUILD_THROTTLE;
0734: recentlyStartedThreshold = DEFAULT_RECENTLY_STARTED_THRESHOLD;
0735: overloadWithoutRefusalLifetime = DEFAULT_OVERLOAD_WITHOUT_REFUSAL_THRESHOLD;
0736: maximumActiveTime = DEFAULT_MAXIMUM_ACTIVE_TIME;
0737: verbose = false;
0738: trace = false;
0739: statistics = null;
0740: statisticsLogLevel = null;
0741: fatalSqlExceptions.clear();
0742: fatalSqlExceptionWrapper = null;
0743: }
0744:
0745: /**
0746: * Get all the properties used to define this pool
0747: * @return
0748: */
0749: protected Properties getCompleteInfo() {
0750: return completeInfo;
0751: }
0752:
0753: /**
0754: * Overwrite the complete info
0755: * @param completeInfo the new properties
0756: * @see #getCompleteInfo()
0757: */
0758: public void setCompleteInfo(Properties completeInfo) {
0759: this .completeInfo = completeInfo;
0760: }
0761:
0762: /**
0763: * @see ConnectionPoolDefinitionIF#getUser
0764: */
0765: public String getUser() {
0766: return getDelegateProperty(USER_PROPERTY);
0767: }
0768:
0769: /**
0770: * @see ConnectionPoolDefinitionIF#getUser
0771: */
0772: public void setUser(String user) {
0773: setDelegateProperty(USER_PROPERTY, user);
0774: }
0775:
0776: /**
0777: * @see ConnectionPoolDefinitionIF#getPassword
0778: */
0779: public String getPassword() {
0780: return getDelegateProperty(PASSWORD_PROPERTY);
0781: }
0782:
0783: /**
0784: * @see ConnectionPoolDefinitionIF#getPassword
0785: */
0786: public void setPassword(String password) {
0787: setDelegateProperty(PASSWORD_PROPERTY, password);
0788: }
0789:
0790: /**
0791: * @see ConnectionPoolDefinitionIF#getJdbcDriverVersion
0792: */
0793: public String getJdbcDriverVersion() {
0794:
0795: try {
0796: Driver driver = DriverManager.getDriver(getUrl());
0797: return driver.getMajorVersion() + "."
0798: + driver.getMinorVersion();
0799: } catch (SQLException e) {
0800: return "Trying to locate driver version for '" + getUrl()
0801: + "' caused: " + e.toString();
0802: } catch (NullPointerException e) {
0803: return "Couldn't locate driver for '" + getUrl() + "'!";
0804: }
0805:
0806: }
0807:
0808: /**
0809: * @see Object#toString
0810: */
0811: public String toString() {
0812: return getCompleteUrl();
0813: }
0814:
0815: /**
0816: * @see ConnectionPoolDefinitionIF#getName
0817: * @deprecated use {@link #getAlias}
0818: */
0819: public String getName() {
0820: return alias;
0821: }
0822:
0823: /**
0824: * @see ConnectionPoolDefinitionIF#getAlias
0825: */
0826: public String getAlias() {
0827: return alias;
0828: }
0829:
0830: /**
0831: * @see ConnectionPoolDefinitionIF#getAlias
0832: */
0833: public void setAlias(String alias) {
0834: this .alias = alias;
0835: }
0836:
0837: /**
0838: * @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
0839: */
0840: public int getMaximumConnectionLifetime() {
0841: return maximumConnectionLifetime;
0842: }
0843:
0844: /**
0845: * @see ConnectionPoolDefinitionIF#getMaximumConnectionLifetime
0846: */
0847: public void setMaximumConnectionLifetime(
0848: int maximumConnectionLifetime) {
0849: this .maximumConnectionLifetime = maximumConnectionLifetime;
0850: }
0851:
0852: /**
0853: * @see ConnectionPoolDefinitionIF#getPrototypeCount
0854: */
0855: public int getPrototypeCount() {
0856: return prototypeCount;
0857: }
0858:
0859: /**
0860: * @see ConnectionPoolDefinitionIF#getPrototypeCount
0861: */
0862: public void setPrototypeCount(int prototypeCount) {
0863: this .prototypeCount = prototypeCount;
0864: }
0865:
0866: /**
0867: * @see ConnectionPoolDefinitionIF#getMinimumConnectionCount
0868: */
0869: public int getMinimumConnectionCount() {
0870: return minimumConnectionCount;
0871: }
0872:
0873: /**
0874: * @see ConnectionPoolDefinitionIF#getMinimumConnectionCount
0875: */
0876: public void setMinimumConnectionCount(int minimumConnectionCount) {
0877: this .minimumConnectionCount = minimumConnectionCount;
0878: }
0879:
0880: /**
0881: * @see ConnectionPoolDefinitionIF#getMaximumConnectionCount
0882: */
0883: public int getMaximumConnectionCount() {
0884: return maximumConnectionCount;
0885: }
0886:
0887: /**
0888: * @see ConnectionPoolDefinitionIF#getMaximumConnectionCount
0889: */
0890: public void setMaximumConnectionCount(int maximumConnectionCount) {
0891: this .maximumConnectionCount = maximumConnectionCount;
0892: }
0893:
0894: /**
0895: * @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
0896: */
0897: public int getHouseKeepingSleepTime() {
0898: return houseKeepingSleepTime;
0899: }
0900:
0901: /**
0902: * @see ConnectionPoolDefinitionIF#getHouseKeepingSleepTime
0903: */
0904: public void setHouseKeepingSleepTime(int houseKeepingSleepTime) {
0905: this .houseKeepingSleepTime = houseKeepingSleepTime;
0906: }
0907:
0908: /**
0909: * @see ConnectionPoolDefinitionIF#getMaximumNewConnections
0910: * @deprecated use more descriptive {@link #getSimultaneousBuildThrottle} instead
0911: */
0912: public int getMaximumNewConnections() {
0913: return simultaneousBuildThrottle;
0914: }
0915:
0916: /**
0917: * @see ConnectionPoolDefinitionIF#getMaximumNewConnections
0918: * @deprecated use more descriptive {@link #setSimultaneousBuildThrottle} instead
0919: */
0920: public void setMaximumNewConnections(int maximumNewConnections) {
0921: this .simultaneousBuildThrottle = maximumNewConnections;
0922: }
0923:
0924: /**
0925: * @see ConnectionPoolDefinitionIF#getSimultaneousBuildThrottle
0926: */
0927: public int getSimultaneousBuildThrottle() {
0928: return simultaneousBuildThrottle;
0929: }
0930:
0931: /**
0932: * @see ConnectionPoolDefinitionIF#getSimultaneousBuildThrottle
0933: */
0934: public void setSimultaneousBuildThrottle(
0935: int simultaneousBuildThrottle) {
0936: this .simultaneousBuildThrottle = simultaneousBuildThrottle;
0937: }
0938:
0939: /**
0940: * @see ConnectionPoolDefinitionIF#getProperties
0941: * @deprecated use less ambiguous {@link #getDelegateProperties} instead
0942: */
0943: public Properties getProperties() {
0944: return delegateProperties;
0945: }
0946:
0947: /**
0948: * @see ConnectionPoolDefinitionIF#getDelegateProperties
0949: */
0950: public Properties getDelegateProperties() {
0951: return delegateProperties;
0952: }
0953:
0954: /**
0955: * Get a property
0956: * @param name the name of the property
0957: * @return the value of the property
0958: */
0959: public String getDelegateProperty(String name) {
0960: return getDelegateProperties().getProperty(name);
0961: }
0962:
0963: /**
0964: * Set a property
0965: * @param name the name of the property
0966: * @param value the value of the property
0967: * @see ConnectionPoolDefinitionIF#getProperties
0968: */
0969: public void setDelegateProperty(String name, String value) {
0970: connectionPropertiesChanged = true;
0971: getDelegateProperties().setProperty(name, value);
0972: }
0973:
0974: /**
0975: * Overwrite the delegate properties
0976: * @param delegateProperties the new properties
0977: * @see ConnectionPoolDefinitionIF#getProperties
0978: */
0979: public void setDelegateProperties(Properties delegateProperties) {
0980: this .delegateProperties = delegateProperties;
0981: }
0982:
0983: /**
0984: * @see ConnectionPoolDefinitionIF#getUrl
0985: */
0986: public String getUrl() {
0987: return url;
0988: }
0989:
0990: /**
0991: * @see ConnectionPoolDefinitionIF#getUrl
0992: */
0993: public void setUrl(String url) {
0994: this .url = url;
0995: connectionPropertiesChanged = true;
0996: }
0997:
0998: /**
0999: * @see ConnectionPoolDefinitionIF#getDriver
1000: */
1001: public String getDriver() {
1002: return driver;
1003: }
1004:
1005: /**
1006: * @see ConnectionPoolDefinitionIF#getDriver
1007: */
1008: public void setDriver(String driver) {
1009: this .driver = driver;
1010: connectionPropertiesChanged = true;
1011: }
1012:
1013: /**
1014: * @see ConnectionPoolDefinitionIF#getRecentlyStartedThreshold
1015: */
1016: public int getRecentlyStartedThreshold() {
1017: return recentlyStartedThreshold;
1018: }
1019:
1020: /**
1021: * @see ConnectionPoolDefinitionIF#getRecentlyStartedThreshold
1022: */
1023: public void setRecentlyStartedThreshold(int recentlyStartedThreshold) {
1024: this .recentlyStartedThreshold = recentlyStartedThreshold;
1025: }
1026:
1027: /**
1028: * @see ConnectionPoolDefinitionIF#getOverloadWithoutRefusalLifetime
1029: */
1030: public int getOverloadWithoutRefusalLifetime() {
1031: return overloadWithoutRefusalLifetime;
1032: }
1033:
1034: /**
1035: * @see ConnectionPoolDefinitionIF#getOverloadWithoutRefusalLifetime
1036: */
1037: public void setOverloadWithoutRefusalLifetime(
1038: int overloadWithoutRefusalLifetime) {
1039: this .overloadWithoutRefusalLifetime = overloadWithoutRefusalLifetime;
1040: }
1041:
1042: /**
1043: * @see ConnectionPoolDefinitionIF#getMaximumActiveTime
1044: */
1045: public int getMaximumActiveTime() {
1046: return maximumActiveTime;
1047: }
1048:
1049: /**
1050: * @see ConnectionPoolDefinitionIF#getMaximumActiveTime
1051: */
1052: public void setMaximumActiveTime(int maximumActiveTime) {
1053: this .maximumActiveTime = maximumActiveTime;
1054: }
1055:
1056: /**
1057: * @see ConnectionPoolDefinitionIF#getDebugLevel
1058: * @deprecated use {@link #isVerbose} instead
1059: */
1060: public int getDebugLevel() {
1061: return (verbose ? 1 : 0);
1062: }
1063:
1064: /**
1065: * @see ConnectionPoolDefinitionIF#isVerbose
1066: */
1067: public boolean isVerbose() {
1068: return verbose;
1069: }
1070:
1071: /**
1072: * @see ConnectionPoolDefinitionIF#isVerbose
1073: */
1074: public void setVerbose(boolean verbose) {
1075: this .verbose = verbose;
1076: }
1077:
1078: /**
1079: * @see ConnectionPoolDefinitionIF#isTrace
1080: */
1081: public boolean isTrace() {
1082: return trace;
1083: }
1084:
1085: /**
1086: * @see ConnectionPoolDefinitionIF#isTrace
1087: */
1088: public void setTrace(boolean trace) {
1089: this .trace = trace;
1090: }
1091:
1092: /**
1093: * @see ConnectionPoolDefinitionIF#getCompleteUrl
1094: */
1095: public String getCompleteUrl() {
1096: return completeUrl;
1097: }
1098:
1099: /**
1100: * @see ConnectionPoolDefinitionIF#getCompleteUrl
1101: */
1102: public void setCompleteUrl(String completeUrl) {
1103: this .completeUrl = completeUrl;
1104: }
1105:
1106: /**
1107: * @see ConnectionPoolDefinitionIF#getFatalSqlExceptions
1108: */
1109: public void setFatalSqlExceptionsAsString(
1110: String fatalSqlExceptionsAsString) {
1111: this .fatalSqlExceptionsAsString = fatalSqlExceptionsAsString;
1112: fatalSqlExceptions.clear();
1113: if (fatalSqlExceptionsAsString != null) {
1114: StringTokenizer st = new StringTokenizer(
1115: fatalSqlExceptionsAsString,
1116: FATAL_SQL_EXCEPTIONS_DELIMITER);
1117: while (st.hasMoreTokens()) {
1118: fatalSqlExceptions.add(st.nextToken().trim());
1119: }
1120: }
1121: }
1122:
1123: /**
1124: * @see ConnectionPoolDefinitionIF#getFatalSqlExceptions
1125: */
1126: public Set getFatalSqlExceptions() {
1127: return fatalSqlExceptions;
1128: }
1129:
1130: /**
1131: * @see ConnectionPoolDefinitionIF#getFatalSqlExceptionWrapper
1132: */
1133: public String getFatalSqlExceptionWrapper() {
1134: return fatalSqlExceptionWrapper;
1135: }
1136:
1137: /**
1138: * @see ConnectionPoolDefinitionIF#getFatalSqlExceptionWrapper
1139: */
1140: public void setFatalSqlExceptionWrapper(
1141: String fatalSqlExceptionWrapper) throws ProxoolException {
1142:
1143: // Test it out. That's the best way.
1144: try {
1145: FatalSqlExceptionHelper.throwFatalSQLException(
1146: fatalSqlExceptionWrapper, new SQLException("Test"));
1147: } catch (SQLException e) {
1148: // That's OK, we were expecting one of these
1149: } catch (RuntimeException e) {
1150: // That's OK, we were expecting one of these
1151: }
1152:
1153: this .fatalSqlExceptionWrapper = fatalSqlExceptionWrapper;
1154: }
1155:
1156: /**
1157: * @see ConnectionPoolDefinitionIF#getHouseKeepingTestSql
1158: */
1159: public String getHouseKeepingTestSql() {
1160: return houseKeepingTestSql;
1161: }
1162:
1163: /**
1164: * @see ConnectionPoolDefinitionIF#getHouseKeepingTestSql
1165: */
1166: public void setHouseKeepingTestSql(String houseKeepingTestSql) {
1167: this .houseKeepingTestSql = houseKeepingTestSql;
1168: }
1169:
1170: /**
1171: * @see ConnectionPoolDefinitionIF#isTestBeforeUse
1172: */
1173: public boolean isTestBeforeUse() {
1174: return testBeforeUse;
1175: }
1176:
1177: /**
1178: * @see ConnectionPoolDefinitionIF#isTestBeforeUse
1179: */
1180: public void setTestBeforeUse(boolean testBeforeUse) {
1181: this .testBeforeUse = testBeforeUse;
1182: }
1183:
1184: /**
1185: * @see ConnectionPoolDefinitionIF#isTestAfterUse
1186: */
1187: public boolean isTestAfterUse() {
1188: return testAfterUse;
1189: }
1190:
1191: /**
1192: * @see ConnectionPoolDefinitionIF#isTestAfterUse
1193: */
1194: public void setTestAfterUse(boolean testAfterUse) {
1195: this .testAfterUse = testAfterUse;
1196: }
1197:
1198: /**
1199: * @see ConnectionPoolDefinitionIF#getStatistics
1200: */
1201: public String getStatistics() {
1202: return statistics;
1203: }
1204:
1205: /**
1206: * @see ConnectionPoolDefinitionIF#getStatistics
1207: */
1208: public void setStatistics(String statistics) {
1209: this .statistics = statistics;
1210: }
1211:
1212: /**
1213: * @see ConnectionPoolDefinitionIF#getStatisticsLogLevel
1214: */
1215: public String getStatisticsLogLevel() {
1216: return statisticsLogLevel;
1217: }
1218:
1219: /**
1220: * @see ConnectionPoolDefinitionIF#getStatisticsLogLevel
1221: */
1222: public void setStatisticsLogLevel(String statisticsLogLevel) {
1223: this .statisticsLogLevel = statisticsLogLevel;
1224: }
1225:
1226: // Start JNDI
1227: public String getJndiName() {
1228: return jndiName;
1229: }
1230:
1231: public void setJndiName(String jndiName) {
1232: this .jndiName = jndiName;
1233: }
1234:
1235: public String getInitialContextFactory() {
1236: return initialContextFactory;
1237: }
1238:
1239: public void setInitialContextFactory(String initialContextFactory) {
1240: this .initialContextFactory = initialContextFactory;
1241: }
1242:
1243: public String getProviderUrl() {
1244: return providerUrl;
1245: }
1246:
1247: public void setProviderUrl(String providerUrl) {
1248: this .providerUrl = providerUrl;
1249: }
1250:
1251: public String getSecurityAuthentication() {
1252: return securityAuthentication;
1253: }
1254:
1255: public void setSecurityAuthentication(String securityAuthentication) {
1256: this .securityAuthentication = securityAuthentication;
1257: }
1258:
1259: public String getSecurityPrincipal() {
1260: return securityPrincipal;
1261: }
1262:
1263: public void setSecurityPrincipal(String securityPrincipal) {
1264: this .securityPrincipal = securityPrincipal;
1265: }
1266:
1267: public String getSecurityCredentials() {
1268: return securityCredentials;
1269: }
1270:
1271: public void setSecurityCredentials(String securityCredentials) {
1272: this .securityCredentials = securityCredentials;
1273: }
1274:
1275: // End JNDI
1276:
1277: /**
1278: * @see ConnectionPoolDefinitionIF#isJmx()
1279: */
1280: public boolean isJmx() {
1281: return jmx;
1282: }
1283:
1284: /**
1285: * @see ConnectionPoolDefinitionIF#isJmx()
1286: */
1287: public void setJmx(boolean jmx) {
1288: this .jmx = jmx;
1289: }
1290:
1291: /**
1292: * @see ConnectionPoolDefinitionIF#getJmxAgentId()
1293: */
1294: public String getJmxAgentId() {
1295: return jmxAgentId;
1296: }
1297:
1298: /**
1299: * @see ConnectionPoolDefinitionIF#getJmxAgentId()
1300: */
1301: public void setJmxAgentId(String jmxAgentId) {
1302: this .jmxAgentId = jmxAgentId;
1303: }
1304:
1305: /**
1306: * @see ConnectionPoolDefinitionIF#getInjectableConnectionInterface()
1307: */
1308: public Class getInjectableConnectionInterface() {
1309: return injectableConnectionInterface;
1310: }
1311:
1312: /**
1313: * @see ConnectionPoolDefinitionIF#getInjectableConnectionInterface()
1314: */
1315: public String getInjectableConnectionInterfaceName() {
1316: if (getInjectableConnectionInterface() != null) {
1317: return getInjectableConnectionInterface().getName();
1318: } else {
1319: return null;
1320: }
1321: }
1322:
1323: /**
1324: * @param injectableConnectionInterfaceName the fully qualified class name
1325: * @see ConnectionPoolDefinitionIF#getInjectableConnectionInterface()
1326: */
1327: public void setInjectableConnectionInterfaceName(
1328: String injectableConnectionInterfaceName) {
1329: this .injectableConnectionInterface = getInterface(injectableConnectionInterfaceName);
1330: }
1331:
1332: /**
1333: * @see ConnectionPoolDefinitionIF#getInjectableStatementInterface()
1334: */
1335: public Class getInjectableStatementInterface() {
1336: return injectableStatementInterface;
1337: }
1338:
1339: /**
1340: * @see ConnectionPoolDefinitionIF#getInjectableStatementInterface()
1341: */
1342: public String getInjectableStatementInterfaceName() {
1343: if (getInjectableStatementInterface() != null) {
1344: return getInjectableStatementInterface().getName();
1345: } else {
1346: return null;
1347: }
1348: }
1349:
1350: /**
1351: * @param injectableStatementInterfaceName the fully qualified class name
1352: * @see ConnectionPoolDefinitionIF#getInjectableStatementInterface()
1353: */
1354: public void setInjectableStatementInterfaceName(
1355: String injectableStatementInterfaceName) {
1356: this .injectableStatementInterface = getInterface(injectableStatementInterfaceName);
1357: }
1358:
1359: /**
1360: * @see ConnectionPoolDefinitionIF#getInjectablePreparedStatementInterface()
1361: */
1362: public Class getInjectablePreparedStatementInterface() {
1363: return injectablePreparedStatementInterface;
1364: }
1365:
1366: /**
1367: * @see ConnectionPoolDefinitionIF#getInjectablePreparedStatementInterface()
1368: */
1369: public String getInjectablePreparedStatementInterfaceName() {
1370: if (getInjectablePreparedStatementInterface() != null) {
1371: return getInjectablePreparedStatementInterface().getName();
1372: } else {
1373: return null;
1374: }
1375: }
1376:
1377: /**
1378: * @param injectablePreparedStatementInterfaceName the fully qualified class name
1379: * @see ConnectionPoolDefinitionIF#getInjectablePreparedStatementInterface()
1380: */
1381: public void setInjectablePreparedStatementInterfaceName(
1382: String injectablePreparedStatementInterfaceName) {
1383: this .injectablePreparedStatementInterface = getInterface(injectablePreparedStatementInterfaceName);
1384: }
1385:
1386: /**
1387: * @see ConnectionPoolDefinitionIF#getInjectableCallableStatementInterface()
1388: */
1389: public String getInjectableCallableStatememtInterfaceName() {
1390: if (getInjectableCallableStatementInterface() != null) {
1391: return getInjectableCallableStatementInterface().getName();
1392: } else {
1393: return null;
1394: }
1395: }
1396:
1397: /**
1398: * @see ConnectionPoolDefinitionIF#getInjectableCallableStatementInterface()
1399: */
1400: public Class getInjectableCallableStatementInterface() {
1401: return injectableCallableStatementInterface;
1402: }
1403:
1404: /**
1405: * @param injectableCallableStatementInterfaceName the fully qualified class name
1406: * @see ConnectionPoolDefinitionIF#getInjectableCallableStatementInterface()
1407: */
1408: public void setInjectableCallableStatementInterfaceName(
1409: String injectableCallableStatementInterfaceName) {
1410: this .injectableCallableStatementInterface = getInterface(injectableCallableStatementInterfaceName);
1411: }
1412:
1413: private Class getInterface(String className) {
1414: try {
1415: Class clazz = null;
1416: if (className != null && className.length() > 0) {
1417: clazz = Class.forName(className);
1418: if (!clazz.isInterface()) {
1419: throw new IllegalArgumentException(className
1420: + " is a class. It must be an interface.");
1421: }
1422: if (!Modifier.isPublic(clazz.getModifiers())) {
1423: throw new IllegalArgumentException(
1424: className
1425: + " is a protected interface. It must be public.");
1426: }
1427: }
1428: return clazz;
1429: } catch (ClassNotFoundException e) {
1430: throw new IllegalArgumentException(className
1431: + " couldn't be found");
1432: }
1433: }
1434:
1435: /**
1436: * Returns true if {@link #redefine redefining} the pool using
1437: * these parameters would not change the definition. You can
1438: * use this to decide whether or not to trigger a change
1439: * {@link ConfigurationListenerIF#definitionUpdated event}.
1440: *
1441: * @param url the url (containing alias and possible delegate url and driver)
1442: * @param info the properties
1443: * @return true if the definition is identical to that that represented by these parameters
1444: */
1445: public boolean isEqual(String url, Properties info) {
1446: try {
1447: return !doChange(url, info, true, false);
1448: } catch (ProxoolException e) {
1449: LOG.error("Problem checking equality", e);
1450: return false;
1451: }
1452: /*
1453: boolean equal = true;
1454:
1455: if (info == null && completeInfo != null) {
1456: equal = false;
1457: } else if (info != null && completeInfo == null) {
1458: equal = false;
1459: } else if (!info.equals(completeInfo)) {
1460: equal = false;
1461: } else if (!url.equals(completeUrl)) {
1462: equal = false;
1463: }
1464:
1465: return equal;
1466: */
1467: }
1468:
1469: }
1470:
1471: /*
1472: Revision history:
1473: $Log: ConnectionPoolDefinition.java,v $
1474: Revision 1.34 2006/01/18 14:40:01 billhorsman
1475: Unbundled Jakarta's Commons Logging.
1476:
1477: Revision 1.33 2005/05/04 16:24:59 billhorsman
1478: Now supports cloning.
1479:
1480: Revision 1.32 2004/06/02 20:19:14 billhorsman
1481: Added injectable interface properties
1482:
1483: Revision 1.31 2004/03/18 17:08:14 chr32
1484: Added jmx* properties.
1485:
1486: Revision 1.30 2004/03/15 02:42:44 chr32
1487: Removed explicit JNDI properties. Going for a generic approach instead.
1488:
1489: Revision 1.29 2003/10/30 00:13:59 billhorsman
1490: Fixed bug where all proxool properties were getting passed onto the delegate driver, and all delegate properties weren't
1491:
1492: Revision 1.28 2003/10/24 15:22:21 billhorsman
1493: Fixed bug where connection pool was being recognised as changed even when it wasn't. (This bug introduced after 0.7.2).
1494:
1495: Revision 1.27 2003/10/20 11:40:53 billhorsman
1496: Smarter handling of null and empty strings. No NPE during unit tests now.
1497:
1498: Revision 1.26 2003/10/19 13:31:57 billhorsman
1499: Setting a property to a zero length String actually sets it to a null
1500:
1501: Revision 1.25 2003/10/16 18:54:49 billhorsman
1502: Fixed javadoc for update() and redefine() methods which were transposed. Also improved exception handling for
1503: incomplete pool definitions.
1504:
1505: Revision 1.24 2003/09/30 18:39:08 billhorsman
1506: New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties.
1507:
1508: Revision 1.23 2003/09/29 17:48:08 billhorsman
1509: New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you
1510: can make it a RuntimeException if you need to.
1511:
1512: Revision 1.22 2003/09/05 16:59:42 billhorsman
1513: Added wrap-fatal-sql-exceptions property
1514:
1515: Revision 1.21 2003/08/30 14:54:04 billhorsman
1516: Checkstyle
1517:
1518: Revision 1.20 2003/08/30 11:37:31 billhorsman
1519: Trim fatal-sql-exception messages so that whitespace around the comma delimiters does not
1520: get used to match against exception message.
1521:
1522: Revision 1.19 2003/07/23 06:54:48 billhorsman
1523: draft JNDI changes (shouldn't effect normal operation)
1524:
1525: Revision 1.18 2003/04/27 15:42:21 billhorsman
1526: fix to condition that meant configuration change was getting sent too often (and sometimes not at all)
1527:
1528: Revision 1.17 2003/04/19 12:58:41 billhorsman
1529: fixed bug where ConfigurationListener's
1530: definitionUpdated was getting called too
1531: frequently
1532:
1533: Revision 1.16 2003/04/10 21:50:16 billhorsman
1534: empty constructor for use by DataSource
1535:
1536: Revision 1.15 2003/03/11 14:51:49 billhorsman
1537: more concurrency fixes relating to snapshots
1538:
1539: Revision 1.14 2003/03/10 23:43:09 billhorsman
1540: reapplied checkstyle that i'd inadvertently let
1541: IntelliJ change...
1542:
1543: Revision 1.13 2003/03/10 15:26:45 billhorsman
1544: refactoringn of concurrency stuff (and some import
1545: optimisation)
1546:
1547: Revision 1.12 2003/03/05 23:28:56 billhorsman
1548: deprecated maximum-new-connections property in favour of
1549: more descriptive simultaneous-build-throttle
1550:
1551: Revision 1.11 2003/03/05 18:42:32 billhorsman
1552: big refactor of prototyping and house keeping to
1553: drastically reduce the number of threads when using
1554: many pools
1555:
1556: Revision 1.10 2003/03/03 11:11:57 billhorsman
1557: fixed licence
1558:
1559: Revision 1.9 2003/02/26 16:05:52 billhorsman
1560: widespread changes caused by refactoring the way we
1561: update and redefine pool definitions.
1562:
1563: Revision 1.8 2003/02/06 15:41:17 billhorsman
1564: add statistics-log-level
1565:
1566: Revision 1.7 2003/01/31 00:17:05 billhorsman
1567: statistics is now a string to allow multiple,
1568: comma-delimited values
1569:
1570: Revision 1.6 2003/01/30 17:20:38 billhorsman
1571: new statistics property
1572:
1573: Revision 1.5 2003/01/17 00:38:12 billhorsman
1574: wide ranging changes to clarify use of alias and url -
1575: this has led to some signature changes (new exceptions
1576: thrown) on the ProxoolFacade API.
1577:
1578: Revision 1.4 2002/11/09 15:50:15 billhorsman
1579: new trace property and better doc
1580:
1581: Revision 1.3 2002/10/27 13:29:38 billhorsman
1582: deprecated debug-level in favour of verbose
1583:
1584: Revision 1.2 2002/10/17 19:46:02 billhorsman
1585: removed redundant reference to logFilename (we now use Jakarta's Commons Logging component
1586:
1587: Revision 1.1.1.1 2002/09/13 08:13:00 billhorsman
1588: new
1589:
1590: Revision 1.8 2002/07/10 16:14:47 billhorsman
1591: widespread layout changes and move constants into ProxoolConstants
1592:
1593: Revision 1.7 2002/07/04 09:05:36 billhorsman
1594: Fixes
1595:
1596: Revision 1.6 2002/07/02 11:19:08 billhorsman
1597: layout code and imports
1598:
1599: Revision 1.5 2002/07/02 08:41:59 billhorsman
1600: No longer public - we should be confuring pools with Properties now. Also added completeUrl property so that we can access pool by either alias or full url.
1601:
1602: Revision 1.4 2002/06/28 11:19:47 billhorsman
1603: improved doc
1604:
1605: */
|