org.apache.xbean.finder
Class AbstractFinder

java.lang.Object
  extended by org.apache.xbean.finder.AbstractFinder
All Implemented Interfaces:
IAnnotationFinder
Direct Known Subclasses:
BundleAnnotationFinder, ClassFinder

public abstract class AbstractFinder
extends Object
implements IAnnotationFinder

Version:
$Rev: 1326452 $ $Date: 2012-04-15 17:24:14 -0700 (Sun, 15 Apr 2012) $

Nested Class Summary
 class AbstractFinder.Annotatable
           
 class AbstractFinder.AnnotationInfo
           
 class AbstractFinder.ClassInfo
           
 class AbstractFinder.FieldInfo
           
static class AbstractFinder.GenericAwareInfoBuildingVisitor
           
static interface AbstractFinder.Info
           
 class AbstractFinder.InfoBuildingVisitor
           
 class AbstractFinder.MethodInfo
           
 class AbstractFinder.PackageInfo
           
 
Field Summary
protected  Map<String,AbstractFinder.ClassInfo> classInfos
           
protected  Map<String,AbstractFinder.ClassInfo> originalInfos
           
 
Constructor Summary
AbstractFinder()
           
 
Method Summary
 List<Class<?>> findAnnotatedClasses(Class<? extends Annotation> annotation)
           
 List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation)
           
 List<Field> findAnnotatedFields(Class<? extends Annotation> annotation)
           
 List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation)
           
 List<Package> findAnnotatedPackages(Class<? extends Annotation> annotation)
           
 List<Class<?>> findClassesInPackage(String packageName, boolean recursive)
           
<T> List<Class<? extends T>>
findImplementations(Class<T> clazz)
           
 List<Class<?>> findInheritedAnnotatedClasses(Class<? extends Annotation> annotation)
          Naive implementation - works extremelly slow O(n^3)
 List<Annotated<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation)
           
 List<Annotated<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation)
           
 List<Annotated<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation)
           
<T> List<Class<? extends T>>
findSubclasses(Class<T> clazz)
           
 List<String> getAnnotatedClassNames()
           
protected  List<AbstractFinder.Info> getAnnotationInfos(String name)
           
 List<String> getClassesNotLoaded()
          Returns a list of classes that could not be loaded in last invoked findAnnotated* method.
protected abstract  URL getResource(String className)
           
 boolean isAnnotationPresent(Class<? extends Annotation> annotation)
           
 AbstractFinder link()
          The link() method must be called to successfully use the findSubclasses and findImplementations methods
protected abstract  Class<?> loadClass(String fixedName)
           
protected  void readClassDef(Class clazz)
           
protected  void readClassDef(InputStream in)
           
protected  void readClassDef(InputStream in, String path)
           
protected  void readClassDef(String className)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classInfos

protected final Map<String,AbstractFinder.ClassInfo> classInfos

originalInfos

protected final Map<String,AbstractFinder.ClassInfo> originalInfos
Constructor Detail

AbstractFinder

public AbstractFinder()
Method Detail

getResource

protected abstract URL getResource(String className)

loadClass

protected abstract Class<?> loadClass(String fixedName)
                               throws ClassNotFoundException
Throws:
ClassNotFoundException

getAnnotatedClassNames

public List<String> getAnnotatedClassNames()
Specified by:
getAnnotatedClassNames in interface IAnnotationFinder

link

public AbstractFinder link()
                    throws IOException
The link() method must be called to successfully use the findSubclasses and findImplementations methods

Returns:
Throws:
IOException

isAnnotationPresent

public boolean isAnnotationPresent(Class<? extends Annotation> annotation)
Specified by:
isAnnotationPresent in interface IAnnotationFinder

getClassesNotLoaded

public List<String> getClassesNotLoaded()
Returns a list of classes that could not be loaded in last invoked findAnnotated* method.

The list will only contain entries of classes whose byte code matched the requirements of last invoked find* method, but were unable to be loaded and included in the results.

The list returned is unmodifiable. Once obtained, the returned list will be a live view of the results from the last findAnnotated* method call.

This method is not thread safe.

Specified by:
getClassesNotLoaded in interface IAnnotationFinder
Returns:
an unmodifiable live view of classes that could not be loaded in previous findAnnotated* call.

findAnnotatedPackages

public List<Package> findAnnotatedPackages(Class<? extends Annotation> annotation)
Specified by:
findAnnotatedPackages in interface IAnnotationFinder

findAnnotatedClasses

public List<Class<?>> findAnnotatedClasses(Class<? extends Annotation> annotation)
Specified by:
findAnnotatedClasses in interface IAnnotationFinder

findMetaAnnotatedClasses

public List<Annotated<Class<?>>> findMetaAnnotatedClasses(Class<? extends Annotation> annotation)
Specified by:
findMetaAnnotatedClasses in interface IAnnotationFinder

findInheritedAnnotatedClasses

public List<Class<?>> findInheritedAnnotatedClasses(Class<? extends Annotation> annotation)
Naive implementation - works extremelly slow O(n^3)

Specified by:
findInheritedAnnotatedClasses in interface IAnnotationFinder
Parameters:
annotation -
Returns:
list of directly or indirectly (inherited) annotated classes

findAnnotatedMethods

public List<Method> findAnnotatedMethods(Class<? extends Annotation> annotation)
Specified by:
findAnnotatedMethods in interface IAnnotationFinder

findMetaAnnotatedMethods

public List<Annotated<Method>> findMetaAnnotatedMethods(Class<? extends Annotation> annotation)
Specified by:
findMetaAnnotatedMethods in interface IAnnotationFinder

findAnnotatedConstructors

public List<Constructor> findAnnotatedConstructors(Class<? extends Annotation> annotation)
Specified by:
findAnnotatedConstructors in interface IAnnotationFinder

findAnnotatedFields

public List<Field> findAnnotatedFields(Class<? extends Annotation> annotation)
Specified by:
findAnnotatedFields in interface IAnnotationFinder

findMetaAnnotatedFields

public List<Annotated<Field>> findMetaAnnotatedFields(Class<? extends Annotation> annotation)
Specified by:
findMetaAnnotatedFields in interface IAnnotationFinder

findClassesInPackage

public List<Class<?>> findClassesInPackage(String packageName,
                                           boolean recursive)
Specified by:
findClassesInPackage in interface IAnnotationFinder

findSubclasses

public <T> List<Class<? extends T>> findSubclasses(Class<T> clazz)
Specified by:
findSubclasses in interface IAnnotationFinder

findImplementations

public <T> List<Class<? extends T>> findImplementations(Class<T> clazz)
Specified by:
findImplementations in interface IAnnotationFinder

getAnnotationInfos

protected List<AbstractFinder.Info> getAnnotationInfos(String name)

readClassDef

protected void readClassDef(String className)

readClassDef

protected void readClassDef(InputStream in)
                     throws IOException
Throws:
IOException

readClassDef

protected void readClassDef(InputStream in,
                            String path)
                     throws IOException
Throws:
IOException

readClassDef

protected void readClassDef(Class clazz)


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.