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 2011/07/18 06:59:28 UTC

svn commit: r1147744 - in /geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder: AnnotationFinder.java archive/ClasspathArchive.java

Author: dblevins
Date: Mon Jul 18 04:59:28 2011
New Revision: 1147744

URL: http://svn.apache.org/viewvc?rev=1147744&view=rev
Log:
tweak ClasspathArchive so it can discover and return the right archive type for individual urls
also tweak AnnotationFinder so it can return the Archive

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/ClasspathArchive.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=1147744&r1=1147743&r2=1147744&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 Mon Jul 18 04:59:28 2011
@@ -91,6 +91,10 @@ public class AnnotationFinder implements
         return new ArrayList<String>(originalInfos.keySet());
     }
 
+    public Archive getArchive() {
+        return archive;
+    }
+
     /**
      * The link() method must be called to successfully use the findSubclasses and findImplementations methods
      *

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/ClasspathArchive.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/ClasspathArchive.java?rev=1147744&r1=1147743&r2=1147744&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/ClasspathArchive.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/archive/ClasspathArchive.java Mon Jul 18 04:59:28 2011
@@ -49,36 +49,42 @@ public class ClasspathArchive extends Co
 
         for (URL location : urls) {
             try {
+                archives.add(archive(loader, location));
+            } catch (Exception e) {
+                // TODO This is what we did before, so not too urgent to change, but not ideal
+                e.printStackTrace();
+            }
+        }
+
+        return archives;
+    }
 
-                if (location.getProtocol().equals("jar")) {
+    public static Archive archive(ClassLoader loader, URL location) {
 
-                    archives.add(new JarArchive(loader, location));
+        if (location.getProtocol().equals("jar")) {
 
-                } else if (location.getProtocol().equals("file")) {
+            return new JarArchive(loader, location);
 
-                    try {
+        } else if (location.getProtocol().equals("file")) {
 
-                        // See if it's actually a jar
+            try {
 
-                        URL jarUrl = new URL("jar", "", location.toExternalForm() + "!/");
-                        JarURLConnection juc = (JarURLConnection) jarUrl.openConnection();
-                        juc.getJarFile();
+                // See if it's actually a jar
 
-                        archives.add(new JarArchive(loader, jarUrl));
+                URL jarUrl = new URL("jar", "", location.toExternalForm() + "!/");
+                JarURLConnection juc = (JarURLConnection) jarUrl.openConnection();
+                juc.getJarFile();
 
-                    } catch (IOException e) {
+                return new JarArchive(loader, jarUrl);
 
-                        archives.add(new FileArchive(loader, location));
+            } catch (IOException e) {
+
+                return new FileArchive(loader, location);
 
-                    }
-                }
-            } catch (Exception e) {
-                // TODO This is what we did before, so not too urgent to change, but not ideal
-                e.printStackTrace();
             }
         }
 
-        return archives;
+        throw new UnsupportedOperationException("unsupported archive type: " + location);
     }
 
     public static List<Archive> archives(ClassLoader loader, URL... urls) {