commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1346696 - /commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java
Date Wed, 06 Jun 2012 01:25:55 GMT
Author: dblevins
Date: Wed Jun  6 01:25:54 2012
New Revision: 1346696

URL: http://svn.apache.org/viewvc?rev=1346696&view=rev
Log:
All *Info inner-classes now static, promoting to top-level shortly

Modified:
    commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java

Modified: commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java?rev=1346696&r1=1346695&r2=1346696&view=diff
==============================================================================
--- commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java
(original)
+++ commons/sandbox/classscan/branches/commons-finder/src/main/java/org/apache/commons/classscan/finder/AnnotationFinder.java
Wed Jun  6 01:25:54 2012
@@ -1042,7 +1042,7 @@ public class AnnotationFinder implements
      *
      * A bit of tweaking would be required to make them static before promoting them
      */
-    public class Annotatable {
+    public static class Annotatable {
         private final List<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
 
         public Annotatable(AnnotatedElement element) {
@@ -1062,10 +1062,6 @@ public class AnnotationFinder implements
             return annotations;
         }
 
-        public String getMetaAnnotationName() {
-            return null;
-        }
-
         /**
          * Utility method to get around some errors caused by
          * interactions between the Equinox class loaders and
@@ -1095,8 +1091,6 @@ public class AnnotationFinder implements
 
     public static interface Info {
 
-        String getMetaAnnotationName();
-
         String getName();
 
         List<AnnotationInfo> getAnnotations();
@@ -1104,7 +1098,7 @@ public class AnnotationFinder implements
         Annotation[] getDeclaredAnnotations();
     }
 
-    public class PackageInfo extends Annotatable implements Info {
+    public static class PackageInfo extends Annotatable implements Info {
         private final String name;
         private final ClassInfo info;
         private final Package pkg;
@@ -1116,8 +1110,8 @@ public class AnnotationFinder implements
             this.info = null;
         }
 
-        public PackageInfo(String name) {
-            info = new ClassInfo(name, null);
+        public PackageInfo(Archive archive, String name) {
+            info = new ClassInfo(archive, name, null);
             this.name = name;
             this.pkg = null;
         }
@@ -1148,7 +1142,7 @@ public class AnnotationFinder implements
         }
     }
 
-    public class ClassInfo extends Annotatable implements Info {
+    public static class ClassInfo extends Annotatable implements Info {
         private String name;
         private final List<MethodInfo> methods = new SingleLinkedList<MethodInfo>();
         private final List<MethodInfo> constructors = new SingleLinkedList<MethodInfo>();
@@ -1159,6 +1153,10 @@ public class AnnotationFinder implements
         private final List<FieldInfo> fields = new SingleLinkedList<FieldInfo>();
         private Class<?> clazz;
 
+        /**
+         * Allows lazy loading of the related java class
+         */
+        private Archive archive;
 
         public ClassInfo(Class clazz) {
             super(clazz);
@@ -1173,14 +1171,10 @@ public class AnnotationFinder implements
             }
         }
 
-        public ClassInfo(String name, String superType) {
+        public ClassInfo(Archive archive, String name, String superType) {
             this.name = name;
             this.superType = superType;
-        }
-
-        @Override
-        public String getMetaAnnotationName() {
-            return AnnotationFinder.this.getMetaAnnotationName(this);
+            this.archive = archive;
         }
 
         public String getPackageName() {
@@ -1217,14 +1211,9 @@ public class AnnotationFinder implements
 
         public Class<?> get() throws ClassNotFoundException {
             if (clazz != null) return clazz;
-            try {
-                final String fixedName = name.replaceFirst("<.*>", "");
-                this.clazz = archive.loadClass(fixedName);
-                return clazz;
-            } catch (ClassNotFoundException notFound) {
-                classesNotLoaded.add(name);
-                throw notFound;
-            }
+            final String fixedName = name.replaceFirst("<.*>", "");
+            this.clazz = archive.loadClass(fixedName);
+            return clazz;
         }
 
         public String toString() {
@@ -1232,7 +1221,7 @@ public class AnnotationFinder implements
         }
     }
 
-    public class MethodInfo extends Annotatable implements Info {
+    public static class MethodInfo extends Annotatable implements Info {
         private final ClassInfo declaringClass;
         private final String descriptor;
         private final String name;
@@ -1261,11 +1250,6 @@ public class AnnotationFinder implements
         }
 
         @Override
-        public String getMetaAnnotationName() {
-            return declaringClass.getMetaAnnotationName();
-        }
-
-        @Override
         public Annotation[] getDeclaredAnnotations() {
             super.getDeclaredAnnotations();
             try {
@@ -1347,7 +1331,7 @@ public class AnnotationFinder implements
 
     }
 
-    public class FieldInfo extends Annotatable implements Info {
+    public static class FieldInfo extends Annotatable implements Info {
         private final String name;
         private final String type;
         private final ClassInfo declaringClass;
@@ -1384,11 +1368,6 @@ public class AnnotationFinder implements
         }
 
         @Override
-        public String getMetaAnnotationName() {
-            return declaringClass.getMetaAnnotationName();
-        }
-
-        @Override
         public Annotation[] getDeclaredAnnotations() {
             super.getDeclaredAnnotations();
             try {
@@ -1408,7 +1387,7 @@ public class AnnotationFinder implements
 
         private Field toField() throws ClassNotFoundException {
 
-            Class<?> clazz = this.declaringClass.get();
+            final Class<?> clazz = this.declaringClass.get();
 
             try {
                 return clazz.getDeclaredField(name);
@@ -1419,7 +1398,7 @@ public class AnnotationFinder implements
         }
     }
 
-    public class AnnotationInfo extends Annotatable implements Info {
+    public static class AnnotationInfo extends Annotatable implements Info {
         private final String name;
 
         public AnnotationInfo(Annotation annotation) {
@@ -1525,10 +1504,10 @@ public class AnnotationFinder implements
         @Override
         public void visit(int version, int access, String name, String signature, String
superName, String[] interfaces) {
             if (name.endsWith("package-info")) {
-                info = new PackageInfo(javaName(name));
+                info = new PackageInfo(archive, javaName(name));
             } else {
 
-                ClassInfo classInfo = new ClassInfo(javaName(name), javaName(superName));
+                ClassInfo classInfo = new ClassInfo(archive, javaName(name), javaName(superName));
 
                 for (String interfce : interfaces) {
                     classInfo.getInterfaces().add(javaName(interfce));



Mime
View raw message