You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by db...@apache.org on 2012/04/15 23:52:41 UTC

svn commit: r1326430 - /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java

Author: dblevins
Date: Sun Apr 15 21:52:41 2012
New Revision: 1326430

URL: http://svn.apache.org/viewvc?rev=1326430&view=rev
Log:
Ensure getAnnotatedClasses() is always functional.  Simply move the population of that to the constructor and allow link() to be called more than once (should have little to no effect).

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java?rev=1326430&r1=1326429&r2=1326430&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java Sun Apr 15 21:52:41 2012
@@ -111,6 +111,24 @@ public class AnnotationFinder implements
         }
     }
 
+    public AnnotationFinder(Archive archive) {
+        this.archive = archive;
+
+        for (Archive.Entry entry : archive) {
+            final String className = entry.getName();
+            try {
+                readClassDef(entry.getBytecode());
+            } catch (NoClassDefFoundError e) {
+                throw new NoClassDefFoundError("Could not fully load class: " + className + "\n due to:" + e.getMessage());
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        // keep track of what was originally from the archives
+        originalInfos.putAll(classInfos);
+    }
+
     public boolean hasMetaAnnotations() {
         return metaroots.size() > 0;
     }
@@ -153,21 +171,6 @@ public class AnnotationFinder implements
         }
     }
 
-    public AnnotationFinder(Archive archive) {
-        this.archive = archive;
-
-        for (Archive.Entry entry : archive) {
-            final String className = entry.getName();
-            try {
-                readClassDef(entry.getBytecode());
-            } catch (NoClassDefFoundError e) {
-                throw new NoClassDefFoundError("Could not fully load class: " + className + "\n due to:" + e.getMessage());
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
     public List<String> getAnnotatedClassNames() {
         return new ArrayList<String>(originalInfos.keySet());
     }
@@ -183,11 +186,6 @@ public class AnnotationFinder implements
      * @throws java.io.IOException
      */
     public AnnotationFinder link() {
-        // already linked?
-        if (originalInfos.size() > 0) return this;
-
-        // keep track of what was originally from the archives
-        originalInfos.putAll(classInfos);
 
         for (ClassInfo classInfo : classInfos.values().toArray(new ClassInfo[classInfos.size()])) {