[jboss-cvs] JBossAS SVN: r104076 - in projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning: annotations/spi and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 17 08:29:35 EDT 2010


Author: alesj
Date: 2010-04-17 08:29:35 -0400 (Sat, 17 Apr 2010)
New Revision: 104076

Modified:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/DefaultAnnotationRepository.java
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/spi/AnnotationIndex.java
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/jsf/JBossAnnotationProvider.java
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java
Log:
Make path impl detail.

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/DefaultAnnotationRepository.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/DefaultAnnotationRepository.java	2010-04-17 04:47:38 UTC (rev 104075)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/DefaultAnnotationRepository.java	2010-04-17 12:29:35 UTC (rev 104076)
@@ -288,8 +288,12 @@
       return elements;
    }
 
-   public <A extends Annotation> Set<Element<A, AnnotatedElement>> getAnnotatedClasses(String path, Class<A> annotation, ElementType type)
+   public <A extends Annotation> Set<Element<A, AnnotatedElement>> getAnnotatedClasses(URL url, Class<A> annotation, ElementType type)
    {
+      if (url == null)
+         throw new IllegalArgumentException("Null url");
+
+      String path = url.getPath();
       if (type == null)
       {
          Set<Element<A, AnnotatedElement>> result = new HashSet<Element<A, AnnotatedElement>>();

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/spi/AnnotationIndex.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/spi/AnnotationIndex.java	2010-04-17 04:47:38 UTC (rev 104075)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/spi/AnnotationIndex.java	2010-04-17 12:29:35 UTC (rev 104076)
@@ -25,6 +25,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.annotation.ElementType;
 import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
 import java.util.Set;
 
 /**
@@ -38,10 +39,10 @@
     * Get all classes who have annotated type annotated with annotation param.
     *
     * @param <A> the annotation type
-    * @param path the classpath entry, if null all classes in classpath are checked
+    * @param url the classpath entry, if null all classes in classpath are checked
     * @param annotation the annotation we're querying for
     * @param type annotation element type, if null all types are matched
     * @return set of matching classes
     */
-   <A extends Annotation> Set<Element<A, AnnotatedElement>> getAnnotatedClasses(String path, Class<A> annotation, ElementType type);   
+   <A extends Annotation> Set<Element<A, AnnotatedElement>> getAnnotatedClasses(URL url, Class<A> annotation, ElementType type);
 }

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/jsf/JBossAnnotationProvider.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/jsf/JBossAnnotationProvider.java	2010-04-17 04:47:38 UTC (rev 104075)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/jsf/JBossAnnotationProvider.java	2010-04-17 12:29:35 UTC (rev 104076)
@@ -128,14 +128,12 @@
       Set<Class<?>> classes = new HashSet<Class<?>>();
       result.put(annotationClass, classes);
 
-      String path = url.getPath();
-
       Target target = annotationClass.getAnnotation(Target.class);
       ElementType[] types = target.value();
 
       for (ElementType type : types)
       {
-         Set<Element<T,AnnotatedElement>> set = index.getAnnotatedClasses(path, annotationClass, type);
+         Set<Element<T,AnnotatedElement>> set = index.getAnnotatedClasses(url, annotationClass, type);
          for (Element elt : set)
             classes.add(elt.getOwner());
       }

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java	2010-04-17 04:47:38 UTC (rev 104075)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java	2010-04-17 12:29:35 UTC (rev 104076)
@@ -24,6 +24,7 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -63,8 +64,8 @@
       if (annotationToLookFor == null)
          throw new IllegalArgumentException("Null annotation class");
 
-      String path = cpEntry.getPathName();
-      Set<Element<A, AnnotatedElement>> elements = annotations.getAnnotatedClasses(path, annotationToLookFor, null);
+      URL url = toURL(cpEntry);
+      Set<Element<A, AnnotatedElement>> elements = annotations.getAnnotatedClasses(url, annotationToLookFor, null);
       Set<Class<?>> results = new HashSet<Class<?>>();
       for (Element<A, AnnotatedElement> elt : elements)
          results.add(elt.getOwner());
@@ -84,4 +85,17 @@
          result.add(ti.getType());
       return result;
    }
+
+   protected static URL toURL(VirtualFile file)
+   {
+      try
+      {
+         return file.toURL();
+
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
 }




More information about the jboss-cvs-commits mailing list