[jboss-cvs] JBossAS SVN: r103316 - in projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning: hierarchy and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 31 08:36:29 EDT 2010
Author: alesj
Date: 2010-03-31 08:36:27 -0400 (Wed, 31 Mar 2010)
New Revision: 103316
Added:
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPlugin.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPluginFactory.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyTypeVisitor.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/spi/
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/spi/HierarchyIndex.java
Removed:
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/HierarchyTypeVisitor.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPlugin.java
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPluginFactory.java
Modified:
projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java
Log:
Make hierarchy usage more generic.
Added: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexImpl.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -0,0 +1,95 @@
+/*
+ * 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.hierarchy.plugins;
+
+import java.util.*;
+
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
+import org.jboss.scanning.plugins.helpers.MergeUtils;
+import org.jboss.scanning.spi.ScanningHandle;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HierarchyIndexImpl implements HierarchyIndex, ScanningHandle<HierarchyIndexImpl>
+{
+ /** The inherited types */
+ private Map<String, Map<TypeInfo, Set<TypeInfo>>> cache = new HashMap<String, Map<TypeInfo, Set<TypeInfo>>>();
+ /** The type info factory */
+ private TypeInfoFactory tif;
+
+ void cleanup()
+ {
+ cache.clear();
+ }
+
+ Map<String, Map<TypeInfo, Set<TypeInfo>>> getCache()
+ {
+ return cache;
+ }
+
+ public void merge(HierarchyIndexImpl subHandle)
+ {
+ MergeUtils.doubleMerge(cache, subHandle.getCache());
+ }
+
+ void putInfo(String path, TypeInfo key, TypeInfo... classes)
+ {
+ if (tif == null)
+ tif = key.getTypeInfoFactory();
+
+ Map<TypeInfo, Set<TypeInfo>> map = cache.get(path);
+ if (map == null)
+ {
+ map = new HashMap<TypeInfo, Set<TypeInfo>>();
+ cache.put(path, map);
+ }
+ Set<TypeInfo> infos = map.get(key);
+ if (infos == null)
+ {
+ infos = new HashSet<TypeInfo>();
+ map.put(key, infos);
+ }
+ infos.addAll(Arrays.asList(classes));
+ }
+
+ public Set<TypeInfo> getInheritedClasses(String path, TypeInfo superTypeToLookFor)
+ {
+ Set<TypeInfo> result = null;
+ Map<TypeInfo, Set<TypeInfo>> map = cache.get(path);
+ if (map != null)
+ result = map.get(superTypeToLookFor);
+
+ return result == null || result.isEmpty() ? Collections.<TypeInfo>emptySet() : Collections.unmodifiableSet(result);
+ }
+
+ public Set<TypeInfo> getInheritedClasses(String path, Class<?> superTypeToLookFor)
+ {
+ if (tif == null) // we haven't cached anything yet
+ return Collections.emptySet();
+
+ return getInheritedClasses(path, tif.getTypeInfo(superTypeToLookFor));
+ }
+}
Copied: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPlugin.java (from rev 103312, projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPlugin.java)
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPlugin.java (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPlugin.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -0,0 +1,78 @@
+/*
+ * 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.hierarchy.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.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
+import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
+import org.jboss.scanning.plugins.visitor.ReflectProvider;
+import org.jboss.scanning.spi.helpers.AbstractScanningPlugin;
+
+/**
+ * Default resource index.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HierarchyIndexScanningPlugin extends AbstractScanningPlugin<HierarchyIndexImpl, HierarchyIndex>
+{
+ /** The reosurces */
+ private final HierarchyIndexImpl hierarchy;
+ /** The visitor */
+ private final ResourceVisitor visitor;
+
+ public HierarchyIndexScanningPlugin(ReflectProvider provider, ResourceOwnerFinder finder)
+ {
+ hierarchy = new HierarchyIndexImpl();
+ visitor = new HierarchyTypeVisitor(provider, finder, hierarchy);
+ }
+
+ protected HierarchyIndexImpl doCreateHandle()
+ {
+ return hierarchy;
+ }
+
+ @Override
+ public void cleanupHandle(HierarchyIndex handle)
+ {
+ if (handle instanceof HierarchyIndexImpl)
+ HierarchyIndexImpl.class.cast(handle).cleanup();
+ }
+
+ public Class<HierarchyIndex> getHandleInterface()
+ {
+ return HierarchyIndex.class;
+ }
+
+ public ResourceFilter getFilter()
+ {
+ return ClassFilter.INSTANCE;
+ }
+
+ public void visit(ResourceContext resource)
+ {
+ visitor.visit(resource);
+ }
+}
\ No newline at end of file
Copied: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPluginFactory.java (from rev 102988, projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPluginFactory.java)
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPluginFactory.java (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyIndexScanningPluginFactory.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -0,0 +1,62 @@
+/*
+ * 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.hierarchy.plugins;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
+import org.jboss.scanning.plugins.DeploymentScanningPluginFactory;
+import org.jboss.scanning.plugins.helpers.DeploymentUtilsFactory;
+import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
+import org.jboss.scanning.plugins.visitor.ReflectProvider;
+import org.jboss.scanning.spi.ScanningPlugin;
+
+/**
+ * Default resource index.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HierarchyIndexScanningPluginFactory implements DeploymentScanningPluginFactory<HierarchyIndexImpl, HierarchyIndex>
+{
+ private String attachmentKey;
+
+ public HierarchyIndexScanningPluginFactory()
+ {
+ }
+
+ public HierarchyIndexScanningPluginFactory(String attachmentKey)
+ {
+ this.attachmentKey = attachmentKey;
+ }
+
+ public boolean isRelevant(DeploymentUnit unit)
+ {
+ return attachmentKey == null || unit.isAttachmentPresent(attachmentKey);
+ }
+
+ public ScanningPlugin<HierarchyIndexImpl, HierarchyIndex> create(DeploymentUnit unit)
+ {
+ ReflectProvider provider = DeploymentUtilsFactory.getProvider(unit);
+ ResourceOwnerFinder finder = DeploymentUtilsFactory.getFinder(unit);
+ return new HierarchyIndexScanningPlugin(provider, finder);
+ }
+}
\ No newline at end of file
Copied: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyTypeVisitor.java (from rev 103147, projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/HierarchyTypeVisitor.java)
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyTypeVisitor.java (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/plugins/HierarchyTypeVisitor.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -0,0 +1,102 @@
+/*
+ * 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.hierarchy.plugins;
+
+import java.net.URL;
+
+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.reflect.spi.InterfaceInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
+import org.jboss.scanning.plugins.visitor.ReflectProvider;
+import org.jboss.scanning.plugins.visitor.ReflectResourceVisitor;
+
+/**
+ * Hierarchy type visitor.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class HierarchyTypeVisitor extends ReflectResourceVisitor
+{
+ private ResourceOwnerFinder finder;
+ private HierarchyIndexImpl index;
+ private TypeInfo OBJECT;
+
+ public HierarchyTypeVisitor(ReflectProvider provider, ResourceOwnerFinder finder, HierarchyIndexImpl index)
+ {
+ super(provider);
+ if (finder == null)
+ throw new IllegalArgumentException("Null finder");
+ if (index == null)
+ throw new IllegalArgumentException("Null index");
+ this.finder = finder;
+ this.index = index;
+ }
+
+ public ResourceFilter getFilter()
+ {
+ return ClassFilter.INSTANCE;
+ }
+
+ @Override
+ protected void handleClass(ResourceContext resource, ClassInfo classInfo) throws Exception
+ {
+ URL ownerURL = finder.findOwnerURL(resource);
+ String path = ownerURL.getPath();
+ handleInterfaces(path, classInfo, classInfo); // handle target's interfaces
+ recurse(path, classInfo, classInfo.getSuperclass()); // recurse on super class
+ }
+
+ private void recurse(String path, final ClassInfo ci, ClassInfo sub)
+ {
+ if (sub == null)
+ return;
+
+ if (OBJECT == null)
+ OBJECT = sub.getTypeInfoFactory().getTypeInfo(Object.class);
+
+ if (sub == OBJECT) // no need to index Object sub-types
+ return;
+
+ index.putInfo(path, ci, sub); // sub on ref
+ handleInterfaces(path, ci, sub); // sub on ref's interfaces
+
+ // recurse
+ recurse(path, ci, sub.getSuperclass());
+ }
+
+ private void handleInterfaces(String path, ClassInfo ci, ClassInfo ref)
+ {
+ InterfaceInfo[] ifaces = ref.getInterfaces();
+ if (ifaces != null)
+ {
+ for (InterfaceInfo ii : ifaces)
+ {
+ recurse(path, ci, ii); // recurse on interface
+ }
+ }
+ }
+}
\ No newline at end of file
Added: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/spi/HierarchyIndex.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/spi/HierarchyIndex.java (rev 0)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/hierarchy/spi/HierarchyIndex.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -0,0 +1,32 @@
+package org.jboss.scanning.hierarchy.spi;
+
+import java.util.Set;
+
+import org.jboss.reflect.spi.TypeInfo;
+
+
+/**
+ * Index the class hierarchy.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface HierarchyIndex
+{
+ /**
+ * Get inherited classes.
+ *
+ * @param path the classpath entry path
+ * @param superTypeToLookFor the super type to inherit
+ * @return set of matching inherited classes
+ */
+ Set<TypeInfo> getInheritedClasses(String path, TypeInfo superTypeToLookFor);
+
+ /**
+ * Get inherited classes.
+ *
+ * @param path the classpath entry path
+ * @param superTypeToLookFor the super type to inherit
+ * @return set of matching inherited classes
+ */
+ Set<TypeInfo> getInheritedClasses(String path, Class<?> superTypeToLookFor);
+}
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-03-31 12:33:50 UTC (rev 103315)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/DefaultResourcesIndex.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -24,14 +24,13 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Set;
import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
import org.jboss.scanning.annotations.spi.AnnotationIndex;
import org.jboss.scanning.annotations.spi.Element;
-import org.jboss.scanning.plugins.helpers.MergeUtils;
-import org.jboss.scanning.spi.ScanningHandle;
+import org.jboss.scanning.hierarchy.spi.HierarchyIndex;
import org.jboss.scanning.web.spi.ResourcesIndex;
import org.jboss.vfs.VirtualFile;
@@ -40,57 +39,23 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class DefaultResourcesIndex implements ResourcesIndex, ScanningHandle<DefaultResourcesIndex>
+public class DefaultResourcesIndex implements ResourcesIndex
{
/** The annotation index */
- private AnnotationIndex index;
- /** The inherited types */
- private Map<String, Map<TypeInfo, Set<TypeInfo>>> cache = new HashMap<String, Map<TypeInfo, Set<TypeInfo>>>();
- /** The type info factory */
- private TypeInfoFactory tif;
+ private AnnotationIndex annotations;
+ /** The hierarchy index */
+ private HierarchyIndex hierarchy;
- public DefaultResourcesIndex(AnnotationIndex index)
+ public DefaultResourcesIndex(AnnotationIndex annotations, HierarchyIndex hierarchy)
{
- if (index == null)
- throw new IllegalArgumentException("Null index");
- this.index = index;
+ if (annotations == null)
+ throw new IllegalArgumentException("Null annotations index");
+ if (hierarchy == null)
+ throw new IllegalArgumentException("Null hierarchy index");
+ this.annotations = annotations;
+ this.hierarchy = hierarchy;
}
- void cleanup()
- {
- cache.clear();
- }
-
- Map<String, Map<TypeInfo, Set<TypeInfo>>> getCache()
- {
- return cache;
- }
-
- public void merge(DefaultResourcesIndex subHandle)
- {
- MergeUtils.doubleMerge(cache, subHandle.getCache());
- }
-
- void putInfo(String path, TypeInfo key, TypeInfo... classes)
- {
- if (tif == null)
- tif = key.getTypeInfoFactory();
-
- Map<TypeInfo, Set<TypeInfo>> map = cache.get(path);
- if (map == null)
- {
- map = new HashMap<TypeInfo, Set<TypeInfo>>();
- cache.put(path, map);
- }
- Set<TypeInfo> infos = map.get(key);
- if (infos == null)
- {
- infos = new HashSet<TypeInfo>();
- map.put(key, infos);
- }
- infos.addAll(Arrays.asList(classes));
- }
-
public <A extends Annotation> Set<Class<?>> getAnnotatedClasses(VirtualFile cpEntry, Class<A> annotationToLookFor)
{
if (cpEntry == null)
@@ -99,13 +64,14 @@
throw new IllegalArgumentException("Null annotation class");
String path = cpEntry.getPathName();
- Set<Element<A, AnnotatedElement>> elements = index.getAnnotatedClasses(path, annotationToLookFor, null);
+ Set<Element<A, AnnotatedElement>> elements = annotations.getAnnotatedClasses(path, annotationToLookFor, null);
Set<Class<?>> results = new HashSet<Class<?>>();
for (Element<A, AnnotatedElement> elt : elements)
results.add(elt.getOwner());
return results;
}
+ @SuppressWarnings("deprecation")
public Set<Class<?>> getInheritedClasses(VirtualFile cpEntry, Class<?> superTypeToLookFor)
{
if (cpEntry == null)
@@ -113,23 +79,9 @@
if (superTypeToLookFor == null)
throw new IllegalArgumentException("Null super type");
- // we haven't added anything yet to cache
- if (tif == null)
- return Collections.emptySet();
-
Set<Class<?>> result = new HashSet<Class<?>>();
- String path = cpEntry.getPathName();
- Map<TypeInfo, Set<TypeInfo>> map = cache.get(path);
- if (map != null)
- {
- TypeInfo key = tif.getTypeInfo(superTypeToLookFor);
- Set<TypeInfo> infos = map.get(key);
- if (infos != null)
- {
- for (TypeInfo ti : infos)
- result.add(ti.getType());
- }
- }
+ for (TypeInfo ti : hierarchy.getInheritedClasses(cpEntry.getPathName(), superTypeToLookFor))
+ result.add(ti.getType());
return result;
}
}
Deleted: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/HierarchyTypeVisitor.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/HierarchyTypeVisitor.java 2010-03-31 12:33:50 UTC (rev 103315)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/HierarchyTypeVisitor.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -1,102 +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.web.plugins;
-
-import java.net.URL;
-
-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.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
-import org.jboss.scanning.plugins.visitor.ReflectProvider;
-import org.jboss.scanning.plugins.visitor.ReflectResourceVisitor;
-
-/**
- * Hierarchy type visitor.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class HierarchyTypeVisitor extends ReflectResourceVisitor
-{
- private ResourceOwnerFinder finder;
- private DefaultResourcesIndex index;
- private TypeInfo OBJECT;
-
- public HierarchyTypeVisitor(ReflectProvider provider, ResourceOwnerFinder finder, DefaultResourcesIndex index)
- {
- super(provider);
- if (finder == null)
- throw new IllegalArgumentException("Null finder");
- if (index == null)
- throw new IllegalArgumentException("Null index");
- this.finder = finder;
- this.index = index;
- }
-
- public ResourceFilter getFilter()
- {
- return ClassFilter.INSTANCE;
- }
-
- @Override
- protected void handleClass(ResourceContext resource, ClassInfo classInfo) throws Exception
- {
- URL ownerURL = finder.findOwnerURL(resource);
- String path = ownerURL.getPath();
- handleInterfaces(path, classInfo, classInfo); // handle target's interfaces
- recurse(path, classInfo, classInfo.getSuperclass()); // recurse on super class
- }
-
- private void recurse(String path, final ClassInfo ci, ClassInfo sub)
- {
- if (sub == null)
- return;
-
- if (OBJECT == null)
- OBJECT = sub.getTypeInfoFactory().getTypeInfo(Object.class);
-
- if (sub == OBJECT) // no need to index Object sub-types
- return;
-
- index.putInfo(path, ci, sub); // sub on ref
- handleInterfaces(path, ci, sub); // sub on ref's interfaces
-
- // recurse
- recurse(path, ci, sub.getSuperclass());
- }
-
- private void handleInterfaces(String path, ClassInfo ci, ClassInfo ref)
- {
- InterfaceInfo[] ifaces = ref.getInterfaces();
- if (ifaces != null)
- {
- for (InterfaceInfo ii : ifaces)
- {
- recurse(path, ci, ii); // recurse on interface
- }
- }
- }
-}
\ No newline at end of file
Deleted: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPlugin.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPlugin.java 2010-03-31 12:33:50 UTC (rev 103315)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPlugin.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -1,80 +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.web.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.classloading.spi.visitor.ResourceVisitor;
-import org.jboss.scanning.annotations.spi.AnnotationIndex;
-import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
-import org.jboss.scanning.plugins.visitor.ReflectProvider;
-import org.jboss.scanning.spi.helpers.AbstractScanningPlugin;
-import org.jboss.scanning.web.spi.ResourcesIndex;
-
-/**
- * Default resource index.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class ResourcesIndexScanningPlugin extends AbstractScanningPlugin<DefaultResourcesIndex, ResourcesIndex>
-{
- /** The reosurces */
- private final DefaultResourcesIndex resources;
- /** The visitor */
- private final ResourceVisitor visitor;
-
- public ResourcesIndexScanningPlugin(ReflectProvider provider, ResourceOwnerFinder finder, AnnotationIndex index)
- {
- resources = new DefaultResourcesIndex(index);
- visitor = new HierarchyTypeVisitor(provider, finder, resources);
- }
-
- @Override
- protected DefaultResourcesIndex doCreateHandle()
- {
- return resources;
- }
-
- @Override
- public void cleanupHandle(ResourcesIndex handle)
- {
- if (handle instanceof DefaultResourcesIndex)
- DefaultResourcesIndex.class.cast(handle).cleanup();
- }
-
- public Class<ResourcesIndex> getHandleInterface()
- {
- return ResourcesIndex.class;
- }
-
- public ResourceFilter getFilter()
- {
- return ClassFilter.INSTANCE;
- }
-
- public void visit(ResourceContext resource)
- {
- visitor.visit(resource);
- }
-}
\ No newline at end of file
Deleted: projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPluginFactory.java
===================================================================
--- projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPluginFactory.java 2010-03-31 12:33:50 UTC (rev 103315)
+++ projects/scanning/trunk/plugins/src/main/java/org/jboss/scanning/web/plugins/ResourcesIndexScanningPluginFactory.java 2010-03-31 12:36:27 UTC (rev 103316)
@@ -1,53 +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.web.plugins;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.scanning.annotations.spi.AnnotationIndex;
-import org.jboss.scanning.plugins.DeploymentScanningPluginFactory;
-import org.jboss.scanning.plugins.helpers.DeploymentUtilsFactory;
-import org.jboss.scanning.plugins.helpers.ResourceOwnerFinder;
-import org.jboss.scanning.plugins.visitor.ReflectProvider;
-import org.jboss.scanning.spi.ScanningPlugin;
-import org.jboss.scanning.web.spi.ResourcesIndex;
-
-/**
- * Default resource index.
- *
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class ResourcesIndexScanningPluginFactory implements DeploymentScanningPluginFactory<DefaultResourcesIndex, ResourcesIndex>
-{
- public boolean isRelevant(DeploymentUnit unit)
- {
- return unit.isAttachmentPresent("org.jboss.metadata.web.X.JBossWebMetaData");
- }
-
- public ScanningPlugin<DefaultResourcesIndex, ResourcesIndex> create(DeploymentUnit unit)
- {
- ReflectProvider provider = DeploymentUtilsFactory.getProvider(unit);
- ResourceOwnerFinder finder = DeploymentUtilsFactory.getFinder(unit);
- AnnotationIndex index = DeploymentUtilsFactory.getLazyUtilProxy(unit, AnnotationIndex.class);
- return new ResourcesIndexScanningPlugin(provider, finder, index);
- }
-}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list