tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1005271 - in /tomcat/trunk: java/org/apache/catalina/core/DefaultInstanceManager.java webapps/docs/changelog.xml
Date Wed, 06 Oct 2010 21:58:38 GMT
Author: markt
Date: Wed Oct  6 21:58:37 2010
New Revision: 1005271

URL: http://svn.apache.org/viewvc?rev=1005271&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49956
Handle case when @Resource annotation uses the full JNDI name for a resource.
Based on a patch by Gurkan Erdogdu.

Modified:
    tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
    tomcat/trunk/webapps/docs/changelog.xml

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=1005271&r1=1005270&r2=1005271&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java Wed Oct  6 21:58:37
2010
@@ -454,9 +454,10 @@ public class DefaultInstanceManager impl
         Object lookedupResource;
         boolean accessibility;
 
-        if ((name != null) &&
-                (name.length() > 0)) {
-            lookedupResource = context.lookup(name);
+        String normalizedName = normalize(name);
+
+        if ((normalizedName != null) && (normalizedName.length() > 0)) {
+            lookedupResource = context.lookup(normalizedName);
         } else {
             lookedupResource =
                 context.lookup(clazz.getName() + "/" + field.getName());
@@ -495,9 +496,10 @@ public class DefaultInstanceManager impl
         Object lookedupResource;
         boolean accessibility;
 
-        if ((name != null) &&
-                (name.length() > 0)) {
-            lookedupResource = context.lookup(name);
+        String normalizedName = normalize(name);
+
+        if ((normalizedName != null) && (normalizedName.length() > 0)) {
+            lookedupResource = context.lookup(normalizedName);
         } else {
             lookedupResource = context.lookup(
                     clazz.getName() + "/" + getName(method));
@@ -520,4 +522,11 @@ public class DefaultInstanceManager impl
 
         return name.toString();
     }
+    
+    private static String normalize(String jndiName){
+        if(jndiName != null && jndiName.startsWith("java:comp/env/")){
+            return jndiName.substring(14);
+        }
+        return jndiName;
+    }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1005271&r1=1005270&r2=1005271&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Oct  6 21:58:37 2010
@@ -66,6 +66,10 @@
         <bug>49952</bug>: Allow ServletContainerInitializers to add listeners
to
         a web application. Patch provided by David Jencks. (markt)
       </fix>
+      <fix>
+        <bug>49956</bug>: Handle case when @Resource annotation uses the full
+        JNDI name for a resource. Based on a patch by Gurkan Erdogdu. (markt) 
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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


Mime
View raw message