Author: fhanik Date: Fri Apr 29 17:33:15 2011 New Revision: 1097895 URL: http://svn.apache.org/viewvc?rev=1097895&view=rev Log: https://issues.apache.org/bugzilla/show_bug.cgi?id=48817 Add in setValidator to support dependency injection frameworks like Spring etc
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=1097895&r1=1097894&r2=1097895&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Fri Apr 29 17:33:15 2011 @@ -844,6 +844,14 @@ public class DataSourceProxy implements public Validator getValidator() { return getPoolProperties().getValidator(); } + + /** + * {@inheritDoc} + */ + public void setValidator(Validator validator) { + getPoolProperties().setValidator(validator); + } + /** * {@inheritDoc} Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java?rev=1097895&r1=1097894&r2=1097895&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java Fri Apr 29 17:33:15 2011 @@ -542,6 +542,13 @@ public interface PoolConfiguration { * @return the optional validator object - may be null */ public Validator getValidator(); + + /** + * Sets the validator object + * If this is a non null object, it will be used as a validator instead of the validationQuery + * If this is null, remove the usage of the validator. + */ + public void setValidator(Validator validator); /** * avoid excess validation, only run validation at most at this frequency - time in milliseconds. Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=1097895&r1=1097894&r2=1097895&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Fri Apr 29 17:33:15 2011 @@ -358,6 +358,19 @@ public class PoolProperties implements P public Validator getValidator() { return validator; } + + /** + * {@inheritDoc} + */ + public void setValidator(Validator validator) { + this.validator = validator; + if (validator!=null) { + this.validatorClassName = validator.getClass().getName(); + } else { + this.validatorClassName = null; + } + } + /** * {@inheritDoc} Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java?rev=1097895&r1=1097894&r2=1097895&view=diff ============================================================================== --- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java (original) +++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Fri Apr 29 17:33:15 2011 @@ -638,4 +638,13 @@ public class ConnectionPool extends Noti //noop } + /** + * {@inheritDoc} + */ + public void setValidator(Validator validator) { + //noop + } + + + } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org