tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r676391 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/catalina/util/DefaultAnnotationProcessor.java webapps/docs/changelog.xml
Date Sun, 13 Jul 2008 18:20:40 GMT
Author: markt
Date: Sun Jul 13 11:20:40 2008
New Revision: 676391

URL: http://svn.apache.org/viewvc?rev=676391&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45285
Need to look for annotations in class hierarchy

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/DefaultAnnotationProcessor.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=676391&r1=676390&r2=676391&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Sun Jul 13 11:20:40 2008
@@ -48,12 +48,6 @@
   +1: fhanik
   -1: 
 
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=45285
-  Need to look for annotations in class hierarchy
-  http://people.apache.org/~markt/patches/2008-07-09-bug45285.patch
-  +1: markt, jfclere, remm
-  -1: 
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42678
   Only ignore docBase it it really is a subdir of appBase
   Patch provided by juergen

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/DefaultAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/DefaultAnnotationProcessor.java?rev=676391&r1=676390&r2=676391&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/DefaultAnnotationProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/util/DefaultAnnotationProcessor.java Sun
Jul 13 11:20:40 2008
@@ -127,62 +127,67 @@
             return;
         }
         
-        // Initialize fields annotations
-        Field[] fields = instance.getClass().getDeclaredFields();
-        for (int i = 0; i < fields.length; i++) {
-            if (fields[i].isAnnotationPresent(Resource.class)) {
-                Resource annotation = (Resource) fields[i].getAnnotation(Resource.class);
-                lookupFieldResource(context, instance, fields[i], annotation.name());
-            }
-            if (fields[i].isAnnotationPresent(EJB.class)) {
-                EJB annotation = (EJB) fields[i].getAnnotation(EJB.class);
-                lookupFieldResource(context, instance, fields[i], annotation.name());
-            }
-            if (fields[i].isAnnotationPresent(WebServiceRef.class)) {
-                WebServiceRef annotation = 
-                    (WebServiceRef) fields[i].getAnnotation(WebServiceRef.class);
-                lookupFieldResource(context, instance, fields[i], annotation.name());
-            }
-            if (fields[i].isAnnotationPresent(PersistenceContext.class)) {
-                PersistenceContext annotation = 
-                    (PersistenceContext) fields[i].getAnnotation(PersistenceContext.class);
-                lookupFieldResource(context, instance, fields[i], annotation.name());
-            }
-            if (fields[i].isAnnotationPresent(PersistenceUnit.class)) {
-                PersistenceUnit annotation = 
-                    (PersistenceUnit) fields[i].getAnnotation(PersistenceUnit.class);
-                lookupFieldResource(context, instance, fields[i], annotation.name());
-            }
-        }
+        Class<?> clazz = instance.getClass();
         
-        // Initialize methods annotations
-        Method[] methods = instance.getClass().getDeclaredMethods();
-        for (int i = 0; i < methods.length; i++) {
-            if (methods[i].isAnnotationPresent(Resource.class)) {
-                Resource annotation = (Resource) methods[i].getAnnotation(Resource.class);
-                lookupMethodResource(context, instance, methods[i], annotation.name());
-            }
-            if (methods[i].isAnnotationPresent(EJB.class)) {
-                EJB annotation = (EJB) methods[i].getAnnotation(EJB.class);
-                lookupMethodResource(context, instance, methods[i], annotation.name());
-            }
-            if (methods[i].isAnnotationPresent(WebServiceRef.class)) {
-                WebServiceRef annotation = 
-                    (WebServiceRef) methods[i].getAnnotation(WebServiceRef.class);
-                lookupMethodResource(context, instance, methods[i], annotation.name());
-            }
-            if (methods[i].isAnnotationPresent(PersistenceContext.class)) {
-                PersistenceContext annotation = 
-                    (PersistenceContext) methods[i].getAnnotation(PersistenceContext.class);
-                lookupMethodResource(context, instance, methods[i], annotation.name());
-            }
-            if (methods[i].isAnnotationPresent(PersistenceUnit.class)) {
-                PersistenceUnit annotation = 
-                    (PersistenceUnit) methods[i].getAnnotation(PersistenceUnit.class);
-                lookupMethodResource(context, instance, methods[i], annotation.name());
+        while (clazz != null) {
+            // Initialize fields annotations
+            Field[] fields = instance.getClass().getDeclaredFields();
+            for (int i = 0; i < fields.length; i++) {
+                if (fields[i].isAnnotationPresent(Resource.class)) {
+                    Resource annotation = (Resource) fields[i].getAnnotation(Resource.class);
+                    lookupFieldResource(context, instance, fields[i], annotation.name());
+                }
+                if (fields[i].isAnnotationPresent(EJB.class)) {
+                    EJB annotation = (EJB) fields[i].getAnnotation(EJB.class);
+                    lookupFieldResource(context, instance, fields[i], annotation.name());
+                }
+                if (fields[i].isAnnotationPresent(WebServiceRef.class)) {
+                    WebServiceRef annotation = 
+                        (WebServiceRef) fields[i].getAnnotation(WebServiceRef.class);
+                    lookupFieldResource(context, instance, fields[i], annotation.name());
+                }
+                if (fields[i].isAnnotationPresent(PersistenceContext.class)) {
+                    PersistenceContext annotation = 
+                        (PersistenceContext) fields[i].getAnnotation(PersistenceContext.class);
+                    lookupFieldResource(context, instance, fields[i], annotation.name());
+                }
+                if (fields[i].isAnnotationPresent(PersistenceUnit.class)) {
+                    PersistenceUnit annotation = 
+                        (PersistenceUnit) fields[i].getAnnotation(PersistenceUnit.class);
+                    lookupFieldResource(context, instance, fields[i], annotation.name());
+                }
+            }
+            
+            // Initialize methods annotations
+            Method[] methods = instance.getClass().getDeclaredMethods();
+            for (int i = 0; i < methods.length; i++) {
+                if (methods[i].isAnnotationPresent(Resource.class)) {
+                    Resource annotation = (Resource) methods[i].getAnnotation(Resource.class);
+                    lookupMethodResource(context, instance, methods[i], annotation.name());
+                }
+                if (methods[i].isAnnotationPresent(EJB.class)) {
+                    EJB annotation = (EJB) methods[i].getAnnotation(EJB.class);
+                    lookupMethodResource(context, instance, methods[i], annotation.name());
+                }
+                if (methods[i].isAnnotationPresent(WebServiceRef.class)) {
+                    WebServiceRef annotation = 
+                        (WebServiceRef) methods[i].getAnnotation(WebServiceRef.class);
+                    lookupMethodResource(context, instance, methods[i], annotation.name());
+                }
+                if (methods[i].isAnnotationPresent(PersistenceContext.class)) {
+                    PersistenceContext annotation = 
+                        (PersistenceContext) methods[i].getAnnotation(PersistenceContext.class);
+                    lookupMethodResource(context, instance, methods[i], annotation.name());
+                }
+                if (methods[i].isAnnotationPresent(PersistenceUnit.class)) {
+                    PersistenceUnit annotation = 
+                        (PersistenceUnit) methods[i].getAnnotation(PersistenceUnit.class);
+                    lookupMethodResource(context, instance, methods[i], annotation.name());
+                }
             }
+            
+            clazz = clazz.getSuperclass();
         }
-
     }
     
     

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=676391&r1=676390&r2=676391&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sun Jul 13 11:20:40 2008
@@ -33,6 +33,13 @@
 
 <body>
 <section name="Tomcat 6.0.18 (remm)">
+  <subsection name="Cataina">
+    <changelog>
+      <update>
+        <bug>45285</bug>: Look for annotations in class hierarchy. (markt)
+      </update>
+    </changelog>
+  </subsection>
   <subsection name="Webapps">
     <changelog>
       <update>



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


Mime
View raw message