https://issues.apache.org/bugzilla/show_bug.cgi?id=48817
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 29 Apr 2011 17:33:15 +0000 (17:33 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 29 Apr 2011 17:33:15 +0000 (17:33 +0000)
Add in setValidator to support dependency injection frameworks like Spring etc

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1097895 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java

index e839991..225d07a 100644 (file)
@@ -844,6 +844,14 @@ public class DataSourceProxy implements PoolConfiguration {
     public Validator getValidator() {
         return getPoolProperties().getValidator();
     }
+    
+    /** 
+     * {@inheritDoc}
+     */
+    public void setValidator(Validator validator) {
+        getPoolProperties().setValidator(validator);
+    }
+
 
     /** 
      * {@inheritDoc}
index b8d2515..b4ddb34 100644 (file)
@@ -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. 
index be01339..5a1272f 100644 (file)
@@ -358,6 +358,19 @@ public class PoolProperties implements PoolConfiguration {
     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}
index 657cf0e..6e6100b 100644 (file)
@@ -638,4 +638,13 @@ public class ConnectionPool extends NotificationBroadcasterSupport implements Co
         //noop
     }
 
+    /** 
+     * {@inheritDoc}
+     */
+    public void setValidator(Validator validator) {
+        //noop
+    }
+    
+    
+
 }