implemented use equals attribute everywhere
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 24 Nov 2008 20:41:38 +0000 (20:41 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 24 Nov 2008 20:41:38 +0000 (20:41 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@720282 13f79535-47bb-0310-9956-ffa450edef68

modules/jdbc-pool/doc/jdbc-pool.xml
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java
modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java

index 40ec6b3..7f80352 100644 (file)
       <p>(boolean) Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of 
          <code>==</code> when comparing method names. This property does not apply to added interceptors as those are configured individually.
          The default value is <code>false</code>.
-      </p>   
+      </p> 
+    </attribute>    
   </attributes>  
   </subsection>
 </section>
index 6e8aeda..212be1a 100644 (file)
@@ -56,14 +56,18 @@ public abstract class JdbcInterceptor implements InvocationHandler {
         this.next = next;
     }
     
-    public boolean compare(String methodName, Method method) {
+    public boolean compare(String name1, String name2) {
         if (useEquals()) {
-            return methodName.equals(method.getName());
+            return name1.equals(name2);
         } else {
-            return methodName==method.getName();
+            return name1==name2;
         }
     }
     
+    public boolean compare(String methodName, Method method) {
+        return compare(methodName, method.getName());
+    }
+    
     /**
      * Gets called each time the connection is borrowed from the pool
      * @param parent - the connection pool owning the connection
index 80f04b6..3609ac0 100644 (file)
@@ -40,7 +40,7 @@ public abstract class  AbstractCreateStatementInterceptor extends JdbcIntercepto
     
     @Override
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-        if (CLOSE_VAL==method.getName()) {
+        if (compare(CLOSE_VAL,method)) {
             closeInvoked();
             return super.invoke(proxy, method, args);
         } else {
@@ -70,7 +70,7 @@ public abstract class  AbstractCreateStatementInterceptor extends JdbcIntercepto
 
     protected boolean process(String[] names, Method method, boolean process) {
         for (int i=0; (!process) && i<names.length; i++) {
-            process = (method.getName()==names[i]);
+            process = compare(names[i],method);
         }
         return process;
     }
index a3f5609..93653ee 100644 (file)
@@ -99,12 +99,12 @@ public class ConnectionState extends JdbcInterceptor  {
         boolean read = false;\r
         int index = -1;\r
         for (int i=0; (!read) && i<readState.length; i++) {\r
-            read = name==readState[i];\r
+            read = compare(name,readState[i]);\r
             if (read) index = i;\r
         }\r
         boolean write = false;\r
         for (int i=0; (!write) && (!read) && i<writeState.length; i++) {\r
-            write = name==writeState[i];\r
+            write = compare(name,writeState[i]);\r
             if (write) index = i;\r
         }\r
         Object result = null;\r