proxool-cvs Mailing List for Proxool: Proxy JDBC Connection Pool (Page 9)
UNMAINTAINED!
Brought to you by:
billhorsman
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
(17) |
Mar
(20) |
Apr
(22) |
May
(4) |
Jun
(3) |
Jul
(11) |
Aug
(23) |
Sep
(60) |
Oct
(41) |
Nov
(15) |
Dec
(29) |
2004 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(5) |
Jun
(29) |
Jul
(6) |
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(8) |
Jun
|
Jul
(1) |
Aug
|
Sep
(8) |
Oct
(19) |
Nov
|
Dec
|
2006 |
Jan
(17) |
Feb
|
Mar
(5) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2007 |
Jan
(9) |
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <bil...@us...> - 2003-10-20 15:02:30
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv11251 Modified Files: ConnectionPoolDefinition.java Log Message: Smarter handling of null and empty strings. No NPE during unit tests now. Index: ConnectionPoolDefinition.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPoolDefinition.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ConnectionPoolDefinition.java 19 Oct 2003 13:31:57 -0000 1.26 --- ConnectionPoolDefinition.java 20 Oct 2003 11:40:53 -0000 1.27 *************** *** 223,232 **** String key = (String) i.next(); String value = info.getProperty(key); - // This allows us to set properties to a null, even though Properties - // object doesn't allow null values. It means that you can't set a property - // to be a zero length string but that's ok. - if (value != null && value.length() == 0) { - value = null; - } changed = changed | setAnyProperty(key, value, pretend); if (!pretend) { --- 223,226 ---- *************** *** 360,364 **** changed = true; if (!pretend) { ! setFatalSqlExceptionsAsString(value); } } --- 354,358 ---- changed = true; if (!pretend) { ! setFatalSqlExceptionsAsString(value.length() > 0 ? value : null); } } *************** *** 367,371 **** changed = true; if (!pretend) { ! setFatalSqlExceptionWrapper(value); } } --- 361,365 ---- changed = true; if (!pretend) { ! setFatalSqlExceptionWrapper(value.length() > 0 ? value : null); } } *************** *** 374,378 **** changed = true; if (!pretend) { ! setStatistics(value); } } --- 368,372 ---- changed = true; if (!pretend) { ! setStatistics(value.length() > 0 ? value : null); } } *************** *** 381,385 **** changed = true; if (!pretend) { ! setStatisticsLogLevel(value); } } --- 375,379 ---- changed = true; if (!pretend) { ! setStatisticsLogLevel(value.length() > 0 ? value : null); } } *************** *** 463,467 **** changed = true; if (!pretend) { ! setHouseKeepingTestSql(value); } } --- 457,461 ---- changed = true; if (!pretend) { ! setHouseKeepingTestSql(value.length() > 0 ? value : null); } } *************** *** 496,500 **** changed = true; if (!pretend) { ! setJndiName(value); } } --- 490,494 ---- changed = true; if (!pretend) { ! setJndiName(value.length() > 0 ? value : null); } } *************** *** 503,507 **** changed = true; if (!pretend) { ! setInitialContextFactory(value); } } --- 497,501 ---- changed = true; if (!pretend) { ! setInitialContextFactory(value.length() > 0 ? value : null); } } *************** *** 510,514 **** changed = true; if (!pretend) { ! setProviderUrl(value); } } --- 504,508 ---- changed = true; if (!pretend) { ! setProviderUrl(value.length() > 0 ? value : null); } } *************** *** 517,521 **** changed = true; if (!pretend) { ! setSecurityAuthentication(value); } } --- 511,515 ---- changed = true; if (!pretend) { ! setSecurityAuthentication(value.length() > 0 ? value : null); } } *************** *** 524,528 **** changed = true; if (!pretend) { ! setSecurityPrincipal(value); } } --- 518,522 ---- changed = true; if (!pretend) { ! setSecurityPrincipal(value.length() > 0 ? value : null); } } *************** *** 531,535 **** changed = true; if (!pretend) { ! setSecurityCredentials(value); } } --- 525,529 ---- changed = true; if (!pretend) { ! setSecurityCredentials(value.length() > 0 ? value : null); } } *************** *** 1135,1138 **** --- 1129,1135 ---- Revision history: $Log$ + Revision 1.27 2003/10/20 11:40:53 billhorsman + Smarter handling of null and empty strings. No NPE during unit tests now. + Revision 1.26 2003/10/19 13:31:57 billhorsman Setting a property to a zero length String actually sets it to a null |
From: <ch...@us...> - 2003-10-20 07:43:39
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/jmx In directory sc8-pr-cvs1:/tmp/cvs-serv9535 Modified Files: ConnectionPoolMBean.java Log Message: Bettered handling of empty values. Now not setting attributes that has not changed. Index: ConnectionPoolMBean.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/jmx/ConnectionPoolMBean.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ConnectionPoolMBean.java 30 Sep 2003 18:38:27 -0000 1.13 --- ConnectionPoolMBean.java 20 Oct 2003 07:37:07 -0000 1.14 *************** *** 97,102 **** ! private static final Log LOG = LogFactory.getLog (ConnectionPoolMBean.class); ! private static final String CLASS_NAME = ConnectionPoolMBean.class.getName (); private static final String RECOURCE_NAME_MBEAN_POOL_DESCRIPTION = "mbean.pool.description"; --- 97,102 ---- ! private static final Log LOG = LogFactory.getLog(ConnectionPoolMBean.class); ! private static final String CLASS_NAME = ConnectionPoolMBean.class.getName(); private static final String RECOURCE_NAME_MBEAN_POOL_DESCRIPTION = "mbean.pool.description"; *************** *** 106,111 **** private static final String OPERATION_NAME_SHUTDOWN = "shutdown"; ! private static final ResourceBundle ATTRIBUTE_DESCRIPTIONS_RESOURCE = createAttributeDescriptionsResource (); ! private static final ResourceBundle JMX_RESOURCE = createJMXResource (); private static final MBeanNotificationInfo[] NOTIFICATION_INFOS = getNotificationInfos(); --- 106,111 ---- private static final String OPERATION_NAME_SHUTDOWN = "shutdown"; ! private static final ResourceBundle ATTRIBUTE_DESCRIPTIONS_RESOURCE = createAttributeDescriptionsResource(); ! private static final ResourceBundle JMX_RESOURCE = createJMXResource(); private static final MBeanNotificationInfo[] NOTIFICATION_INFOS = getNotificationInfos(); *************** *** 118,127 **** private boolean active; ! public ConnectionPoolMBean (String alias, Properties poolProperties) ! throws ProxoolException { this.poolDefinition = ProxoolFacade ! .getConnectionPoolDefinition(alias); this.poolProperties = poolProperties; ! this.mBeanInfo = getDynamicMBeanInfo(this.poolDefinition.getAlias ()); ProxoolFacade.addProxoolListener(this); ProxoolFacade.addConfigurationListener(alias, this); --- 118,127 ---- private boolean active; ! public ConnectionPoolMBean(String alias, Properties poolProperties) ! throws ProxoolException { this.poolDefinition = ProxoolFacade ! .getConnectionPoolDefinition(alias); this.poolProperties = poolProperties; ! this.mBeanInfo = getDynamicMBeanInfo(this.poolDefinition.getAlias()); ProxoolFacade.addProxoolListener(this); ProxoolFacade.addConfigurationListener(alias, this); *************** *** 131,145 **** * @see javax.management.DynamicMBean#getAttribute(java.lang.String) */ ! public Object getAttribute (String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException { if (attributeName == null) { final String message = "Cannot invoke a getter of " + CLASS_NAME + " with null attribute name"; LOG.error(message); ! throw new RuntimeOperationsException (new IllegalArgumentException ("Attribute name cannot be null"), ! message); } if (LOG.isDebugEnabled()) { LOG.debug("Getting attribute " + attributeName + "."); } ! return ((Attribute) getAttributes (new String[]{attributeName}).get (0)).getValue(); } --- 131,145 ---- * @see javax.management.DynamicMBean#getAttribute(java.lang.String) */ ! public Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException { if (attributeName == null) { final String message = "Cannot invoke a getter of " + CLASS_NAME + " with null attribute name"; LOG.error(message); ! throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name cannot be null"), ! message); } if (LOG.isDebugEnabled()) { LOG.debug("Getting attribute " + attributeName + "."); } ! return ((Attribute) getAttributes(new String[]{attributeName}).get(0)).getValue(); } *************** *** 147,164 **** * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute) */ ! public void setAttribute (Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { if (attribute == null) { final String message = "Cannot invoke a setter of " + CLASS_NAME + " with null attribute"; LOG.error(message); ! throw new RuntimeOperationsException (new IllegalArgumentException ("Attribute cannot be null"), ! message); } if (LOG.isDebugEnabled()) { LOG.debug("Setting attribute " + attribute.getName() + "."); } ! final AttributeList attributeList = new AttributeList (); ! attributeList.add (attribute); ! setAttributes (attributeList); } --- 147,164 ---- * @see javax.management.DynamicMBean#setAttribute(javax.management.Attribute) */ ! public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { if (attribute == null) { final String message = "Cannot invoke a setter of " + CLASS_NAME + " with null attribute"; LOG.error(message); ! throw new RuntimeOperationsException(new IllegalArgumentException("Attribute cannot be null"), ! message); } if (LOG.isDebugEnabled()) { LOG.debug("Setting attribute " + attribute.getName() + "."); } ! final AttributeList attributeList = new AttributeList(); ! attributeList.add(attribute); ! setAttributes(attributeList); } *************** *** 166,177 **** * @see javax.management.DynamicMBean#getAttributes(java.lang.String[]) */ ! public AttributeList getAttributes (String[] attributeNames) { if (attributeNames == null) { final String message = "Cannot invoke a null getter of " + CLASS_NAME; LOG.error(message); ! throw new RuntimeOperationsException (new IllegalArgumentException ("attributeNames[] cannot be null"), ! message); } ! AttributeList resultList = new AttributeList (); // if attributeNames is empty, return an empty result list --- 166,177 ---- * @see javax.management.DynamicMBean#getAttributes(java.lang.String[]) */ ! public AttributeList getAttributes(String[] attributeNames) { if (attributeNames == null) { final String message = "Cannot invoke a null getter of " + CLASS_NAME; LOG.error(message); ! throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames[] cannot be null"), ! message); } ! AttributeList resultList = new AttributeList(); // if attributeNames is empty, return an empty result list *************** *** 184,259 **** try { if (equalsProperty(attributeNames[i], ProxoolConstants.ALIAS)) { ! resultList.add (new Attribute (attributeNames[i], ! this.poolDefinition.getAlias())); } else if (equalsProperty(attributeNames[i], ProxoolConstants.DRIVER_PROPERTIES)) { ! resultList.add (new Attribute (attributeNames[i], ! getDelegatePropertiesAsString(this.poolProperties))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.DRIVER_URL)) { ! resultList.add (new Attribute (attributeNames[i], ! this.poolDefinition.getUrl ())); } else if (equalsProperty(attributeNames[i], ProxoolConstants.FATAL_SQL_EXCEPTION)) { ! resultList.add (new Attribute (attributeNames[i], ! getValueOrEmpty(this.poolProperties.getProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY)))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getHouseKeepingSleepTime ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.HOUSE_KEEPING_TEST_SQL)) { ! resultList.add (new Attribute (attributeNames[i], ! getValueOrEmpty(poolDefinition.getHouseKeepingTestSql ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TEST_BEFORE_USE)) { ! resultList.add (new Attribute (attributeNames[i], ! new Boolean (this.poolDefinition.isTestBeforeUse ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TEST_AFTER_USE)) { ! resultList.add (new Attribute (attributeNames[i], ! new Boolean (this.poolDefinition.isTestAfterUse ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_ACTIVE_TIME)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getMaximumActiveTime ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_CONNECTION_COUNT)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getMaximumConnectionCount ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getMaximumConnectionLifetime ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_NEW_CONNECTIONS)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getMaximumNewConnections ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getSimultaneousBuildThrottle ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MINIMUM_CONNECTION_COUNT)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getMinimumConnectionCount ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getOverloadWithoutRefusalLifetime ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.PROTOTYPE_COUNT)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getPrototypeCount ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.RECENTLY_STARTED_THRESHOLD)) { ! resultList.add (new Attribute (attributeNames[i], ! new Integer (this.poolDefinition.getRecentlyStartedThreshold ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.STATISTICS)) { ! resultList.add (new Attribute (attributeNames[i], ! getValueOrEmpty(this.poolDefinition.getStatistics ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.STATISTICS_LOG_LEVEL)) { ! resultList.add (new Attribute (attributeNames[i], ! getValueOrEmpty(this.poolDefinition.getStatisticsLogLevel ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TRACE)) { ! resultList.add (new Attribute (attributeNames[i], ! new Boolean (this.poolDefinition.isTrace ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.VERBOSE)) { ! resultList.add (new Attribute (attributeNames[i], ! new Boolean (this.poolDefinition.isVerbose ()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS)) { ! resultList.add (new Attribute (attributeNames[i], ! this.poolDefinition.getFatalSqlExceptionWrapper())); } else { final String message = "Unknown attribute: " + attributeNames[i]; LOG.error(message); ! throw new AttributeNotFoundException (); } } catch (AttributeNotFoundException e) { ! throw new RuntimeOperationsException (new IllegalArgumentException (e.getMessage ())); } } --- 184,259 ---- try { if (equalsProperty(attributeNames[i], ProxoolConstants.ALIAS)) { ! resultList.add(new Attribute(attributeNames[i], ! this.poolDefinition.getAlias())); } else if (equalsProperty(attributeNames[i], ProxoolConstants.DRIVER_PROPERTIES)) { ! resultList.add(new Attribute(attributeNames[i], ! getDelegatePropertiesAsString(this.poolProperties))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.DRIVER_URL)) { ! resultList.add(new Attribute(attributeNames[i], ! this.poolDefinition.getUrl())); } else if (equalsProperty(attributeNames[i], ProxoolConstants.FATAL_SQL_EXCEPTION)) { ! resultList.add(new Attribute(attributeNames[i], ! getValueOrEmpty(this.poolProperties.getProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY)))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getHouseKeepingSleepTime()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.HOUSE_KEEPING_TEST_SQL)) { ! resultList.add(new Attribute(attributeNames[i], ! getValueOrEmpty(poolDefinition.getHouseKeepingTestSql()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TEST_BEFORE_USE)) { ! resultList.add(new Attribute(attributeNames[i], ! new Boolean(this.poolDefinition.isTestBeforeUse()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TEST_AFTER_USE)) { ! resultList.add(new Attribute(attributeNames[i], ! new Boolean(this.poolDefinition.isTestAfterUse()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_ACTIVE_TIME)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getMaximumActiveTime()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_CONNECTION_COUNT)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getMaximumConnectionCount()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getMaximumConnectionLifetime()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MAXIMUM_NEW_CONNECTIONS)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getMaximumNewConnections()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getSimultaneousBuildThrottle()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.MINIMUM_CONNECTION_COUNT)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getMinimumConnectionCount()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getOverloadWithoutRefusalLifetime()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.PROTOTYPE_COUNT)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getPrototypeCount()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.RECENTLY_STARTED_THRESHOLD)) { ! resultList.add(new Attribute(attributeNames[i], ! new Integer(this.poolDefinition.getRecentlyStartedThreshold()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.STATISTICS)) { ! resultList.add(new Attribute(attributeNames[i], ! getValueOrEmpty(this.poolDefinition.getStatistics()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.STATISTICS_LOG_LEVEL)) { ! resultList.add(new Attribute(attributeNames[i], ! getValueOrEmpty(this.poolDefinition.getStatisticsLogLevel()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.TRACE)) { ! resultList.add(new Attribute(attributeNames[i], ! new Boolean(this.poolDefinition.isTrace()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.VERBOSE)) { ! resultList.add(new Attribute(attributeNames[i], ! new Boolean(this.poolDefinition.isVerbose()))); } else if (equalsProperty(attributeNames[i], ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS)) { ! resultList.add(new Attribute(attributeNames[i], ! getValueOrEmpty(this.poolDefinition.getFatalSqlExceptionWrapper()))); } else { final String message = "Unknown attribute: " + attributeNames[i]; LOG.error(message); ! throw new AttributeNotFoundException(message); } } catch (AttributeNotFoundException e) { ! throw new RuntimeOperationsException(new IllegalArgumentException(e.getMessage())); } } *************** *** 264,278 **** * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList) */ ! public AttributeList setAttributes (AttributeList attributes) { if (attributes == null) { final String message = "AttributeList attributes cannot be null"; LOG.error(message); ! throw new RuntimeOperationsException (new IllegalArgumentException (message), ! "Cannot invoke a setter of " + CLASS_NAME); } ! AttributeList resultList = new AttributeList (); ! if (attributes.isEmpty ()) { return resultList; } --- 264,278 ---- * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList) */ ! public AttributeList setAttributes(AttributeList attributes) { if (attributes == null) { final String message = "AttributeList attributes cannot be null"; LOG.error(message); ! throw new RuntimeOperationsException(new IllegalArgumentException(message), ! "Cannot invoke a setter of " + CLASS_NAME); } ! AttributeList resultList = new AttributeList(); ! if (attributes.isEmpty()) { return resultList; } *************** *** 281,329 **** Object value = null; final Properties newProperties = new Properties(); ! for (Iterator i = attributes.iterator (); i.hasNext ();) { ! Attribute attribute = (Attribute) i.next (); try { ! name = attribute.getName (); ! value = attribute.getValue (); if (equalsProperty(name, ProxoolConstants.DRIVER_PROPERTIES)) { ! checkAssignable (name, String.class, value.getClass ()); ! setDelegateProperties(newProperties, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.DRIVER_URL)) { ! checkAssignable (name, String.class, value.getClass ()); ! if (notEmpty(value.toString())) { newProperties.setProperty(ProxoolConstants.DRIVER_URL_PROPERTY, value.toString()); } else { ! newProperties.remove(ProxoolConstants.DRIVER_URL_PROPERTY); } ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.FATAL_SQL_EXCEPTION)) { ! checkAssignable (name, String.class, value.getClass ()); ! if (notEmpty(value.toString())) { ! newProperties.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, value.toString()); ! } else { ! newProperties.remove(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY); } - resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME)) { setIntegerAttribute(name, ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_HOUSE_KEEPING_SLEEP_TIME, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.HOUSE_KEEPING_TEST_SQL)) { ! checkAssignable (name, String.class, value.getClass ()); ! if (notEmpty(value.toString())) { newProperties.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, value.toString()); } else { ! newProperties.remove(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY); } ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.TEST_BEFORE_USE)) { ! checkAssignable (name, Boolean.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.TEST_BEFORE_USE_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.TEST_AFTER_USE)) { ! checkAssignable (name, Boolean.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.TEST_AFTER_USE_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.MAXIMUM_ACTIVE_TIME)) { setIntegerAttribute(name, ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY, value, --- 281,335 ---- Object value = null; final Properties newProperties = new Properties(); ! Attribute attribute = null; ! for (Iterator i = attributes.iterator(); i.hasNext();) { ! attribute = (Attribute) i.next(); try { ! name = attribute.getName(); ! value = attribute.getValue(); if (equalsProperty(name, ProxoolConstants.DRIVER_PROPERTIES)) { ! if (!isEqualProperties(value.toString(), getDelegatePropertiesAsString(this.poolProperties))) { ! checkAssignable(name, String.class, value); ! setDelegateProperties(newProperties, value.toString()); ! resultList.add(new Attribute(name, value)); ! } } else if (equalsProperty(name, ProxoolConstants.DRIVER_URL)) { ! checkAssignable(name, String.class, value); ! if (notEmpty(value)) { newProperties.setProperty(ProxoolConstants.DRIVER_URL_PROPERTY, value.toString()); } else { ! newProperties.setProperty(ProxoolConstants.DRIVER_URL_PROPERTY, ""); } ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.FATAL_SQL_EXCEPTION)) { ! if (!isEqualProperties(value.toString(), ! this.poolProperties.getProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY))) { ! checkAssignable(name, String.class, value); ! if (notEmpty(value)) { ! newProperties.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, value.toString()); ! } else { ! newProperties.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, ""); ! } ! resultList.add(new Attribute(name, value)); } } else if (equalsProperty(name, ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME)) { setIntegerAttribute(name, ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_HOUSE_KEEPING_SLEEP_TIME, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.HOUSE_KEEPING_TEST_SQL)) { ! checkAssignable(name, String.class, value); ! if (notEmpty(value)) { newProperties.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, value.toString()); } else { ! newProperties.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, ""); } ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.TEST_BEFORE_USE)) { ! checkAssignable(name, Boolean.class, value); newProperties.setProperty(ProxoolConstants.TEST_BEFORE_USE_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.TEST_AFTER_USE)) { ! checkAssignable(name, Boolean.class, value); newProperties.setProperty(ProxoolConstants.TEST_AFTER_USE_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.MAXIMUM_ACTIVE_TIME)) { setIntegerAttribute(name, ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY, value, *************** *** 342,397 **** ConnectionPoolDefinitionIF.DEFAULT_SIMULTANEOUS_BUILD_THROTTLE, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.MINIMUM_CONNECTION_COUNT)) { ! checkAssignable (name, Integer.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME)) { setIntegerAttribute(name, ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_OVERLOAD_WITHOUT_REFUSAL_THRESHOLD, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.PROTOTYPE_COUNT)) { ! checkAssignable (name, Integer.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.RECENTLY_STARTED_THRESHOLD)) { setIntegerAttribute(name, ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_RECENTLY_STARTED_THRESHOLD, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.STATISTICS)) { ! checkAssignable (name, String.class, value.getClass ()); ! if (notEmpty(value.toString())) { newProperties.setProperty(ProxoolConstants.STATISTICS_PROPERTY, value.toString()); } else { ! newProperties.remove(ProxoolConstants.STATISTICS_PROPERTY); } ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.STATISTICS_LOG_LEVEL)) { ! checkAssignable (name, String.class, value.getClass ()); ! if (notEmpty(value.toString())) { newProperties.setProperty(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY, value.toString()); } else { ! newProperties.remove(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY); } ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.TRACE)) { ! checkAssignable (name, Boolean.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.TRACE_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.VERBOSE)) { ! checkAssignable (name, Boolean.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.VERBOSE_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else if (equalsProperty(name, ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS)) { ! checkAssignable (name, Boolean.class, value.getClass ()); newProperties.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, value.toString()); ! resultList.add (new Attribute (name, value)); } else { final String message = "Unknown attribute: " + name; LOG.error(message); ! throw new AttributeNotFoundException (message); } } catch (InvalidAttributeValueException e) { ! final String message = "Attribute value was illegal: " + e.getMessage (); LOG.error(message); ! throw new RuntimeOperationsException (new RuntimeException (message)); } catch (AttributeNotFoundException e) { ! throw new RuntimeOperationsException (new IllegalArgumentException (e.getMessage ())); } } --- 348,403 ---- ConnectionPoolDefinitionIF.DEFAULT_SIMULTANEOUS_BUILD_THROTTLE, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.MINIMUM_CONNECTION_COUNT)) { ! checkAssignable(name, Integer.class, value); newProperties.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME)) { setIntegerAttribute(name, ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_OVERLOAD_WITHOUT_REFUSAL_THRESHOLD, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.PROTOTYPE_COUNT)) { ! checkAssignable(name, Integer.class, value); newProperties.setProperty(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.RECENTLY_STARTED_THRESHOLD)) { setIntegerAttribute(name, ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY, value, ConnectionPoolDefinitionIF.DEFAULT_RECENTLY_STARTED_THRESHOLD, newProperties, resultList); } else if (equalsProperty(name, ProxoolConstants.STATISTICS)) { ! checkAssignable(name, String.class, value); ! if (notEmpty(value)) { newProperties.setProperty(ProxoolConstants.STATISTICS_PROPERTY, value.toString()); } else { ! newProperties.setProperty(ProxoolConstants.STATISTICS_PROPERTY, ""); } ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.STATISTICS_LOG_LEVEL)) { ! checkAssignable(name, String.class, value); ! if (notEmpty(value)) { newProperties.setProperty(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY, value.toString()); } else { ! newProperties.setProperty(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY, ""); } ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.TRACE)) { ! checkAssignable(name, Boolean.class, value); newProperties.setProperty(ProxoolConstants.TRACE_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.VERBOSE)) { ! checkAssignable(name, Boolean.class, value); newProperties.setProperty(ProxoolConstants.VERBOSE_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else if (equalsProperty(name, ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS)) { ! checkAssignable(name, Boolean.class, value); newProperties.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY, value.toString()); ! resultList.add(new Attribute(name, value)); } else { final String message = "Unknown attribute: " + name; LOG.error(message); ! throw new AttributeNotFoundException(message); } } catch (InvalidAttributeValueException e) { ! final String message = "Attribute value was illegal: " + e.getMessage(); LOG.error(message); ! throw new RuntimeOperationsException(new RuntimeException(message)); } catch (AttributeNotFoundException e) { ! throw new RuntimeOperationsException(new IllegalArgumentException(e.getMessage())); } } *************** *** 408,414 **** * @see javax.management.DynamicMBean#invoke(java.lang.String, java.lang.Object[], java.lang.String[]) */ ! public Object invoke (String operationName, Object params[], String signature[]) throws MBeanException, ReflectionException { if (operationName == null) { ! throw new RuntimeOperationsException (new IllegalArgumentException ("Operation name cannot be null"), "Cannot invoke a null operation in " + CLASS_NAME); } else if (operationName.equals(OPERATION_NAME_SHUTDOWN)) { try { --- 414,420 ---- * @see javax.management.DynamicMBean#invoke(java.lang.String, java.lang.Object[], java.lang.String[]) */ ! public Object invoke(String operationName, Object params[], String signature[]) throws MBeanException, ReflectionException { if (operationName == null) { ! throw new RuntimeOperationsException(new IllegalArgumentException("Operation name cannot be null"), "Cannot invoke a null operation in " + CLASS_NAME); } else if (operationName.equals(OPERATION_NAME_SHUTDOWN)) { try { *************** *** 420,424 **** } else { throw new ReflectionException(new NoSuchMethodException(operationName), ! "Cannot find the operation " + operationName + "."); } } --- 426,430 ---- } else { throw new ReflectionException(new NoSuchMethodException(operationName), ! "Cannot find the operation " + operationName + "."); } } *************** *** 427,479 **** * @see javax.management.DynamicMBean#getMBeanInfo() */ ! public MBeanInfo getMBeanInfo () { return mBeanInfo; } ! private MBeanInfo getDynamicMBeanInfo (String alias) { final MBeanAttributeInfo[] attributeInfos = new MBeanAttributeInfo[]{ ! createProxoolAttribute (ProxoolConstants.ALIAS, String.class, false), ! createProxoolAttribute (ProxoolConstants.DRIVER_PROPERTIES, String.class), ! createProxoolAttribute (ProxoolConstants.DRIVER_URL, String.class), ! createProxoolAttribute (ProxoolConstants.FATAL_SQL_EXCEPTION, String.class), ! createProxoolAttribute (ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME, Integer.class), ! createProxoolAttribute (ProxoolConstants.HOUSE_KEEPING_TEST_SQL, String.class), ! createProxoolAttribute (ProxoolConstants.TEST_BEFORE_USE, Boolean.class), ! createProxoolAttribute (ProxoolConstants.TEST_AFTER_USE, Boolean.class), ! createProxoolAttribute (ProxoolConstants.MAXIMUM_ACTIVE_TIME, Integer.class), ! createProxoolAttribute (ProxoolConstants.MAXIMUM_CONNECTION_COUNT, Integer.class), ! createProxoolAttribute (ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME, Integer.class), ! createProxoolAttribute (ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE, Integer.class), ! createProxoolAttribute (ProxoolConstants.MINIMUM_CONNECTION_COUNT, Integer.class), ! createProxoolAttribute (ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME, Integer.class), ! createProxoolAttribute (ProxoolConstants.PROTOTYPE_COUNT, Integer.class), ! createProxoolAttribute (ProxoolConstants.RECENTLY_STARTED_THRESHOLD, Integer.class), ! createProxoolAttribute (ProxoolConstants.STATISTICS, String.class), ! createProxoolAttribute (ProxoolConstants.STATISTICS_LOG_LEVEL, String.class), ! createProxoolAttribute (ProxoolConstants.TRACE, Boolean.class), ! createProxoolAttribute (ProxoolConstants.VERBOSE, Boolean.class), ! createProxoolAttribute (ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS, String.class), }; final MBeanConstructorInfo[] constructorInfos = new MBeanConstructorInfo[]{ ! new MBeanConstructorInfo ("ConnectionPoolMBean(): Construct a ConnectionPoolMBean object.", ConnectionPoolMBean.class.getConstructors ()[0]) }; final MBeanOperationInfo[] operationInfos = new MBeanOperationInfo[]{ ! new MBeanOperationInfo (OPERATION_NAME_SHUTDOWN, "Stop and dispose this connection pool.", ! new MBeanParameterInfo[]{}, "void", MBeanOperationInfo.ACTION) }; ! return new MBeanInfo (CLASS_NAME, MessageFormat.format (getJMXText (RECOURCE_NAME_MBEAN_POOL_DESCRIPTION), ! new Object[]{alias}), attributeInfos, constructorInfos, operationInfos, new MBeanNotificationInfo[0]); } ! private static String getAttributeDescription (String attributeName) { String description = ""; if (ATTRIBUTE_DESCRIPTIONS_RESOURCE != null) { try { ! description = ATTRIBUTE_DESCRIPTIONS_RESOURCE.getString (attributeName); } catch (Exception e) { ! LOG.warn ("Could not get description for attribute '" + attributeName + "' from resource " + ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS + "."); } } --- 433,485 ---- * @see javax.management.DynamicMBean#getMBeanInfo() */ ! public MBeanInfo getMBeanInfo() { return mBeanInfo; } ! private MBeanInfo getDynamicMBeanInfo(String alias) { final MBeanAttributeInfo[] attributeInfos = new MBeanAttributeInfo[]{ ! createProxoolAttribute(ProxoolConstants.ALIAS, String.class, false), ! createProxoolAttribute(ProxoolConstants.DRIVER_PROPERTIES, String.class), ! createProxoolAttribute(ProxoolConstants.DRIVER_URL, String.class), ! createProxoolAttribute(ProxoolConstants.FATAL_SQL_EXCEPTION, String.class), ! createProxoolAttribute(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME, Integer.class), ! createProxoolAttribute(ProxoolConstants.HOUSE_KEEPING_TEST_SQL, String.class), ! createProxoolAttribute(ProxoolConstants.TEST_BEFORE_USE, Boolean.class), ! createProxoolAttribute(ProxoolConstants.TEST_AFTER_USE, Boolean.class), ! createProxoolAttribute(ProxoolConstants.MAXIMUM_ACTIVE_TIME, Integer.class), ! createProxoolAttribute(ProxoolConstants.MAXIMUM_CONNECTION_COUNT, Integer.class), ! createProxoolAttribute(ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME, Integer.class), ! createProxoolAttribute(ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE, Integer.class), ! createProxoolAttribute(ProxoolConstants.MINIMUM_CONNECTION_COUNT, Integer.class), ! createProxoolAttribute(ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME, Integer.class), ! createProxoolAttribute(ProxoolConstants.PROTOTYPE_COUNT, Integer.class), ! createProxoolAttribute(ProxoolConstants.RECENTLY_STARTED_THRESHOLD, Integer.class), ! createProxoolAttribute(ProxoolConstants.STATISTICS, String.class), ! createProxoolAttribute(ProxoolConstants.STATISTICS_LOG_LEVEL, String.class), ! createProxoolAttribute(ProxoolConstants.TRACE, Boolean.class), ! createProxoolAttribute(ProxoolConstants.VERBOSE, Boolean.class), ! createProxoolAttribute(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS, String.class), }; final MBeanConstructorInfo[] constructorInfos = new MBeanConstructorInfo[]{ ! new MBeanConstructorInfo("ConnectionPoolMBean(): Construct a ConnectionPoolMBean object.", ConnectionPoolMBean.class.getConstructors()[0]) }; final MBeanOperationInfo[] operationInfos = new MBeanOperationInfo[]{ ! new MBeanOperationInfo(OPERATION_NAME_SHUTDOWN, "Stop and dispose this connection pool.", ! new MBeanParameterInfo[]{}, "void", MBeanOperationInfo.ACTION) }; ! return new MBeanInfo(CLASS_NAME, MessageFormat.format(getJMXText(RECOURCE_NAME_MBEAN_POOL_DESCRIPTION), ! new Object[]{alias}), attributeInfos, constructorInfos, operationInfos, new MBeanNotificationInfo[0]); } ! private static String getAttributeDescription(String attributeName) { String description = ""; if (ATTRIBUTE_DESCRIPTIONS_RESOURCE != null) { try { ! description = ATTRIBUTE_DESCRIPTIONS_RESOURCE.getString(attributeName); } catch (Exception e) { ! LOG.warn("Could not get description for attribute '" + attributeName + "' from resource " + ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS + "."); } } *************** *** 481,491 **** } ! private static String getJMXText (String key) { String value = ""; if (JMX_RESOURCE != null) { try { ! value = JMX_RESOURCE.getString (key); } catch (Exception e) { ! LOG.warn ("Could not get value for attribute '" + key + "' from resource " + ResourceNamesIF.JMX + "."); } } --- 487,497 ---- } ! private static String getJMXText(String key) { String value = ""; if (JMX_RESOURCE != null) { try { ! value = JMX_RESOURCE.getString(key); } catch (Exception e) { ! LOG.warn("Could not get value for attribute '" + key + "' from resource " + ResourceNamesIF.JMX + "."); } } *************** *** 493,527 **** } ! private static ResourceBundle createAttributeDescriptionsResource () { try { ! return ResourceBundle.getBundle (ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS); } catch (Exception e) { ! LOG.error ("Could not find resource " + ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS, e); } return null; } ! private static ResourceBundle createJMXResource () { try { ! return ResourceBundle.getBundle (ResourceNamesIF.JMX); } catch (Exception e) { ! LOG.error ("Could not find resource " + ResourceNamesIF.JMX, e); } return null; } ! private static MBeanAttributeInfo createProxoolAttribute (String attributeName, Class type) { return createProxoolAttribute(attributeName, type, true); } ! private static MBeanAttributeInfo createProxoolAttribute (String attributeName, Class type, boolean writable) { ! return new MBeanAttributeInfo (ProxoolJMXHelper.getValidIdentifier(attributeName), type.getName (), ! getAttributeDescription (attributeName), true, writable, false); } ! private void checkAssignable (String name, Class class1, Class class2) throws InvalidAttributeValueException { ! if (!class1.isAssignableFrom (class2)) { ! throw(new InvalidAttributeValueException ("Cannot set attribute " + name + " to a " + class2.getName () ! + " object, " + class1.getName () + " expected.")); } } --- 499,541 ---- } ! private static ResourceBundle createAttributeDescriptionsResource() { try { ! return ResourceBundle.getBundle(ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS); } catch (Exception e) { ! LOG.error("Could not find resource " + ResourceNamesIF.ATTRIBUTE_DESCRIPTIONS, e); } return null; } ! private static ResourceBundle createJMXResource() { try { ! return ResourceBundle.getBundle(ResourceNamesIF.JMX); } catch (Exception e) { ! LOG.error("Could not find resource " + ResourceNamesIF.JMX, e); } return null; } ! private static MBeanAttributeInfo createProxoolAttribute(String attributeName, Class type) { return createProxoolAttribute(attributeName, type, true); } ! private static MBeanAttributeInfo createProxoolAttribute(String attributeName, Class type, boolean writable) { ! return new MBeanAttributeInfo(ProxoolJMXHelper.getValidIdentifier(attributeName), type.getName(), ! getAttributeDescription(attributeName), true, writable, false); } ! private void checkAssignable(String name, Class clazz, Object value) throws InvalidAttributeValueException { ! if (value == null) { ! if (!String.class.equals(clazz)) { ! throw(new InvalidAttributeValueException("Cannot set attribute " + name + " to null " ! + " an instance of " + clazz.getName() + " expected.")); ! } ! } else { ! Class valueClass = value.getClass(); ! if (!clazz.isAssignableFrom(valueClass)) { ! throw(new InvalidAttributeValueException("Cannot set attribute " + name + " to a " + valueClass.getName() ! + " instance, " + clazz.getName() + " expected.")); ! } } } *************** *** 532,536 **** private void setDelegateProperties(Properties properties, String propertyString) ! throws InvalidAttributeValueException { if (propertyString == null || propertyString.trim().length() == 0) { return; --- 546,550 ---- private void setDelegateProperties(Properties properties, String propertyString) ! throws InvalidAttributeValueException { if (propertyString == null || propertyString.trim().length() == 0) { return; *************** *** 544,551 **** if (equalsIndex != -1) { properties.put(keyValuePair.substring(0, equalsIndex).trim(), ! keyValuePair.substring(equalsIndex + 1).trim()); } else { throw new InvalidAttributeValueException("Could not find key/value delimiter '=' in property definition: '" ! + keyValuePair + "'."); } } --- 558,565 ---- if (equalsIndex != -1) { properties.put(keyValuePair.substring(0, equalsIndex).trim(), ! keyValuePair.substring(equalsIndex + 1).trim()); } else { throw new InvalidAttributeValueException("Could not find key/value delimiter '=' in property definition: '" ! + keyValuePair + "'."); } } *************** *** 571,576 **** } ! private boolean notEmpty(String string) { ! return string != null && string.trim().length() > 0; } --- 585,590 ---- } ! private boolean notEmpty(Object object) { ! return object != null && object.toString().trim().length() > 0; } *************** *** 584,602 **** private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties, ! AttributeList resultList) throws InvalidAttributeValueException { ! checkAssignable (attributeName, Integer.class, value.getClass ()); if (notEmptyOrZero((Integer) value)) { properties.setProperty(propertyName, value.toString()); ! resultList.add (new Attribute (attributeName, value)); } else { ! resultList.add (new Attribute (attributeName, ! new Integer(defaultValue))); } } private static MBeanNotificationInfo[] getNotificationInfos() { ! return new MBeanNotificationInfo[] { new MBeanNotificationInfo( ! new String[]{NOTIFICATION_TYPE_DEFINITION_UPDATED}, Notification.class.getName(), getJMXText(RECOURCE_NAME_MBEAN_NOTIFICATION_DESCRIPTION)) }; } --- 598,626 ---- private void setIntegerAttribute(String attributeName, String propertyName, Object value, int defaultValue, Properties properties, ! AttributeList resultList) throws InvalidAttributeValueException { ! checkAssignable(attributeName, Integer.class, value); if (notEmptyOrZero((Integer) value)) { properties.setProperty(propertyName, value.toString()); ! resultList.add(new Attribute(attributeName, value)); } else { ! resultList.add(new Attribute(attributeName, ! new Integer(defaultValue))); ! } ! } ! ! private boolean isEqualProperties(String property1, String property2) { ! if (property1 == null) { ! return property2 == null; ! } else if (property2 == null) { ! return property1 == null; ! } else { ! return property1.equals(property2); } } private static MBeanNotificationInfo[] getNotificationInfos() { ! return new MBeanNotificationInfo[]{ new MBeanNotificationInfo( ! new String[]{NOTIFICATION_TYPE_DEFINITION_UPDATED}, Notification.class.getName(), getJMXText(RECOURCE_NAME_MBEAN_NOTIFICATION_DESCRIPTION)) }; } *************** *** 631,640 **** */ public void definitionUpdated(ConnectionPoolDefinitionIF connectionPoolDefinition, Properties completeInfo, ! Properties changedInfo) { this.poolDefinition = connectionPoolDefinition; this.poolProperties = completeInfo; this.notificationHelper.sendNotification(new Notification(NOTIFICATION_TYPE_DEFINITION_UPDATED, this, ! definitionUpdatedSequence++, System.currentTimeMillis(), ! getJMXText(RECOURCE_NAME_MBEAN_NOTIFICATION_DEF_UPDATED))); } --- 655,664 ---- */ public void definitionUpdated(ConnectionPoolDefinitionIF connectionPoolDefinition, Properties completeInfo, ! Properties changedInfo) { this.poolDefinition = connectionPoolDefinition; this.poolProperties = completeInfo; this.notificationHelper.sendNotification(new Notification(NOTIFICATION_TYPE_DEFINITION_UPDATED, this, ! definitionUpdatedSequence++, System.currentTimeMillis(), ! getJMXText(RECOURCE_NAME_MBEAN_NOTIFICATION_DEF_UPDATED))); } *************** *** 643,647 **** */ public void addNotificationListener(NotificationListener notificationListener, NotificationFilter notificationFilter, ! Object handBack) throws IllegalArgumentException { this.notificationHelper.addNotificationListener(notificationListener, notificationFilter, handBack); } --- 667,671 ---- */ public void addNotificationListener(NotificationListener notificationListener, NotificationFilter notificationFilter, ! Object handBack) throws IllegalArgumentException { this.notificationHelper.addNotificationListener(notificationListener, notificationFilter, handBack); } *************** *** 667,671 **** if (objectName == null) { throw new ProxoolException("objectName was null, but we can not construct an MBean instance without knowing" ! + " the pool alias."); } return objectName; --- 691,695 ---- if (objectName == null) { throw new ProxoolException("objectName was null, but we can not construct an MBean instance without knowing" ! + " the pool alias."); } return objectName; *************** *** 698,701 **** --- 722,728 ---- Revision history: $Log$ + Revision 1.14 2003/10/20 07:37:07 chr32 + Bettered handling of empty values. Now not setting attributes that has not changed. + Revision 1.13 2003/09/30 18:38:27 billhorsman New properties |
From: <ch...@us...> - 2003-10-20 07:42:06
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/logging/impl In directory sc8-pr-cvs1:/tmp/cvs-serv10133 Modified Files: Log4JCategoryLog.java Log Message: Style fix. Index: Log4JCategoryLog.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/logging/impl/Log4JCategoryLog.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Log4JCategoryLog.java 10 Sep 2003 23:05:10 -0000 1.4 --- Log4JCategoryLog.java 20 Oct 2003 07:42:03 -0000 1.5 *************** *** 62,67 **** package org.logicalcobwebs.logging.impl; - import org.apache.log4j.*; import org.logicalcobwebs.logging.Log; import java.util.Enumeration; --- 62,71 ---- package org.logicalcobwebs.logging.impl; import org.logicalcobwebs.logging.Log; + import org.apache.log4j.Category; + import org.apache.log4j.ConsoleAppender; + import org.apache.log4j.PatternLayout; + import org.apache.log4j.Level; + import org.apache.log4j.Priority; import java.util.Enumeration; |
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/admin/jmx In directory sc8-pr-cvs1:/tmp/cvs-serv9984 Modified Files: AllTests.java ConnectionPoolMBeanTest.java Added Files: AbstractJMXTest.java MultipleAgentsConnectionPoolMBeanTest.java Log Message: Improved tests. --- NEW FILE: AbstractJMXTest.java --- package org.logicalcobwebs.proxool.admin.jmx; import java.util.Properties; import java.sql.SQLException; import java.sql.DriverManager; import org.logicalcobwebs.proxool.AbstractProxoolTest; import org.logicalcobwebs.proxool.TestHelper; import org.logicalcobwebs.proxool.TestConstants; import org.logicalcobwebs.proxool.ProxoolConstants; /** * Parent class for the JMX tests. * * @version $Revision: 1.1 $, $Date: 2003/10/20 07:40:44 $ * @author Christian Nedregaard (chr...@em...) * @author $Author: chr32 $ (current maintainer) * @since Proxool 0.8 */ public class AbstractJMXTest extends AbstractProxoolTest { /** * @see junit.framework.TestCase#TestCase(java.lang.String) */ public AbstractJMXTest(String alias) { super(alias); } /** * Create a very basic Proxool pool. * @param alias the alias of the pool * @return the properties used to create the pool. * @throws SQLException if the pool creation fails. */ protected Properties createBasicPool(String alias) throws SQLException { final String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, TestConstants.HYPERSONIC_TEST_URL); final Properties info = createBasicProperties(alias); DriverManager.getConnection(url, info).close(); return info; } /** * Create some very basic Proxool configuration. * @param alias the alias of the pool to be configured. * @return the created properties. */ protected Properties createBasicProperties(String alias) { final Properties info = new Properties(); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); info.setProperty(ProxoolConstants.JMX_PROPERTY, Boolean.TRUE.toString()); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, alias); return info; } } --- NEW FILE: MultipleAgentsConnectionPoolMBeanTest.java --- /* * This software is released under a licence similar to the Apache Software Licence. * See org.logicalcobwebs.proxool.package.html for details. * The latest version is available at http://proxool.sourceforge.net */ package org.logicalcobwebs.proxool.admin.jmx; import org.logicalcobwebs.proxool.ProxoolConstants; import org.logicalcobwebs.proxool.ProxoolDriver; import org.logicalcobwebs.proxool.TestConstants; import org.logicalcobwebs.proxool.TestHelper; import org.logicalcobwebs.proxool.ProxoolFacade; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; /** * Test {@link org.logicalcobwebs.proxool.admin.jmx.ConnectionPoolMBean} when JMX is configured for multiple agents. * * @version $Revision: 1.1 $, $Date: 2003/10/20 07:40:44 $ * @author Christian Nedregaard (chr...@em...) * @author $Author: chr32 $ (current maintainer) * @since Proxool 0.8 */ public class MultipleAgentsConnectionPoolMBeanTest extends AbstractJMXTest { private static final String AGENT1_DOMAIN = "testAgent1"; private static final String AGENT2_DOMAIN = "testAgent2"; private MBeanServer mBeanServer1; private MBeanServer mBeanServer2; private String mBeanServer1Id; private String mBeanServer2Id; /** * @see junit.framework.TestCase#TestCase(java.lang.String) */ public MultipleAgentsConnectionPoolMBeanTest(String s) { super(s); } /** * Test that pools can be regisered for multiple agents. * @throws Exception if the test fails in an unexpected way. */ public void testMultipleAgents() throws Exception { final String alias = "testMultipleAgents"; createMutipleAgentBasicPool(alias); final ObjectName objectName = ProxoolJMXHelper.getObjectName(alias); final String fatalSQLAttributeName = ProxoolJMXHelper.getValidIdentifier(ProxoolConstants.FATAL_SQL_EXCEPTION); String fatalSQLAttribtueValue = (String) mBeanServer1.getAttribute(objectName, fatalSQLAttributeName); assertTrue("Agent " + AGENT1_DOMAIN + " could not find " + fatalSQLAttribtueValue + " attribute.", fatalSQLAttribtueValue != null && fatalSQLAttribtueValue.trim().length() > 0); fatalSQLAttribtueValue = (String) mBeanServer2.getAttribute(objectName, fatalSQLAttributeName); assertTrue("Agent " + AGENT2_DOMAIN + " could not find " + fatalSQLAttribtueValue + " attribute.", fatalSQLAttribtueValue != null && fatalSQLAttribtueValue.trim().length() > 0); ProxoolFacade.removeConnectionPool(alias); } private Properties createMutipleAgentBasicPool(String alias) throws SQLException { final String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, TestConstants.HYPERSONIC_TEST_URL); final Properties info = createBasicProperties(alias); info.setProperty(ProxoolConstants.JMX_AGENT_PROPERTY, mBeanServer1Id + ", " + mBeanServer2Id); DriverManager.getConnection(url, info).close(); return info; } /** * Calls {@link org.logicalcobwebs.proxool.AbstractProxoolTest#setUp} * @see junit.framework.TestCase#setUp */ protected void setUp() throws Exception { Class.forName(ProxoolDriver.class.getName()); this.mBeanServer1 = MBeanServerFactory.createMBeanServer(AGENT1_DOMAIN); this.mBeanServer1Id = this.mBeanServer1.getAttribute( new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId").toString(); this.mBeanServer2 = MBeanServerFactory.createMBeanServer(AGENT2_DOMAIN); this.mBeanServer2Id = this.mBeanServer2.getAttribute( new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId").toString(); super.setUp(); } /** * Calls {@link org.logicalcobwebs.proxool.AbstractProxoolTest#tearDown} * @see junit.framework.TestCase#setUp */ protected void tearDown() throws Exception { MBeanServerFactory.releaseMBeanServer(this.mBeanServer1); MBeanServerFactory.releaseMBeanServer(this.mBeanServer2); this.mBeanServer1 = null; this.mBeanServer2 = null; super.tearDown(); } } /* Revision history: $Log: MultipleAgentsConnectionPoolMBeanTest.java,v $ Revision 1.1 2003/10/20 07:40:44 chr32 Improved tests. */ Index: AllTests.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/admin/jmx/AllTests.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AllTests.java 6 May 2003 23:17:12 -0000 1.4 --- AllTests.java 20 Oct 2003 07:40:44 -0000 1.5 *************** *** 28,31 **** --- 28,32 ---- TestSuite suite = new TestSuite(); suite.addTestSuite(ConnectionPoolMBeanTest.class); + suite.addTestSuite(MultipleAgentsConnectionPoolMBeanTest.class); // create a wrapper for global initialization code. *************** *** 43,46 **** --- 44,50 ---- Revision history: $Log$ + Revision 1.5 2003/10/20 07:40:44 chr32 + Improved tests. + Revision 1.4 2003/05/06 23:17:12 chr32 Moving JMX tests back in from sandbox. Index: ConnectionPoolMBeanTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/admin/jmx/ConnectionPoolMBeanTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ConnectionPoolMBeanTest.java 6 May 2003 23:17:12 -0000 1.9 --- ConnectionPoolMBeanTest.java 20 Oct 2003 07:40:44 -0000 1.10 *************** *** 6,16 **** package org.logicalcobwebs.proxool.admin.jmx; - import org.logicalcobwebs.proxool.AbstractProxoolTest; import org.logicalcobwebs.proxool.ProxoolConstants; import org.logicalcobwebs.proxool.ProxoolDriver; import org.logicalcobwebs.proxool.ProxoolException; import org.logicalcobwebs.proxool.ProxoolFacade; - import org.logicalcobwebs.proxool.TestConstants; - import org.logicalcobwebs.proxool.TestHelper; import javax.management.Attribute; --- 6,13 ---- *************** *** 23,28 **** import javax.management.NotificationListener; import javax.management.ObjectName; - import java.sql.DriverManager; - import java.sql.SQLException; import java.util.Iterator; import java.util.Properties; --- 20,23 ---- *************** *** 37,41 **** * @since Proxool 0.8 */ ! public class ConnectionPoolMBeanTest extends AbstractProxoolTest { private MBeanServer mBeanServer; private boolean notified; --- 32,36 ---- * @since Proxool 0.8 */ ! public class ConnectionPoolMBeanTest extends AbstractJMXTest { private MBeanServer mBeanServer; private boolean notified; *************** *** 109,113 **** this.mBeanServer.setAttribute(objectName, new Attribute(fatalSQLAttributeName, newValue)); ! final String fatalSQLAttribtueValue = (String) mBeanServer.getAttribute(objectName, fatalSQLAttributeName); // check that value vas registered by the bean. assertTrue("Expexted fatalSQLException JMX attribtue to have value '" + newValue + "' but the value was '" --- 104,108 ---- this.mBeanServer.setAttribute(objectName, new Attribute(fatalSQLAttributeName, newValue)); ! String fatalSQLAttribtueValue = (String) mBeanServer.getAttribute(objectName, fatalSQLAttributeName); // check that value vas registered by the bean. assertTrue("Expexted fatalSQLException JMX attribtue to have value '" + newValue + "' but the value was '" *************** *** 120,123 **** --- 115,124 ---- + newValue + "' but the value was '" + proxoolProopertyValue + "'.", proxoolProopertyValue.equals(newValue)); + // check that string properites can be deleted. + this.mBeanServer.setAttribute(objectName, + new Attribute(fatalSQLAttributeName, "")); + fatalSQLAttribtueValue = (String) mBeanServer.getAttribute(objectName, fatalSQLAttributeName); + assertTrue("Expexted fatal-sql-exception Proxool property to be empty " + + " but the value was '" + fatalSQLAttribtueValue + "'.", "".equals(fatalSQLAttribtueValue)); ProxoolFacade.removeConnectionPool(alias); } *************** *** 165,169 **** try { ProxoolFacade.removeConnectionPool(alias); ! fail("Removal of pool alias should have failed, because it should have allready be removed."); } catch (ProxoolException e) { // we want this --- 166,170 ---- try { ProxoolFacade.removeConnectionPool(alias); ! fail("Removal of pool alias should have failed, because it should have already be removed."); } catch (ProxoolException e) { // we want this *************** *** 179,183 **** // test when updated through JMX. this.mBeanServer.setAttribute(objectName, ! new Attribute(ProxoolJMXHelper.getValidIdentifier(ProxoolConstants.FATAL_SQL_EXCEPTION), alias)); assertTrue("We did not get notified when updating through JMX.", this.notified); this.notified = false; --- 180,184 ---- // test when updated through JMX. this.mBeanServer.setAttribute(objectName, ! new Attribute(ProxoolJMXHelper.getValidIdentifier(ProxoolConstants.FATAL_SQL_EXCEPTION), "dingo")); assertTrue("We did not get notified when updating through JMX.", this.notified); this.notified = false; *************** *** 206,222 **** } - private Properties createBasicPool(String alias) throws SQLException { - String url = TestHelper.buildProxoolUrl(alias, - TestConstants.HYPERSONIC_DRIVER, - TestConstants.HYPERSONIC_TEST_URL); - Properties info = new Properties(); - info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); - info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); - info.setProperty(ProxoolConstants.JMX_PROPERTY, Boolean.TRUE.toString()); - info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, alias); - DriverManager.getConnection(url, info).close(); - return info; - } - /** * Calls {@link org.logicalcobwebs.proxool.AbstractProxoolTest#setUp} --- 207,210 ---- *************** *** 244,247 **** --- 232,238 ---- Revision history: $Log$ + Revision 1.10 2003/10/20 07:40:44 chr32 + Improved tests. + Revision 1.9 2003/05/06 23:17:12 chr32 Moving JMX tests back in from sandbox. |
From: <bil...@us...> - 2003-10-19 15:07:13
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv12404 Modified Files: ConnectionPoolDefinition.java Log Message: Setting a property to a zero length String actually sets it to a null Index: ConnectionPoolDefinition.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPoolDefinition.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ConnectionPoolDefinition.java 16 Oct 2003 18:54:49 -0000 1.25 --- ConnectionPoolDefinition.java 19 Oct 2003 13:31:57 -0000 1.26 *************** *** 223,226 **** --- 223,232 ---- String key = (String) i.next(); String value = info.getProperty(key); + // This allows us to set properties to a null, even though Properties + // object doesn't allow null values. It means that you can't set a property + // to be a zero length string but that's ok. + if (value != null && value.length() == 0) { + value = null; + } changed = changed | setAnyProperty(key, value, pretend); if (!pretend) { *************** *** 1129,1132 **** --- 1135,1141 ---- Revision history: $Log$ + Revision 1.26 2003/10/19 13:31:57 billhorsman + Setting a property to a zero length String actually sets it to a null + Revision 1.25 2003/10/16 18:54:49 billhorsman Fixed javadoc for update() and redefine() methods which were transposed. Also improved exception handling for |
From: <bil...@us...> - 2003-10-19 09:56:04
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv13990 Modified Files: ProxyStatement.java Log Message: Drill down into InvocationTargetException during execution debug. Index: ProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyStatement.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ProxyStatement.java 18 Oct 2003 20:44:48 -0000 1.23 --- ProxyStatement.java 19 Oct 2003 09:50:33 -0000 1.24 *************** *** 82,86 **** } } catch (InvocationTargetException e) { ! exception = e; if (testException(e.getTargetException())) { // This is really a fatal one --- 82,90 ---- } } catch (InvocationTargetException e) { ! if (e.getTargetException() instanceof Exception) { ! exception = (Exception) e.getTargetException(); ! } else { ! exception = e; ! } if (testException(e.getTargetException())) { // This is really a fatal one *************** *** 126,129 **** --- 130,136 ---- Revision history: $Log$ + Revision 1.24 2003/10/19 09:50:33 billhorsman + Drill down into InvocationTargetException during execution debug. + Revision 1.23 2003/10/18 20:44:48 billhorsman Better SQL logging (embed parameter values within SQL call) and works properly with batched statements now. |
From: <bil...@us...> - 2003-10-19 09:55:39
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv13949 Modified Files: AbstractProxyStatement.java Log Message: Debug exception displays class name. Index: AbstractProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/AbstractProxyStatement.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AbstractProxyStatement.java 18 Oct 2003 20:44:48 -0000 1.13 --- AbstractProxyStatement.java 19 Oct 2003 09:50:08 -0000 1.14 *************** *** 172,176 **** // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! connectionPool.getLog().debug(sqlLog.toString() + " (" + (System.currentTimeMillis() - startTime) + " milliseconds" + (exception != null ? ", threw " + exception.getMessage() + ")" : ")")); } --- 172,176 ---- // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! connectionPool.getLog().debug(sqlLog.toString() + " (" + (System.currentTimeMillis() - startTime) + " milliseconds" + (exception != null ? ", threw a " + exception.getClass().getName() + ": " + exception.getMessage() + ")" : ")")); } *************** *** 237,240 **** --- 237,243 ---- Revision history: $Log$ + Revision 1.14 2003/10/19 09:50:08 billhorsman + Debug exception displays class name. + Revision 1.13 2003/10/18 20:44:48 billhorsman Better SQL logging (embed parameter values within SQL call) and works properly with batched statements now. |
From: <bil...@us...> - 2003-10-18 20:50:55
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv9584 Modified Files: AbstractProxyStatement.java ProxyStatement.java Log Message: Better SQL logging (embed parameter values within SQL call) and works properly with batched statements now. Index: AbstractProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/AbstractProxyStatement.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractProxyStatement.java 30 Sep 2003 18:39:07 -0000 1.12 --- AbstractProxyStatement.java 18 Oct 2003 20:44:48 -0000 1.13 *************** *** 20,24 **** * statement. The subclass of this defines how we delegate to the * real statement. - * @version $Revision$, $Date$ * @author bill --- 20,23 ---- *************** *** 40,43 **** --- 39,44 ---- private String sqlStatement; + private StringBuffer sqlLog = new StringBuffer(); + /** * @param statement the real statement that we will delegate to *************** *** 146,150 **** Object key = new Integer(index); if (value == null) { ! parameters.put(key, "*"); } else if (value instanceof String) { parameters.put(key, "'" + value + "'"); --- 147,151 ---- Object key = new Integer(index); if (value == null) { ! parameters.put(key, "NULL"); } else if (value instanceof String) { parameters.put(key, "'" + value + "'"); *************** *** 171,183 **** // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! if (parameters != null) { ! connectionPool.getLog().debug(parameters + " -> " + sqlStatement + " (" + (System.currentTimeMillis() - startTime) + " milliseconds)"); ! } else { ! connectionPool.getLog().debug(sqlStatement + " (" + (System.currentTimeMillis() - startTime) + " milliseconds)"); ! } } // Send to any listener ! connectionPool.onExecute(parameters + " -> " + sqlStatement, (System.currentTimeMillis() - startTime), exception); // Clear parameters for next time --- 172,180 ---- // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! connectionPool.getLog().debug(sqlLog.toString() + " (" + (System.currentTimeMillis() - startTime) + " milliseconds" + (exception != null ? ", threw " + exception.getMessage() + ")" : ")")); } // Send to any listener ! connectionPool.onExecute(sqlLog.toString(), (System.currentTimeMillis() - startTime), exception); // Clear parameters for next time *************** *** 186,192 **** --- 183,220 ---- } sqlStatement = null; + sqlLog.setLength(0); } + /** + * Get the parameters that have been built up and use them to fill in any parameters + * withing the sqlStatement and produce a log. If the log already exists (for instance, + * if a batch is being peformed) then it is appended to the end. + */ + protected void appendToSqlLog() { + int parameterIndex = 0; + StringTokenizer st = new StringTokenizer(sqlStatement, "?"); + while (st.hasMoreTokens()) { + if (parameterIndex > 0) { + if (parameters != null) { + final Object value = parameters.get(new Integer(parameterIndex)); + if (value != null) { + sqlLog.append(value); + } else { + sqlLog.append("?"); + } + } else { + sqlLog.append("?"); + } + } + parameterIndex++; + sqlLog.append(st.nextToken()); + } + sqlLog.append("; "); + if (parameters != null) { + parameters.clear(); + } + } + protected boolean isTrace() { boolean isTrace = getConnectionPool().isConnectionListenedTo() || (getConnectionPool().getDefinition().isTrace() && getConnectionPool().getLog().isDebugEnabled()); *************** *** 209,212 **** --- 237,243 ---- Revision history: $Log$ + Revision 1.13 2003/10/18 20:44:48 billhorsman + Better SQL logging (embed parameter values within SQL call) and works properly with batched statements now. + Revision 1.12 2003/09/30 18:39:07 billhorsman New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. Index: ProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyStatement.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ProxyStatement.java 30 Sep 2003 18:39:08 -0000 1.22 --- ProxyStatement.java 18 Oct 2003 20:44:48 -0000 1.23 *************** *** 29,32 **** --- 29,36 ---- private static final String EXECUTE_FRAGMENT = "execute"; + private static final String EXECUTE_BATCH_METHOD = "executeBatch"; + + private static final String ADD_BATCH_METHOD = "addBatch"; + private static final String EQUALS_METHOD = "equals"; *************** *** 93,101 **** } finally { ! // If we executed something then we should tell the listener. ! if (method.getName().startsWith(EXECUTE_FRAGMENT)) { if (argCount > 0 && args[0] instanceof String) { setSqlStatementIfNull((String) args[0]); } trace(startTime, exception); } --- 97,115 ---- } finally { ! if (method.getName().equals(ADD_BATCH_METHOD)) { ! // If we have just added a batch call then we need to update the sql log if (argCount > 0 && args[0] instanceof String) { setSqlStatementIfNull((String) args[0]); } + appendToSqlLog(); + } else if (method.getName().equals(EXECUTE_BATCH_METHOD)) { + // executing a batch should do a trace + trace(startTime, exception); + } else if (method.getName().startsWith(EXECUTE_FRAGMENT)) { + // executing should update the log and do a trace + if (argCount > 0 && args[0] instanceof String) { + setSqlStatementIfNull((String) args[0]); + } + appendToSqlLog(); trace(startTime, exception); } *************** *** 112,115 **** --- 126,132 ---- Revision history: $Log$ + Revision 1.23 2003/10/18 20:44:48 billhorsman + Better SQL logging (embed parameter values within SQL call) and works properly with batched statements now. + Revision 1.22 2003/09/30 18:39:08 billhorsman New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. |
From: <bil...@us...> - 2003-10-18 20:49:40
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv9645 Modified Files: CHANGES.txt Log Message: More changes Index: CHANGES.txt =================================================================== RCS file: /cvsroot/proxool/proxool/CHANGES.txt,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** CHANGES.txt 1 Oct 2003 19:31:54 -0000 1.26 --- CHANGES.txt 18 Oct 2003 20:45:05 -0000 1.27 *************** *** 58,61 **** --- 58,76 ---- is done with a comma delimited list. + - Fix to ProxoolFacade.redefine() which was in fact doing an update instead of a + redefine. This didn't have any consequences unless you were calling this method + explicitly in your code. + + - Made the 'Attempt to use a pool with incomplete definition' exception a but more + informative. It is often because you are refering to an unregistered pool by its + alias. + + - SQL command logging (using the 'trace' property) now embeds the parameters into + the SQL (if the SQL is parametised). This means that the log is almost like a + journal - with the exception that any callable statements that return data retain + the ? (question marks) that contain the output parameters. + + - Batched statements are now correctly reported with the trace feature. + 0.7.2 - April 28, 2003 |
From: <bil...@us...> - 2003-10-16 18:55:35
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv12134 Modified Files: ConnectionPoolDefinition.java Log Message: Fixed javadoc for update() and redefine() methods which were transposed. Also improved exception handling for incomplete pool definitions. Index: ConnectionPoolDefinition.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPoolDefinition.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ConnectionPoolDefinition.java 30 Sep 2003 18:39:08 -0000 1.24 --- ConnectionPoolDefinition.java 16 Oct 2003 18:54:49 -0000 1.25 *************** *** 124,139 **** * @param info additional properties (for Proxool and the delegate * driver) * @throws ProxoolException if anything goes wrong */ ! protected ConnectionPoolDefinition(String url, Properties info) throws ProxoolException { this.alias = ProxoolFacade.getAlias(url); poolLog = LogFactory.getLog("org.logicalcobwebs.proxool." + alias); reset(); ! doChange(url, info, false); } /** ! * Redefine the definition. All existing properties are reset to their ! * default values * @param url the url that defines this pool * @param info additional properties (for Proxool and the delegate --- 124,141 ---- * @param info additional properties (for Proxool and the delegate * driver) + * @param explicitRegister set to true if we are registering a new pool explicitly, or false + * if it's just because we are serving a url that we haven't come across before * @throws ProxoolException if anything goes wrong */ ! protected ConnectionPoolDefinition(String url, Properties info, boolean explicitRegister) throws ProxoolException { this.alias = ProxoolFacade.getAlias(url); poolLog = LogFactory.getLog("org.logicalcobwebs.proxool." + alias); reset(); ! doChange(url, info, false, !explicitRegister); } /** ! * Update the definition. All existing properties are retained ! * and only overwritten if included in the info parameter * @param url the url that defines this pool * @param info additional properties (for Proxool and the delegate *************** *** 145,149 **** connectionPropertiesChanged = false; poolLog.debug("Updating definition"); ! doChange(url, info, false); if (connectionPropertiesChanged) { poolLog.info("Mercifully killing all current connections because of definition changes"); --- 147,151 ---- connectionPropertiesChanged = false; poolLog.debug("Updating definition"); ! doChange(url, info, false, false); if (connectionPropertiesChanged) { poolLog.info("Mercifully killing all current connections because of definition changes"); *************** *** 153,158 **** /** ! * Update the definition. All existing properties are retained ! * and only overwritten if included in the info parameter * @param url the url that defines this pool * @param info additional properties (for Proxool and the delegate --- 155,160 ---- /** ! * Redefine the definition. All existing properties are reset to their ! * default values * @param url the url that defines this pool * @param info additional properties (for Proxool and the delegate *************** *** 165,169 **** connectionPropertiesChanged = false; poolLog.debug("Redefining definition"); ! doChange(url, info, false); // Check for minimum information --- 167,171 ---- connectionPropertiesChanged = false; poolLog.debug("Redefining definition"); ! doChange(url, info, false, false); // Check for minimum information *************** *** 178,182 **** } ! private boolean doChange(String url, Properties info, boolean pretend) throws ProxoolException { boolean changed = false; --- 180,184 ---- } ! private boolean doChange(String url, Properties info, boolean pretend, boolean implicitRegister) throws ProxoolException { boolean changed = false; *************** *** 232,237 **** } ! if (getDriver() == null || getUrl() == null) { ! throw new ProxoolException("Attempt to use a pool with incomplete definition"); } --- 234,239 ---- } ! if ((getDriver() == null || getUrl() == null) && implicitRegister) { ! throw new ProxoolException("Attempt to refer to a unregistered pool by its alias '" + getAlias() + "'"); } *************** *** 1100,1104 **** public boolean isEqual(String url, Properties info) { try { ! return !doChange(url, info, true); } catch (ProxoolException e) { LOG.error("Problem checking equality", e); --- 1102,1106 ---- public boolean isEqual(String url, Properties info) { try { ! return !doChange(url, info, true, false); } catch (ProxoolException e) { LOG.error("Problem checking equality", e); *************** *** 1127,1130 **** --- 1129,1136 ---- Revision history: $Log$ + Revision 1.25 2003/10/16 18:54:49 billhorsman + Fixed javadoc for update() and redefine() methods which were transposed. Also improved exception handling for + incomplete pool definitions. + Revision 1.24 2003/09/30 18:39:08 billhorsman New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. |
From: <bil...@us...> - 2003-10-16 18:53:25
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv11981 Modified Files: ProxoolDriver.java Log Message: When registering a new pool on the fly, indicate that it is implicit (for exception message handling) Index: ProxoolDriver.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxoolDriver.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** ProxoolDriver.java 30 Sep 2003 18:39:08 -0000 1.25 --- ProxoolDriver.java 16 Oct 2003 18:53:21 -0000 1.26 *************** *** 75,79 **** if (!ConnectionPoolManager.getInstance().isPoolExists(alias)) { ! ProxoolFacade.registerConnectionPool(url, info); cp = ConnectionPoolManager.getInstance().getConnectionPool(alias); } else if (info != null && info.size() > 0) { --- 75,79 ---- if (!ConnectionPoolManager.getInstance().isPoolExists(alias)) { ! ProxoolFacade.registerConnectionPool(url, info, false); cp = ConnectionPoolManager.getInstance().getConnectionPool(alias); } else if (info != null && info.size() > 0) { *************** *** 226,229 **** --- 226,232 ---- Revision history: $Log$ + Revision 1.26 2003/10/16 18:53:21 billhorsman + When registering a new pool on the fly, indicate that it is implicit (for exception message handling) + Revision 1.25 2003/09/30 18:39:08 billhorsman New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. |
From: <bil...@us...> - 2003-10-16 18:52:40
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv11821 Modified Files: ProxoolFacade.java Log Message: Fixed a bug: the redefine() method was actually calling the update() method. Also, added checks to make the "Attempt to use a pool with incomplete definition" exception a bit more descriptive. It's often because you are referring to an unregistered pool simply by using an alias. Index: ProxoolFacade.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxoolFacade.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** ProxoolFacade.java 7 Sep 2003 22:09:21 -0000 1.72 --- ProxoolFacade.java 16 Oct 2003 18:52:35 -0000 1.73 *************** *** 58,61 **** --- 58,74 ---- */ public static synchronized String registerConnectionPool(String url, Properties info) throws ProxoolException { + return registerConnectionPool(url, info, true); + } + + /** + * Build a ConnectionPool based on this definition and then start it. + * @param url defines the delegate driver and delegate url. + * @param info the properties used to configure Proxool (and any for the delegate driver too) - optional + * @param explicitRegister set to true if we are registering a new pool explicitly, or false + * if it's just because we are serving a url that we haven't come across before + * @return the alias for this pool (or the full url if no alias is specified) + * @throws ProxoolException if anything goes wrong + */ + protected static synchronized String registerConnectionPool(String url, Properties info, boolean explicitRegister) throws ProxoolException { String alias = getAlias(url); *************** *** 72,76 **** if (!ConnectionPoolManager.getInstance().isPoolExists(alias)) { ! ConnectionPoolDefinition cpd = new ConnectionPoolDefinition(url, info); registerConnectionPool(cpd); } else { --- 85,89 ---- if (!ConnectionPoolManager.getInstance().isPoolExists(alias)) { ! ConnectionPoolDefinition cpd = new ConnectionPoolDefinition(url, info, explicitRegister); registerConnectionPool(cpd); } else { *************** *** 493,497 **** /** ! * Redfine the behaviour of the pool. All existing properties (for Proxool * and the delegate driver are reset to their default) and reapplied * based on the parameters sent here. --- 506,510 ---- /** ! * Redefine the behaviour of the pool. All existing properties (for Proxool * and the delegate driver are reset to their default) and reapplied * based on the parameters sent here. *************** *** 505,509 **** ConnectionPool cp = ConnectionPoolManager.getInstance().getConnectionPool(alias); ConnectionPoolDefinition cpd = cp.getDefinition(); ! cpd.update(url, info); } --- 518,522 ---- ConnectionPool cp = ConnectionPoolManager.getInstance().getConnectionPool(alias); ConnectionPoolDefinition cpd = cp.getDefinition(); ! cpd.redefine(url, info); } *************** *** 691,694 **** --- 704,712 ---- Revision history: $Log$ + Revision 1.73 2003/10/16 18:52:35 billhorsman + Fixed a bug: the redefine() method was actually calling the update() method. Also, added checks to make the + "Attempt to use a pool with incomplete definition" exception a bit more descriptive. It's often because you + are referring to an unregistered pool simply by using an alias. + Revision 1.72 2003/09/07 22:09:21 billhorsman Remove any registered ShutdownHooks during shutdown. |
From: <ch...@us...> - 2003-10-09 19:01:53
|
Update of /cvsroot/proxool/proxool/lib In directory sc8-pr-cvs1:/tmp/cvs-serv24488 Added Files: commons-collections.jar commons-lang.jar dom4j.jar hibernate2.jar xalan.jar xml-apis.jar Log Message: Re-adding Hibernate files as binary files. |
From: <ch...@us...> - 2003-10-09 18:59:01
|
Update of /cvsroot/proxool/proxool/lib In directory sc8-pr-cvs1:/tmp/cvs-serv22737 Removed Files: commons-collections.jar commons-lang.jar dom4j.jar hibernate2.jar xalan.jar xml-apis.jar Log Message: Removing Hibernate files because they were not added as binary files. --- commons-collections.jar DELETED --- --- commons-lang.jar DELETED --- --- dom4j.jar DELETED --- --- hibernate2.jar DELETED --- --- xalan.jar DELETED --- --- xml-apis.jar DELETED --- |
From: <ch...@us...> - 2003-10-09 18:27:13
|
Update of /cvsroot/proxool/proxool/lib In directory sc8-pr-cvs1:/tmp/cvs-serv12554 Added Files: jdbc2_0-stdext.jar Removed Files: jdbc2_0-stdext-src.zip Log Message: Added binary JDBC extentions instead of source. --- NEW FILE: jdbc2_0-stdext.jar --- (This appears to be a binary file; contents omitted.) --- jdbc2_0-stdext-src.zip DELETED --- |
From: <ch...@us...> - 2003-10-07 21:56:51
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv21535 Modified Files: build.xml Log Message: Fixed reporting of java vendor and version. Index: build.xml =================================================================== RCS file: /cvsroot/proxool/proxool/build.xml,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** build.xml 1 Oct 2003 19:31:50 -0000 1.62 --- build.xml 7 Oct 2003 21:56:40 -0000 1.63 *************** *** 228,232 **** description="Build the core source (all that is required to run Proxool)" > ! <echo level="info" message="Using JDK1.4"/> <copy todir="${build-dir}/src/java" preservelastmodified="yes"> <fileset dir="src/java" includes="**/*.java"/> --- 228,232 ---- description="Build the core source (all that is required to run Proxool)" > ! <echo level="info" message="Using ${java.vm.vendor} ${java.vm.name} ${java.vm.version} in ${java.home}"/> <copy todir="${build-dir}/src/java" preservelastmodified="yes"> <fileset dir="src/java" includes="**/*.java"/> |
From: <bil...@us...> - 2003-10-01 19:32:28
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv24660 Modified Files: build.xml Log Message: 0.8.0RC2 Index: build.xml =================================================================== RCS file: /cvsroot/proxool/proxool/build.xml,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** build.xml 10 Sep 2003 22:16:06 -0000 1.61 --- build.xml 1 Oct 2003 19:31:50 -0000 1.62 *************** *** 27,31 **** <!-- Currect release, e.g. 0.6 --> ! <property name="release" value="0.7.3"/> <!-- Currect release, e.g. 0.6 --> --- 27,31 ---- <!-- Currect release, e.g. 0.6 --> ! <property name="release" value="0.8.0RC2"/> <!-- Currect release, e.g. 0.6 --> |
From: <bil...@us...> - 2003-10-01 19:32:00
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv24675 Modified Files: CHANGES.txt Log Message: 0.8.0RC2 Index: CHANGES.txt =================================================================== RCS file: /cvsroot/proxool/proxool/CHANGES.txt,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** CHANGES.txt 30 Aug 2003 11:44:54 -0000 1.25 --- CHANGES.txt 1 Oct 2003 19:31:54 -0000 1.26 *************** *** 6,13 **** $Author$ ! 0.7.3 - (30 August, 2003) ! - Fix to documentation. Defining more than one type of fatal SQL exception ! is done with a comma delimited list. - New getDelegateConnection() method on ProxoolFacade gives you access --- 6,17 ---- $Author$ ! 0.8.0 - (October, 2003) ! - We now use Cglib's proxy library. Together with dropping the use of Timer ! and only referencing ShutdownHooks at runtime we are now able to support ! JDKs 1.2, 1.3 and 1.4 out of the box (Without Ant applied patches, which ! were horrible). ! ! - Proxool is now available as a JMX component. - New getDelegateConnection() method on ProxoolFacade gives you access *************** *** 24,28 **** regardless of your timezone. This was a display bug only and didn't effect the behaviour of the pool itself. ! - Connections that are about to be expired no longer bother to reset themselves (because they'll never be used again anyway). This was --- 28,32 ---- regardless of your timezone. This was a display bug only and didn't effect the behaviour of the pool itself. ! - Connections that are about to be expired no longer bother to reset themselves (because they'll never be used again anyway). This was *************** *** 30,36 **** database which then caused problems during the reset. - Fixed ConcurrentModificationException that happened in some environments during automatic statement closure. ! 0.7.2 - April 28, 2003 --- 34,61 ---- database which then caused problems during the reset. + - Added fatal-sql-exception-wrapper-class property. If a fatal exception is + detected then it is wrapped up inside the exception defined by this + property. This can make exception handling easier is frameworks like + Struts. Two wrappers are provided (FataSQLException and FatalRuntimeException) + but you can also define your own. + + - Added test-before-use and test-after-use properties. They will trigger a test of + the connection (as defined by house-keeper-test-sql) just before a connection + is handed out and just after it is closed (put back in the pool) respectively. + These are both off by default. + - Fixed ConcurrentModificationException that happened in some environments during automatic statement closure. ! ! - Fixed bug where if there was an Error during prototyping (not an SQLException, ! not a RuntimeException but something serious like NoClassDefFoundError) then ! the prototyper would keep attempting to make connections as fast as it could ! (and never succeed in making any). Much better for the prototyper to give ! up in that situation and try again when it is next asked (which, by default, ! would be 30 seconds later). ! ! - Fix to documentation. Defining more than one type of fatal SQL exception ! is done with a comma delimited list. ! 0.7.2 - April 28, 2003 |
From: <bil...@us...> - 2003-10-01 19:31:31
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv24574 Modified Files: Version.java Log Message: 0.8.0RC2 Index: Version.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/Version.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Version.java 11 Sep 2003 11:17:52 -0000 1.13 --- Version.java 1 Oct 2003 19:31:26 -0000 1.14 *************** *** 40,44 **** private static final String BUILD_DATE = null; ! private static final String CVS = "0.8.0RC1+"; public static String getVersion() { --- 40,44 ---- private static final String BUILD_DATE = null; ! private static final String CVS = "0.8.0RC2+"; public static String getVersion() { *************** *** 77,80 **** --- 77,83 ---- Revision history: $Log$ + Revision 1.14 2003/10/01 19:31:26 billhorsman + 0.8.0RC2 + Revision 1.13 2003/09/11 11:17:52 billhorsman *** empty log message *** |
From: <bil...@us...> - 2003-09-30 19:09:51
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv3855 Modified Files: AbstractProxoolTest.java Log Message: Now uses a readwrite lock to make sure that each test runs sequentially. This should be true all the time, but sometimes tests fail and it is always because of some timing issue that is very hard to track down. This is an attempt to fix that. Index: AbstractProxoolTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/AbstractProxoolTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractProxoolTest.java 4 Mar 2003 10:11:09 -0000 1.3 --- AbstractProxoolTest.java 30 Sep 2003 19:09:46 -0000 1.4 *************** *** 9,12 **** --- 9,13 ---- import org.logicalcobwebs.logging.Log; import org.logicalcobwebs.logging.LogFactory; + import org.logicalcobwebs.concurrent.ReaderPreferenceReadWriteLock; import java.util.Stack; *************** *** 25,28 **** --- 26,31 ---- private String alias; + private static ReaderPreferenceReadWriteLock testLock = new ReaderPreferenceReadWriteLock(); + private Stack threadNames = new Stack(); *************** *** 37,40 **** --- 40,44 ---- protected void setUp() throws Exception { GlobalTest.globalSetup(); + testLock.writeLock().acquire(); threadNames.push(Thread.currentThread().getName()); LOG.debug("Thread '" + Thread.currentThread().getName() + "' -> '" + alias + "'"); *************** *** 47,50 **** --- 51,55 ---- protected void tearDown() throws Exception { GlobalTest.globalTeardown(alias); + testLock.writeLock().release(); Thread.currentThread().setName((String) threadNames.pop()); LOG.debug("Thread '" + alias + "' -> '" + Thread.currentThread().getName() + "'"); *************** *** 57,60 **** --- 62,70 ---- Revision history: $Log$ + Revision 1.4 2003/09/30 19:09:46 billhorsman + Now uses a readwrite lock to make sure that each test runs sequentially. This should be true all the time, but sometimes + tests fail and it is always because of some timing issue that is very hard to track down. This is an attempt to + fix that. + Revision 1.3 2003/03/04 10:11:09 billhorsman actually made abstract |
From: <bil...@us...> - 2003-09-30 18:58:33
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv1544 Modified Files: GlobalTest.java Log Message: Increase shutdown grace time to 10 seconds to make tests more robust. Index: GlobalTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/GlobalTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** GlobalTest.java 7 Sep 2003 22:10:17 -0000 1.16 --- GlobalTest.java 30 Sep 2003 18:58:29 -0000 1.17 *************** *** 51,55 **** public static synchronized void globalTeardown(String alias) { ! ProxoolFacade.shutdown(alias + ":teardown", 5000); } --- 51,55 ---- public static synchronized void globalTeardown(String alias) { ! ProxoolFacade.shutdown(alias + ":teardown", 10000); } *************** *** 85,88 **** --- 85,91 ---- Revision history: $Log$ + Revision 1.17 2003/09/30 18:58:29 billhorsman + Increase shutdown grace time to 10 seconds to make tests more robust. + Revision 1.16 2003/09/07 22:10:17 billhorsman Default behaviour of test classes, if Log4J is not configured, is now DEBUG output to console. |
From: <bil...@us...> - 2003-09-30 18:40:20
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv30555 Modified Files: HouseKeeperTest.java Log Message: New tests for test-before-use and test-after-use Index: HouseKeeperTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/HouseKeeperTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HouseKeeperTest.java 11 Sep 2003 23:58:05 -0000 1.7 --- HouseKeeperTest.java 30 Sep 2003 18:40:16 -0000 1.8 *************** *** 11,14 **** --- 11,16 ---- import java.sql.Connection; import java.sql.DriverManager; + import java.sql.Statement; + import java.sql.SQLException; import java.util.Properties; *************** *** 104,107 **** --- 106,222 ---- } + /** + * Test that house keeper destroys connections that fail configured + * the test sql + */ + public void testInvalidBeforeUse() throws Exception { + + String testName = "invalidBeforeUse"; + String alias = testName; + + String url = TestHelper.buildProxoolUrl(alias, + TestConstants.HYPERSONIC_DRIVER, + TestConstants.HYPERSONIC_TEST_URL); + Properties info = new Properties(); + info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); + info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, "Invalid test"); + info.setProperty(ProxoolConstants.TEST_BEFORE_USE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, Boolean.TRUE.toString()); + ProxoolFacade.registerConnectionPool(url, info); + + // This should trigger a test followed the actual executed command. Because we've + // deliberately made the test invalid, we should get an exception when getting a + // connection + Connection connection = null; + Statement s = null; + try { + connection = DriverManager.getConnection(url); + s = connection.createStatement(); + s.execute(TestConstants.HYPERSONIC_TEST_SQL); + fail("Expected to get an exception because the test failed"); + } catch (SQLException e) { + LOG.debug("Expected exception.", e); + } + + } + + /** + * Test that house keeper destroys connections that fail configured + * the test sql + */ + public void testInvalidAfterUse() throws Exception { + + String testName = "invalidAfterUse"; + String alias = testName; + + String url = TestHelper.buildProxoolUrl(alias, + TestConstants.HYPERSONIC_DRIVER, + TestConstants.HYPERSONIC_TEST_URL); + Properties info = new Properties(); + info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); + info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, "Invalid test"); + info.setProperty(ProxoolConstants.TEST_AFTER_USE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, Boolean.TRUE.toString()); + ProxoolFacade.registerConnectionPool(url, info); + + // This should trigger a test as soon as we close the connection. Because we've + // deliberately made the test invalid then it should get thrown away + Connection connection = null; + Statement s = null; + try { + connection = DriverManager.getConnection(url); + s = connection.createStatement(); + s.execute(TestConstants.HYPERSONIC_TEST_SQL); + } finally { + if (connection != null) { + connection.close(); + } + } + + // There should be no available connections. We don't have a minimum setup and the one we + // just created on demand got thrown away because it failed its test + assertEquals("Available connections", 0, ProxoolFacade.getSnapshot(alias).getAvailableConnectionCount()); + + } + + public void testBeforeAndAfterUse() throws Exception { + + String testName = "beforeAndAfterUse"; + String alias = testName; + + String url = TestHelper.buildProxoolUrl(alias, + TestConstants.HYPERSONIC_DRIVER, + TestConstants.HYPERSONIC_TEST_URL); + Properties info = new Properties(); + info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); + info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); + info.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); + info.setProperty(ProxoolConstants.TEST_BEFORE_USE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.TEST_AFTER_USE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, Boolean.TRUE.toString()); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, Boolean.TRUE.toString()); + ProxoolFacade.registerConnectionPool(url, info); + + Connection connection = null; + Statement s = null; + try { + connection = DriverManager.getConnection(url); + s = connection.createStatement(); + s.execute(TestConstants.HYPERSONIC_TEST_SQL); + } finally { + if (connection != null) { + connection.close(); + } + } + + // There should be one available connection. + assertEquals("Available connections", 1, ProxoolFacade.getSnapshot(alias).getAvailableConnectionCount()); + + } + } *************** *** 110,113 **** --- 225,231 ---- Revision history: $Log$ + Revision 1.8 2003/09/30 18:40:16 billhorsman + New tests for test-before-use and test-after-use + Revision 1.7 2003/09/11 23:58:05 billhorsman New test for house-keeper-test-sql |
From: <bil...@us...> - 2003-09-30 18:39:53
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv30435 Modified Files: TestHelper.java Log Message: New test sql syntax constant Index: TestHelper.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/TestHelper.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** TestHelper.java 5 Mar 2003 23:28:55 -0000 1.20 --- TestHelper.java 30 Sep 2003 18:39:50 -0000 1.21 *************** *** 30,34 **** properties.setProperty("password", ""); properties.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "40000"); ! properties.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, "select CURRENT_DATE"); properties.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, "10"); properties.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, "3"); --- 30,34 ---- properties.setProperty("password", ""); properties.setProperty(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY, "40000"); ! properties.setProperty(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY, TestConstants.HYPERSONIC_TEST_SQL); properties.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, "10"); properties.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, "3"); *************** *** 141,144 **** --- 141,147 ---- Revision history: $Log$ + Revision 1.21 2003/09/30 18:39:50 billhorsman + New test sql syntax constant + Revision 1.20 2003/03/05 23:28:55 billhorsman deprecated maximum-new-connections property in favour of |
From: <bil...@us...> - 2003-09-30 18:39:43
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv30342 Modified Files: TestConstants.java Log Message: New test sql syntax constant Index: TestConstants.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/TestConstants.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestConstants.java 3 Mar 2003 11:12:05 -0000 1.4 --- TestConstants.java 30 Sep 2003 18:39:39 -0000 1.5 *************** *** 28,31 **** --- 28,33 ---- static final String HYPERSONIC_PASSWORD = ""; + static final String HYPERSONIC_TEST_SQL = "SELECT COUNT(1) FROM SYSTEM_CATALOGS"; + } *************** *** 33,36 **** --- 35,41 ---- Revision history: $Log$ + Revision 1.5 2003/09/30 18:39:39 billhorsman + New test sql syntax constant + Revision 1.4 2003/03/03 11:12:05 billhorsman fixed licence |
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv30271 Modified Files: AbstractProxyStatement.java ConnectionPool.java ConnectionPoolDefinition.java ConnectionPoolDefinitionIF.java FatalSqlExceptionHelper.java Prototyper.java ProxoolConstants.java ProxoolDriver.java ProxyConnection.java ProxyFactory.java ProxyStatement.java Log Message: New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. Index: AbstractProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/AbstractProxyStatement.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AbstractProxyStatement.java 5 Sep 2003 16:26:50 -0000 1.11 --- AbstractProxyStatement.java 30 Sep 2003 18:39:07 -0000 1.12 *************** *** 12,16 **** import java.sql.Statement; import java.util.Comparator; - import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; --- 12,15 ---- *************** *** 58,85 **** * Check to see whether an exception is a fatal one. If it is, then throw the connection * away (and it won't be made available again) ! * @param e the exception to test */ ! protected boolean testException(SQLException e) { ! boolean fatalSqlExceptionDetected = false; ! Iterator i = connectionPool.getDefinition().getFatalSqlExceptions().iterator(); ! while (i.hasNext()) { ! if (e.getMessage().indexOf((String) i.next()) > -1) { ! // This SQL exception indicates a fatal problem with this connection. We should probably ! // just junk it. ! fatalSqlExceptionDetected = true; ! try { ! statement.close(); ! connectionPool.throwConnection(proxyConnection, "Fatal SQL Exception has been detected"); ! // We should check all the existing connections as soon as possible ! HouseKeeperController.sweepNow(connectionPool.getDefinition().getAlias()); ! LOG.warn("Connection has been thrown away because fatal exception was detected", e); ! } catch (SQLException e2) { ! LOG.error("Problem trying to throw away suspect connection", e2); ! } } } - return fatalSqlExceptionDetected; } --- 57,81 ---- * Check to see whether an exception is a fatal one. If it is, then throw the connection * away (and it won't be made available again) ! * @param t the exception to test */ ! protected boolean testException(Throwable t) { ! if (FatalSqlExceptionHelper.testException(connectionPool.getDefinition(), t)) { ! // This SQL exception indicates a fatal problem with this connection. We should probably ! // just junk it. ! try { ! statement.close(); ! connectionPool.throwConnection(proxyConnection, "Fatal SQL Exception has been detected"); ! // We should check all the existing connections as soon as possible ! HouseKeeperController.sweepNow(connectionPool.getDefinition().getAlias()); ! LOG.warn("Connection has been thrown away because fatal exception was detected", t); ! } catch (SQLException e2) { ! LOG.error("Problem trying to throw away suspect connection", e2); } + return true; + } else { + return false; } } *************** *** 213,216 **** --- 209,215 ---- Revision history: $Log$ + Revision 1.12 2003/09/30 18:39:07 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.11 2003/09/05 16:26:50 billhorsman testException() now returns true if a fatal exception was detected. Index: ConnectionPool.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPool.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ConnectionPool.java 30 Sep 2003 07:50:04 -0000 1.69 --- ConnectionPool.java 30 Sep 2003 18:39:08 -0000 1.70 *************** *** 15,18 **** --- 15,19 ---- import java.sql.Connection; import java.sql.SQLException; + import java.sql.Statement; import java.util.Collection; import java.util.Comparator; *************** *** 199,204 **** // in between) if (proxyConnection != null && proxyConnection.setStatus(ProxyConnectionIF.STATUS_AVAILABLE, ProxyConnectionIF.STATUS_ACTIVE)) { ! nextAvailableConnection++; ! break; } else { proxyConnection = null; --- 200,215 ---- // in between) if (proxyConnection != null && proxyConnection.setStatus(ProxyConnectionIF.STATUS_AVAILABLE, ProxyConnectionIF.STATUS_ACTIVE)) { ! ! // Okay. So we have it. But is it working ok? ! if (getDefinition().isTestBeforeUse()) { ! if (!testConnection(proxyConnection)) { ! // Oops. No it's not. Let's choose another. ! proxyConnection = null; ! } ! } ! if (proxyConnection != null) { ! nextAvailableConnection++; ! break; ! } } else { proxyConnection = null; *************** *** 212,222 **** proxyConnection = PrototyperController.buildConnection( getDefinition().getAlias(), ProxyConnection.STATUS_ACTIVE, "on demand"); } catch (SQLException e) { - log.debug("Couldn't get connection", e); throw e; } catch (ProxoolException e) { log.debug("Couldn't get connection", e); throw new SQLException(e.toString()); ! } catch (Exception e) { log.error("Couldn't get connection", e); throw new SQLException(e.toString()); --- 223,239 ---- proxyConnection = PrototyperController.buildConnection( getDefinition().getAlias(), ProxyConnection.STATUS_ACTIVE, "on demand"); + // Okay. So we have it. But is it working ok? + if (getDefinition().isTestBeforeUse()) { + if (!testConnection(proxyConnection)) { + // Oops. No it's not. There's not much more we can do for now + throw new SQLException("Created a new connection but it failed its test"); + } + } } catch (SQLException e) { throw e; } catch (ProxoolException e) { log.debug("Couldn't get connection", e); throw new SQLException(e.toString()); ! } catch (Throwable e) { log.error("Couldn't get connection", e); throw new SQLException(e.toString()); *************** *** 225,231 **** } catch (SQLException e) { - if (log.isDebugEnabled()) { - log.debug("Problem getting connection", e); - } throw e; } catch (Throwable t) { --- 242,245 ---- *************** *** 257,260 **** --- 271,300 ---- } + private boolean testConnection(ProxyConnectionIF proxyConnection) { + boolean success = false; + final String testSql = getDefinition().getHouseKeepingTestSql(); + if (testSql != null && testSql.length() > 0) { + Statement s = null; + try { + s = proxyConnection.getConnection().createStatement(); + s.execute(testSql); + success = true; + if (LOG.isDebugEnabled()) { + LOG.debug(displayStatistics() + " - Connection #" + proxyConnection.getId() + " tested: OK"); + } + } catch (Throwable t) { + proxyConnection.setStatus(ProxyConnectionIF.STATUS_NULL); + removeProxyConnection(proxyConnection, "it has problems: " + t, ConnectionPool.REQUEST_EXPIRY, true); + } finally { + try { + s.close(); + } catch (SQLException e) { + // Ignore + } + } + } + return success; + } + /** * Add a ProxyConnection to the pool *************** *** 306,309 **** --- 346,355 ---- } + // Optionally, test it to see if it is ok + if (getDefinition().isTestAfterUse()) { + // It will get removed by this call if it is no good + testConnection(proxyConnection); + } + if (log.isDebugEnabled() && getDefinition().isVerbose()) { log.debug(displayStatistics() + " - Connection #" + proxyConnection.getId() + " returned"); *************** *** 1049,1052 **** --- 1095,1101 ---- Revision history: $Log$ + Revision 1.70 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.69 2003/09/30 07:50:04 billhorsman Smarter throwing of caught SQLExceptions without wrapping them up inside another (and losing the stack trace) Index: ConnectionPoolDefinition.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPoolDefinition.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ConnectionPoolDefinition.java 29 Sep 2003 17:48:08 -0000 1.23 --- ConnectionPoolDefinition.java 30 Sep 2003 18:39:08 -0000 1.24 *************** *** 109,112 **** --- 109,116 ---- private String houseKeepingTestSql; + private boolean testBeforeUse; + + private boolean testAfterUse; + /** * So we can set the values one by one if we want *************** *** 278,295 **** } } ! } else if (key.equals(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY)) { ! if (getHouseKeepingSleepTime() != getInt(key, value)) { ! changed = true; ! if (!pretend) { ! setHouseKeepingSleepTime(getInt(key, value)); ! } ! } ! } else if (key.equals(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY)) { ! if (isChanged(getHouseKeepingTestSql(), value)) { ! changed = true; ! if (!pretend) { ! setHouseKeepingTestSql(value); ! } ! } } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY)) { if (getMaximumConnectionCount() != getInt(key, value)) { --- 282,287 ---- } } ! } else if (setHouseKeeperProperty(key, value, pretend)) { ! changed = true; } else if (key.equals(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY)) { if (getMaximumConnectionCount() != getInt(key, value)) { *************** *** 447,450 **** --- 439,482 ---- /** + * Subset of {@link #setAnyProperty} to avoid overly long method. + * @see #setAnyProperty + */ + private boolean setHouseKeeperProperty(String key, String value, boolean pretend) throws ProxoolException { + boolean changed = false; + if (key.equals(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY)) { + if (getHouseKeepingSleepTime() != getInt(key, value)) { + changed = true; + if (!pretend) { + setHouseKeepingSleepTime(getInt(key, value)); + } + } + } else if (key.equals(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY)) { + if (isChanged(getHouseKeepingTestSql(), value)) { + changed = true; + if (!pretend) { + setHouseKeepingTestSql(value); + } + } + } else if (key.equals(ProxoolConstants.TEST_BEFORE_USE_PROPERTY)) { + final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); + if (isTestBeforeUse() != valueAsBoolean) { + changed = true; + if (!pretend) { + setTestBeforeUse(valueAsBoolean); + } + } + } else if (key.equals(ProxoolConstants.TEST_AFTER_USE_PROPERTY)) { + final boolean valueAsBoolean = Boolean.valueOf(value).booleanValue(); + if (isTestAfterUse() != valueAsBoolean) { + changed = true; + if (!pretend) { + setTestAfterUse(valueAsBoolean); + } + } + } + return changed; + } + + /** * Subset of {@link #setAnyProperty} to avoid overly long method * @see #setAnyProperty *************** *** 538,541 **** --- 570,575 ---- houseKeepingSleepTime = DEFAULT_HOUSE_KEEPING_SLEEP_TIME; houseKeepingTestSql = null; + testAfterUse = false; + testBeforeUse = false; simultaneousBuildThrottle = DEFAULT_SIMULTANEOUS_BUILD_THROTTLE; recentlyStartedThreshold = DEFAULT_RECENTLY_STARTED_THRESHOLD; *************** *** 547,550 **** --- 581,585 ---- statisticsLogLevel = null; fatalSqlExceptions.clear(); + fatalSqlExceptionWrapper = null; } *************** *** 947,950 **** --- 982,1013 ---- /** + * @see ConnectionPoolDefinitionIF#isTestBeforeUse + */ + public boolean isTestBeforeUse() { + return testBeforeUse; + } + + /** + * @see ConnectionPoolDefinitionIF#isTestBeforeUse + */ + public void setTestBeforeUse(boolean testBeforeUse) { + this.testBeforeUse = testBeforeUse; + } + + /** + * @see ConnectionPoolDefinitionIF#isTestAfterUse + */ + public boolean isTestAfterUse() { + return testAfterUse; + } + + /** + * @see ConnectionPoolDefinitionIF#isTestAfterUse + */ + public void setTestAfterUse(boolean testAfterUse) { + this.testAfterUse = testAfterUse; + } + + /** * @see ConnectionPoolDefinitionIF#getStatistics */ *************** *** 1064,1067 **** --- 1127,1133 ---- Revision history: $Log$ + Revision 1.24 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.23 2003/09/29 17:48:08 billhorsman New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you Index: ConnectionPoolDefinitionIF.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPoolDefinitionIF.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ConnectionPoolDefinitionIF.java 29 Sep 2003 17:48:08 -0000 1.19 --- ConnectionPoolDefinitionIF.java 30 Sep 2003 18:39:08 -0000 1.20 *************** *** 168,181 **** * is always thrown back to the user. * @return the list of exception fragments (String) ! * @see #FATAL_SQL_EXCEPTIONS_DELIMITER */ Set getFatalSqlExceptions(); /** ! * ! * @return */ String getHouseKeepingTestSql(); /** * The URL that was used to define this pool. For example: --- 168,197 ---- * is always thrown back to the user. * @return the list of exception fragments (String) ! * @see #FATAL_SQL_EXCEPTIONS_DELIMITER */ Set getFatalSqlExceptions(); /** ! * The test SQL that we perform to see if a connection is alright. ! * Should be fast and robust. ! * @return house keeping test SQL */ String getHouseKeepingTestSql(); + /** + * Whether we test each connection before it is served + * @return true if we do the test + * @see #getHouseKeepingTestSql + */ + boolean isTestBeforeUse(); + + /** + * Whether we test each connection after it is closed + * (that is, returned to the pool) + * @return true if we do the test + * @see #getHouseKeepingTestSql + */ + boolean isTestAfterUse(); + /** * The URL that was used to define this pool. For example: *************** *** 279,282 **** --- 295,301 ---- Revision history: $Log$ + Revision 1.20 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.19 2003/09/29 17:48:08 billhorsman New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you Index: FatalSqlExceptionHelper.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/FatalSqlExceptionHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FatalSqlExceptionHelper.java 29 Sep 2003 18:12:33 -0000 1.2 --- FatalSqlExceptionHelper.java 30 Sep 2003 18:39:08 -0000 1.3 *************** *** 6,12 **** --- 6,17 ---- package org.logicalcobwebs.proxool; + import org.logicalcobwebs.logging.Log; + import org.logicalcobwebs.logging.LogFactory; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; + import java.lang.reflect.Method; import java.sql.SQLException; + import java.util.Iterator; /** *************** *** 18,21 **** --- 23,28 ---- class FatalSqlExceptionHelper { + private static final Log LOG = LogFactory.getLog(FatalSqlExceptionHelper.class); + /** * Throws a wrapped SQLException if a wrapper is defined *************** *** 27,31 **** * @throws RuntimeException a wrapped up version of the orginal */ ! protected static void throwFatalSQLException(String className, SQLException originalException) throws ProxoolException, SQLException, RuntimeException { if (className != null && className.trim().length() > 0) { Class clazz = null; --- 34,38 ---- * @throws RuntimeException a wrapped up version of the orginal */ ! protected static void throwFatalSQLException(String className, Throwable originalException) throws ProxoolException, SQLException, RuntimeException { if (className != null && className.trim().length() > 0) { Class clazz = null; *************** *** 62,65 **** --- 69,73 ---- Object exceptionToThrow = toUse.newInstance(args); if (exceptionToThrow instanceof RuntimeException) { + LOG.debug("Wrapping up a fatal exception: " + originalException.getMessage(), originalException); throw (RuntimeException) exceptionToThrow; } else if (exceptionToThrow instanceof SQLException) { *************** *** 76,82 **** } } else { ! throw originalException; } } } --- 84,196 ---- } } else { ! if (originalException instanceof SQLException) { ! throw (SQLException) originalException; ! } else if (originalException instanceof RuntimeException) { ! throw (RuntimeException) originalException; ! } else { ! throw new RuntimeException("Unexpected exception:" + originalException.getMessage()); ! } } } + + /** + * Test to see if an exception is a fatal one + * @param cpd the definition so we can find out what a fatal exception looks like + * @param t the exception to test + * @return true if it is fatal + */ + protected static boolean testException(ConnectionPoolDefinitionIF cpd, Throwable t) { + return testException(cpd, t, 0); + } + + /** + * Test to see if an exception is a fatal one + * @param cpd the definition so we can find out what a fatal exception looks like + * @param t the exception to test + * @param level the recursion level (max 20) + * @return true if it is fatal + */ + protected static boolean testException(ConnectionPoolDefinitionIF cpd, Throwable t, int level) { + boolean fatalSqlExceptionDetected = false; + Iterator i = cpd.getFatalSqlExceptions().iterator(); + while (i.hasNext()) { + if (t.getMessage().indexOf((String) i.next()) > -1) { + // This SQL exception indicates a fatal problem with this connection. + fatalSqlExceptionDetected = true; + } + } + + // If it isn't fatal, then try testing the contained exception + if (!fatalSqlExceptionDetected && level < 20) { + Throwable cause = getCause(t); + if (cause != null) { + fatalSqlExceptionDetected = testException(cpd, cause, level + 1); + } + } + + return fatalSqlExceptionDetected; + } + + /** + * Tries to drill down into an exception to find its cause. Only goes one level deep. + * Uses reflection to look at getCause(), getTargetException(), getRootCause() and + * finally getOriginalException() methods to see if it can find one. Doesn't throw + * an error - it will just log a warning and return a null if nothing was found. + * @param t the exception to look inside + * @return the original exception or null if none was found. + */ + protected static Throwable getCause(Throwable t) { + Throwable cause = null; + Method causeMethod = null; + + try { + // Try a series of likely accessor methods + if (causeMethod == null) { + causeMethod = getMethod(t, "getCause"); + } + if (causeMethod == null) { + causeMethod = getMethod(t, "getTargetException"); + } + if (causeMethod == null) { + causeMethod = getMethod(t, "getRootCause"); + } + if (causeMethod == null) { + causeMethod = getMethod(t, "getOriginalException"); + } + + // If one was found, invoke it. + if (causeMethod != null) { + try { + cause = (Throwable) causeMethod.invoke(t, null); + } catch (IllegalAccessException e) { + LOG.warn("Problem invoking " + t.getClass().getName() + "." + causeMethod.getName() + ". Ignoring.", e); + } catch (IllegalArgumentException e) { + LOG.warn("Problem invoking " + t.getClass().getName() + "." + causeMethod.getName() + ". Ignoring.", e); + } catch (InvocationTargetException e) { + LOG.warn("Problem invoking " + t.getClass().getName() + "." + causeMethod.getName() + ". Ignoring.", e); + } + } + } catch (Exception e) { + LOG.warn("Unexpected exception drilling into exception. Ignoring.", e); + } + return cause; + } + + private static Method getMethod(Object o, String methodName) { + Method m = null; + try { + m = o.getClass().getMethod(methodName, null); + // Reject any method that doesn't return a throwable. + if (!Throwable.class.isAssignableFrom(m.getReturnType())) { + m = null; + } + } catch (NoSuchMethodException e) { + // That's OK + } catch (SecurityException e) { + LOG.warn("Problem finding method " + methodName, e); + } + return m; + } + } *************** *** 84,87 **** --- 198,204 ---- Revision history: $Log$ + Revision 1.3 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.2 2003/09/29 18:12:33 billhorsman Doc Index: Prototyper.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/Prototyper.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Prototyper.java 11 Sep 2003 10:44:54 -0000 1.6 --- Prototyper.java 30 Sep 2003 18:39:08 -0000 1.7 *************** *** 87,90 **** --- 87,91 ---- } + ProxyConnectionIF freshlyBuiltProxyConnection = null; try { // If it has been shutdown then we should just stop now. *************** *** 92,96 **** break; } ! buildConnection(ProxyConnection.STATUS_AVAILABLE, reason); somethingDone = true; } catch (Throwable e) { --- 93,97 ---- break; } ! freshlyBuiltProxyConnection = buildConnection(ProxyConnection.STATUS_AVAILABLE, reason); somethingDone = true; } catch (Throwable e) { *************** *** 104,107 **** --- 105,112 ---- // housekeeping thread runs. } + if (freshlyBuiltProxyConnection == null) { + // That's strange. No double the buildConnection() method logged the + // error, but we should have build a connection here. + } } } catch (Throwable t) { *************** *** 181,191 **** } catch (RuntimeException e) { if (log.isDebugEnabled()) { ! log.debug(e); } throw e; } catch (Throwable t) { if (log.isDebugEnabled()) { ! log.debug(t); } } finally { synchronized (lock) { --- 186,197 ---- } catch (RuntimeException e) { if (log.isDebugEnabled()) { ! log.debug("Prototyping problem", e); } throw e; } catch (Throwable t) { if (log.isDebugEnabled()) { ! log.debug("Prototyping problem", t); } + throw new ProxoolException("Unexpected prototyping problem", t); } finally { synchronized (lock) { *************** *** 261,264 **** --- 267,273 ---- Revision history: $Log$ + Revision 1.7 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.6 2003/09/11 10:44:54 billhorsman Catch throwable not just exception during creation of connection Index: ProxoolConstants.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxoolConstants.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ProxoolConstants.java 29 Sep 2003 17:48:21 -0000 1.18 --- ProxoolConstants.java 30 Sep 2003 18:39:08 -0000 1.19 *************** *** 62,65 **** --- 62,77 ---- public final String HOUSE_KEEPING_TEST_SQL_PROPERTY = PROPERTY_PREFIX + HOUSE_KEEPING_TEST_SQL; + /** @see #TEST_BEFORE_USE_PROPERTY */ + public final String TEST_BEFORE_USE = "test-before-use"; + + /** @see ProxoolDriver#getPropertyInfo */ + public final String TEST_BEFORE_USE_PROPERTY = PROPERTY_PREFIX + TEST_BEFORE_USE; + + /** @see #TEST_AFTER_USE_PROPERTY */ + public final String TEST_AFTER_USE = "test-after-use"; + + /** @see ProxoolDriver#getPropertyInfo */ + public final String TEST_AFTER_USE_PROPERTY = PROPERTY_PREFIX + TEST_AFTER_USE; + /** @see #MAXIMUM_CONNECTION_COUNT_PROPERTY */ public final String MAXIMUM_CONNECTION_COUNT = "maximum-connection-count"; *************** *** 253,256 **** --- 265,271 ---- Revision history: $Log$ + Revision 1.19 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.18 2003/09/29 17:48:21 billhorsman New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you Index: ProxoolDriver.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxoolDriver.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ProxoolDriver.java 5 Sep 2003 16:59:42 -0000 1.24 --- ProxoolDriver.java 30 Sep 2003 18:39:08 -0000 1.25 *************** *** 66,70 **** public Connection connect(String url, Properties info) throws SQLException { - if (!url.startsWith("proxool")) { return null; --- 66,69 ---- *************** *** 90,93 **** --- 89,107 ---- return cp.getConnection(); + } catch (SQLException e) { + LOG.error("Problem", e); + // Check to see if it's fatal. We might need to wrap it up. + try { + String alias = ProxoolFacade.getAlias(url); + cp = ConnectionPoolManager.getInstance().getConnectionPool(alias); + if (FatalSqlExceptionHelper.testException(cp.getDefinition(), e)) { + FatalSqlExceptionHelper.throwFatalSQLException(cp.getDefinition().getFatalSqlExceptionWrapper(), e); + } + // This bit isn't reached if throwFatalSQLException() above throws another exception + throw e; + } catch (ProxoolException e1) { + LOG.error("Problem", e); + throw new SQLException(e.toString()); + } } catch (ProxoolException e) { LOG.error("Problem", e); *************** *** 212,215 **** --- 226,232 ---- Revision history: $Log$ + Revision 1.25 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.24 2003/09/05 16:59:42 billhorsman Added wrap-fatal-sql-exceptions property Index: ProxyConnection.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyConnection.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ProxyConnection.java 10 Sep 2003 22:21:04 -0000 1.27 --- ProxyConnection.java 30 Sep 2003 18:39:08 -0000 1.28 *************** *** 84,90 **** --- 84,97 ---- } catch (InvocationTargetException e) { + // We might get a fatal exception here. Let's test for it. + if (FatalSqlExceptionHelper.testException(getConnectionPool().getDefinition(), e.getTargetException())) { + FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), e.getTargetException()); + } throw e.getTargetException(); } catch (Exception e) { LOG.error("Unexpected invocation exception", e); + if (FatalSqlExceptionHelper.testException(getConnectionPool().getDefinition(), e)) { + FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), e); + } throw new RuntimeException("Unexpected invocation exception: " + e.getMessage()); *************** *** 99,102 **** --- 106,112 ---- Revision history: $Log$ + Revision 1.28 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.27 2003/09/10 22:21:04 chr32 Removing > jdk 1.2 dependencies. Index: ProxyFactory.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyFactory.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ProxyFactory.java 10 Sep 2003 22:21:04 -0000 1.23 --- ProxyFactory.java 30 Sep 2003 18:39:08 -0000 1.24 *************** *** 41,45 **** Object delegate = Proxy.newProxyInstance( ! realConnection.getClass().getClassLoader(), realConnection.getClass().getInterfaces(), new ProxyConnection(realConnection, id, url, connectionPool, status)); --- 41,45 ---- Object delegate = Proxy.newProxyInstance( ! null, realConnection.getClass().getInterfaces(), new ProxyConnection(realConnection, id, url, connectionPool, status)); *************** *** 56,60 **** protected static Connection getConnection(ProxyConnectionIF proxyConnection) { return (Connection) Proxy.newProxyInstance( ! Connection.class.getClassLoader(), new Class[]{Connection.class}, (InvocationHandler) proxyConnection); --- 56,60 ---- protected static Connection getConnection(ProxyConnectionIF proxyConnection) { return (Connection) Proxy.newProxyInstance( ! null, new Class[]{Connection.class}, (InvocationHandler) proxyConnection); *************** *** 103,107 **** } */ ! return (Statement) Proxy.newProxyInstance(delegate.getClass().getClassLoader(), interfaces, new ProxyStatement(delegate, connectionPool, proxyConnection, sqlStatement)); } --- 103,107 ---- } */ ! return (Statement) Proxy.newProxyInstance(null, interfaces, new ProxyStatement(delegate, connectionPool, proxyConnection, sqlStatement)); } *************** *** 114,118 **** protected static DatabaseMetaData getDatabaseMetaData(Connection connection, ProxyConnectionIF proxyConnection) throws SQLException { return (DatabaseMetaData) Proxy.newProxyInstance( ! DatabaseMetaData.class.getClassLoader(), new Class[]{DatabaseMetaData.class}, new ProxyDatabaseMetaData(connection, proxyConnection) --- 114,118 ---- protected static DatabaseMetaData getDatabaseMetaData(Connection connection, ProxyConnectionIF proxyConnection) throws SQLException { return (DatabaseMetaData) Proxy.newProxyInstance( ! null, new Class[]{DatabaseMetaData.class}, new ProxyDatabaseMetaData(connection, proxyConnection) *************** *** 126,129 **** --- 126,132 ---- Revision history: $Log$ + Revision 1.24 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.23 2003/09/10 22:21:04 chr32 Removing > jdk 1.2 dependencies. Index: ProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ProxyStatement.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ProxyStatement.java 29 Sep 2003 17:48:49 -0000 1.21 --- ProxyStatement.java 30 Sep 2003 18:39:08 -0000 1.22 *************** *** 12,16 **** import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import java.sql.SQLException; import java.sql.Statement; --- 12,15 ---- *************** *** 80,99 **** } catch (InvocationTargetException e) { exception = e; ! if (e.getTargetException() instanceof SQLException) { ! final SQLException sqlException = (SQLException) e.getTargetException(); ! if (testException(sqlException)) { ! // This is really a fatal one ! FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), sqlException); ! } } throw e.getTargetException(); } catch (Exception e) { exception = e; ! if (e instanceof SQLException) { ! final SQLException sqlException = (SQLException) e; ! if (testException(sqlException)) { ! // This is really a fatal one ! FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), sqlException); ! } } throw e; --- 79,92 ---- } catch (InvocationTargetException e) { exception = e; ! if (testException(e.getTargetException())) { ! // This is really a fatal one ! FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), e.getTargetException()); } throw e.getTargetException(); } catch (Exception e) { exception = e; ! if (testException(e)) { ! // This is really a fatal one ! FatalSqlExceptionHelper.throwFatalSQLException(getConnectionPool().getDefinition().getFatalSqlExceptionWrapper(), e); } throw e; *************** *** 119,122 **** --- 112,118 ---- Revision history: $Log$ + Revision 1.22 2003/09/30 18:39:08 billhorsman + New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties. + Revision 1.21 2003/09/29 17:48:49 billhorsman New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you |