tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1346109 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/deploy/NamingResources.java
Date Mon, 04 Jun 2012 19:40:06 GMT
Author: markt
Date: Mon Jun  4 19:40:06 2012
New Revision: 1346109

URL: http://svn.apache.org/viewvc?rev=1346109&view=rev
Log:
Rework fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=53333

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1346107

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java?rev=1346109&r1=1346108&r2=1346109&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java Mon Jun  4 19:40:06
2012
@@ -1153,24 +1153,20 @@ public class NamingResources extends Lif
             }
         }
 
-        Class<?> injectionClass = getInjectionTargetType(context, resource);
-        if (injectionClass == null) {
+        Class<?> compatibleClass =
+                getCompatibleType(context, resource, typeClass);
+        if (compatibleClass == null) {
             // Indicates that a compatible type could not be identified that
             // worked for all injection targets
             return false;
         }
 
-        if (typeClass == null) {
-                // Only injectionTarget defined - use it
-                resource.setType(injectionClass.getCanonicalName());
-                return true;
-        } else {
-            return injectionClass.isAssignableFrom(typeClass);
-        }
+        resource.setType(compatibleClass.getCanonicalName());
+        return true;
     }
 
-    private Class<?> getInjectionTargetType(Context context,
-            ResourceBase resource) {
+    private Class<?> getCompatibleType(Context context,
+            ResourceBase resource, Class<?> typeClass) {
 
         Class<?> result = null;
 
@@ -1196,17 +1192,28 @@ public class NamingResources extends Lif
             }
             targetType = convertPrimitiveType(targetType);
 
-            // Figure out the common type - if there is one
-            if (result == null) {
-                result = targetType;
-            } else if (targetType.isAssignableFrom(result)) {
-                // NO-OP - This will work
-            } else if (result.isAssignableFrom(targetType)) {
-                // Need to use more specific type
-                result = targetType;
+            if (typeClass == null) {
+                // Need to find a common type amongst the injection targets
+                if (result == null) {
+                    result = targetType;
+                } else if (targetType.isAssignableFrom(result)) {
+                    // NO-OP - This will work
+                } else if (result.isAssignableFrom(targetType)) {
+                    // Need to use more specific type
+                    result = targetType;
+                } else {
+                    // Incompatible types
+                    return null;
+                }
             } else {
-                // Incompatible types
-                return null;
+                // Each injection target needs to be consistent with the defined
+                // type
+                if (targetType.isAssignableFrom(typeClass)) {
+                    result = typeClass;
+                } else {
+                    // Incompatible types
+                    return null;
+                }
             }
         }
         return result;



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


Mime
View raw message