tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r995224 - /tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
Date Wed, 08 Sep 2010 19:45:16 GMT
Author: markt
Date: Wed Sep  8 19:45:16 2010
New Revision: 995224

URL: http://svn.apache.org/viewvc?rev=995224&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49892
Correct JNDI name for method resource injections
Based on a patch by Gurkan Erdogdu

Modified:
    tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java

Modified: tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java?rev=995224&r1=995223&r2=995224&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java Wed Sep  8 19:45:16
2010
@@ -485,6 +485,7 @@ public class DefaultInstanceManager impl
             throws NamingException, IllegalAccessException, InvocationTargetException {
 
         if (!method.getName().startsWith("set")
+                || method.getName().length() < 4
                 || method.getParameterTypes().length != 1
                 || !method.getReturnType().getName().equals("void")) {
             throw new IllegalArgumentException("Invalid method resource injection annotation");
@@ -498,7 +499,7 @@ public class DefaultInstanceManager impl
             lookedupResource = context.lookup(name);
         } else {
             lookedupResource = context.lookup(
-                    clazz.getName() + "/" + method.getName().substring(3));
+                    clazz.getName() + "/" + getName(method));
         }
 
         accessibility = method.isAccessible();
@@ -506,4 +507,16 @@ public class DefaultInstanceManager impl
         method.invoke(instance, lookedupResource);
         method.setAccessible(accessibility);
     }
+
+        public static String getName(Method setter) {
+            StringBuilder name = new StringBuilder(setter.getName());
+
+            // remove 'set'
+            name.delete(0, 3);
+
+            // lowercase first char
+            name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+
+            return name.toString();
+        }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message