[jboss-cvs] JBossAS SVN: r102738 - projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 22 19:02:48 EDT 2010


Author: alesj
Date: 2010-03-22 19:02:48 -0400 (Mon, 22 Mar 2010)
New Revision: 102738

Added:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/TempAnnotationVisitor.java
Modified:
   projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
Log:
More empty params impl.

Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-03-22 22:35:30 UTC (rev 102737)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/ScannerImpl.java	2010-03-22 23:02:48 UTC (rev 102738)
@@ -30,8 +30,10 @@
 import java.util.*;
 
 import org.jboss.classloading.plugins.vfs.PackageVisitor;
+import org.jboss.classloading.plugins.visitor.FederatedResourceVisitor;
 import org.jboss.classloading.spi.dependency.Module;
 import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
 import org.jboss.deployers.spi.deployer.helpers.AttachmentLocator;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.scanning.plugins.helpers.WeakClassLoaderHolder;
@@ -239,7 +241,22 @@
 
          if (allowQueryInvocationSearch && missingCacheAnnotations.isEmpty() == false)
          {
-            Map<Class<? extends Annotation>, Set<String>> temp = findClasses(missingCacheAnnotations);
+            Module module = AttachmentLocator.searchAncestors(unit, Module.class);
+            if (module == null)
+               throw new IllegalArgumentException("No such module: " + unit);
+
+            Map<Class<? extends Annotation>, Set<String>> temp = new HashMap<Class<? extends Annotation>, Set<String>>();
+            ResourceVisitor[] visitors = new ResourceVisitor[missingCacheAnnotations.size()];
+            int i = 0;
+            for (Class<? extends Annotation> annotation : missingCacheAnnotations)
+            {
+               Set<String> tmpStrings = new HashSet<String>();
+               temp.put(annotation, tmpStrings);
+               visitors[i++] = new TempAnnotationVisitor(null, annotation, strings);
+            }
+            ResourceVisitor visitor = new FederatedResourceVisitor(visitors, null, null);
+            module.visit(visitor, visitor.getFilter(), null, jartoScan);
+
             if (cacheNewResults)
             {
                if (map != null)
@@ -258,11 +275,6 @@
       return result;
    }
 
-   private Map<Class<? extends Annotation>, Set<String>> findClasses(Set<Class<? extends Annotation>> annotations)
-   {
-      return Collections.emptyMap(); // TODO
-   }
-
    public Set<NamedInputStream> getFilesInJar(URL jartoScan, Set<String> filePatterns)
    {
       if (jartoScan == null)

Copied: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/TempAnnotationVisitor.java (from rev 102733, projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/SingleAnnotationVisitor.java)
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/TempAnnotationVisitor.java	                        (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hibernate/TempAnnotationVisitor.java	2010-03-22 23:02:48 UTC (rev 102738)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.hibernate;
+
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.classloading.spi.visitor.ClassFilter;
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.scanning.plugins.visitor.JavassistReflectProvider;
+import org.jboss.scanning.plugins.visitor.ReflectProvider;
+import org.jboss.scanning.plugins.visitor.ReflectResourceVisitor;
+
+/**
+ * Hibernate's temp annotation visitor.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+class TempAnnotationVisitor extends ReflectResourceVisitor
+{
+   private final Class<? extends Annotation> annotation;
+   private Set<String> strings = new HashSet<String>();
+
+   public TempAnnotationVisitor(ReflectProvider provider, Class<? extends Annotation> annotation, Set<String> strings)
+   {
+      super(provider != null ? provider : new JavassistReflectProvider());
+
+      if (annotation == null)
+         throw new IllegalArgumentException("Null annotation");
+      if (strings == null)
+         strings = new HashSet<String>();
+
+      this.annotation = annotation;
+      this.strings = strings;
+   }
+
+   public ResourceFilter getFilter()
+   {
+      return ClassFilter.INSTANCE;
+   }
+
+   @Override
+   protected void doVisit(ResourceContext resource) throws Throwable
+   {
+      ClassInfo classInfo = getClassInfo(resource);
+      if (classInfo.isAnnotationPresent(annotation))
+      {
+         strings.add(classInfo.getName());
+      }
+   }
+
+   public Set<String> getStrings()
+   {
+      return strings;
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list