[jboss-cvs] JBossAS SVN: r106059 - in projects/scanning/trunk: scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 15 12:48:20 EDT 2010
Author: alesj
Date: 2010-06-15 12:48:19 -0400 (Tue, 15 Jun 2010)
New Revision: 106059
Removed:
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/InterfacesAnnotationVisitor.java
Modified:
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/AnnotationsScanningPlugin.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/GenericAnnotationVisitor.java
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/ClassHierarchyResourceVisitor.java
Log:
Remove extra visitor.
Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/AnnotationsScanningPlugin.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/AnnotationsScanningPlugin.java 2010-06-15 16:28:24 UTC (rev 106058)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/AnnotationsScanningPlugin.java 2010-06-15 16:48:19 UTC (rev 106059)
@@ -22,7 +22,6 @@
package org.jboss.scanning.annotations.plugins;
-import org.jboss.classloading.spi.visitor.ClassFilter;
import org.jboss.classloading.spi.visitor.ResourceContext;
import org.jboss.classloading.spi.visitor.ResourceFilter;
import org.jboss.scanning.annotations.spi.AnnotationIndex;
@@ -43,9 +42,7 @@
/** The repository */
private final DefaultAnnotationRepository repository;
/** The annotations visitor */
- private final GenericAnnotationVisitor annotations;
- /** The interfaces visitor */
- private final InterfacesAnnotationVisitor interfaces;
+ private final GenericAnnotationVisitor visitor;
public AnnotationsScanningPlugin(ClassLoader cl)
{
@@ -56,11 +53,8 @@
{
repository = new DefaultAnnotationRepository(cl);
// setup annotations visitor
- annotations = new GenericAnnotationVisitor(provider, finder, repository);
- annotations.setErrorHandler(handler);
- // setup interfaces visitor
- interfaces = new InterfacesAnnotationVisitor(provider, repository);
- interfaces.setErrorHandler(handler);
+ visitor = new GenericAnnotationVisitor(provider, finder, repository);
+ visitor.setErrorHandler(handler);
}
protected DefaultAnnotationRepository doCreateHandle()
@@ -87,12 +81,11 @@
public ResourceFilter getFilter()
{
- return ClassFilter.INSTANCE;
+ return visitor.getFilter();
}
public void visit(ResourceContext resource)
{
- annotations.visit(resource);
- interfaces.visit(resource);
+ visitor.visit(resource);
}
}
Modified: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/GenericAnnotationVisitor.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/GenericAnnotationVisitor.java 2010-06-15 16:28:24 UTC (rev 106058)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/GenericAnnotationVisitor.java 2010-06-15 16:48:19 UTC (rev 106059)
@@ -29,13 +29,17 @@
import org.jboss.classloading.spi.visitor.ClassFilter;
import org.jboss.classloading.spi.visitor.ResourceFilter;
import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.AnnotationValue;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
import org.jboss.scanning.plugins.visitor.ClassHierarchyResourceVisitor;
import org.jboss.scanning.plugins.visitor.ReflectProvider;
/**
+ * Index annotations.
+ *
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
*/
public class GenericAnnotationVisitor extends ClassHierarchyResourceVisitor
{
@@ -61,6 +65,24 @@
}
@Override
+ protected void handleRelevantClass(ClassInfo classInfo, URL ownerURL)
+ {
+ ClassInfo[] interfaces = classInfo.getInterfaces();
+ if (interfaces != null && interfaces.length > 0)
+ {
+ String className = classInfo.getName();
+ for (ClassInfo intf : interfaces)
+ {
+ for (AnnotationValue val : intf.getAnnotations())
+ {
+ String annotation = val.getAnnotationType().getName();
+ repository.addClassImplementingInterfaceAnnotatedWith(annotation, className);
+ }
+ }
+ }
+ }
+
+ @Override
protected void handleAnnotations(ElementType type, Signature signature, Annotation[] annotations, String className, URL ownerURL)
{
if (annotations != null && annotations.length > 0)
Deleted: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/InterfacesAnnotationVisitor.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/InterfacesAnnotationVisitor.java 2010-06-15 16:28:24 UTC (rev 106058)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/annotations/plugins/InterfacesAnnotationVisitor.java 2010-06-15 16:48:19 UTC (rev 106059)
@@ -1,74 +0,0 @@
-/*
- * 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.annotations.plugins;
-
-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.AnnotationValue;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.scanning.plugins.visitor.ReflectProvider;
-import org.jboss.scanning.plugins.visitor.ReflectResourceVisitor;
-
-/**
- * Index classes implementing interfaces with certain annotations.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class InterfacesAnnotationVisitor extends ReflectResourceVisitor
-{
- /** The mutable repository */
- private MutableAnnotationRepository repository;
-
- public InterfacesAnnotationVisitor(ReflectProvider provider, MutableAnnotationRepository repository)
- {
- super(provider);
- if (repository == null)
- throw new IllegalArgumentException("Null repository");
- this.repository = repository;
- }
-
- public ResourceFilter getFilter()
- {
- return ClassFilter.INSTANCE;
- }
-
- @Override
- protected void handleClass(ResourceContext resource, ClassInfo classInfo) throws Exception
- {
- ClassInfo[] interfaces = classInfo.getInterfaces();
- if (interfaces != null && interfaces.length > 0)
- {
- String className = classInfo.getName();
- for (ClassInfo intf : interfaces)
- {
- for (AnnotationValue val : intf.getAnnotations())
- {
- String annotation = val.getAnnotationType().getName();
- repository.addClassImplementingInterfaceAnnotatedWith(annotation, className);
- }
- }
- }
- }
-}
\ No newline at end of file
Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/ClassHierarchyResourceVisitor.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/ClassHierarchyResourceVisitor.java 2010-06-15 16:28:24 UTC (rev 106058)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/ClassHierarchyResourceVisitor.java 2010-06-15 16:48:19 UTC (rev 106059)
@@ -71,6 +71,8 @@
URL ownerURL = finder.findOwnerURL(resource);
+ handleRelevantClass(classInfo, ownerURL);
+
Annotation[] annotations = classInfo.getUnderlyingAnnotations();
handleAnnotations(ElementType.TYPE, (Signature) null, annotations, className, ownerURL);
@@ -100,6 +102,18 @@
}
/**
+ * Handle relevant class - extra options.
+ * Sub classes can add additional indexing logic.
+ *
+ * @param classInfo the current class info
+ * @param ownerURL the owner url
+ */
+ protected void handleRelevantClass(ClassInfo classInfo, URL ownerURL)
+ {
+ // do nothing by default
+ }
+
+ /**
* Handle members for annotations.
*
* @param type where we found the annotations
More information about the jboss-cvs-commits
mailing list