org.apache.xbean.finder
Class ClassFinder

java.lang.Object
  extended by org.apache.xbean.finder.AbstractFinder
      extended by org.apache.xbean.finder.ClassFinder

public class ClassFinder
extends AbstractFinder

ClassFinder searches the classpath of the specified classloader for packages, classes, constructors, methods, or fields with specific annotations. For security reasons ASM is used to find the annotations. Classes are not loaded unless they match the requirements of a called findAnnotated* method. Once loaded, these classes are cached. The getClassesNotLoaded() method can be used immediately after any find* method to get a list of classes which matched the find requirements (i.e. contained the annotation), but were unable to be loaded.

Version:
$Rev: 924423 $ $Date: 2010-03-17 20:06:14 +0100 (Wed, 17 Mar 2010) $
Author:
David Blevins

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.xbean.finder.AbstractFinder
AbstractFinder.Annotatable, AbstractFinder.AnnotationInfo, AbstractFinder.ClassInfo, AbstractFinder.FieldInfo, AbstractFinder.GenericAwareInfoBuildingVisitor, AbstractFinder.Info, AbstractFinder.InfoBuildingVisitor, AbstractFinder.MethodInfo, AbstractFinder.PackageInfo
 
Field Summary
 
Fields inherited from class org.apache.xbean.finder.AbstractFinder
classInfos
 
Constructor Summary
ClassFinder(java.lang.Class... classes)
           
ClassFinder(java.lang.ClassLoader classLoader)
          Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the classloader's parent.
ClassFinder(java.lang.ClassLoader classLoader, boolean excludeParent)
          Creates a ClassFinder that will search the urls in the specified classloader.
ClassFinder(java.lang.ClassLoader classLoader, java.lang.ClassLoader exclude)
          Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the 'exclude' classloader.
ClassFinder(java.lang.ClassLoader classLoader, java.util.Collection<java.net.URL> urls)
           
ClassFinder(java.lang.ClassLoader classLoader, java.net.URL url)
           
ClassFinder(java.util.List<java.lang.Class> classes)
           
 
Method Summary
protected  java.net.URL getResource(java.lang.String className)
           
protected  java.lang.Class<?> loadClass(java.lang.String fixedName)
           
protected  void readClassDef(java.lang.String className)
           
 
Methods inherited from class org.apache.xbean.finder.AbstractFinder
findAnnotatedClasses, findAnnotatedConstructors, findAnnotatedFields, findAnnotatedMethods, findAnnotatedPackages, findClassesInPackage, findInheritedAnnotatedClasses, getAnnotationInfos, getClassesNotLoaded, isAnnotationPresent, readClassDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFinder

public ClassFinder(java.lang.ClassLoader classLoader)
            throws java.lang.Exception
Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the classloader's parent. To include the parent classloader, use: new ClassFinder(classLoader, false); To exclude the parent's parent, use: new ClassFinder(classLoader, classLoader.getParent().getParent());

Parameters:
classLoader - source of classes to scan
Throws:
java.lang.Exception - if something goes wrong

ClassFinder

public ClassFinder(java.lang.ClassLoader classLoader,
                   boolean excludeParent)
            throws java.lang.Exception
Creates a ClassFinder that will search the urls in the specified classloader.

Parameters:
classLoader - source of classes to scan
excludeParent - Allegedly excludes classes from parent classloader, whatever that might mean
Throws:
java.lang.Exception - if something goes wrong.

ClassFinder

public ClassFinder(java.lang.ClassLoader classLoader,
                   java.lang.ClassLoader exclude)
            throws java.lang.Exception
Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the 'exclude' classloader.

Parameters:
classLoader - source of classes to scan
exclude - source of classes to exclude from scanning
Throws:
java.lang.Exception - if something goes wrong

ClassFinder

public ClassFinder(java.lang.ClassLoader classLoader,
                   java.net.URL url)

ClassFinder

public ClassFinder(java.lang.ClassLoader classLoader,
                   java.util.Collection<java.net.URL> urls)

ClassFinder

public ClassFinder(java.lang.Class... classes)

ClassFinder

public ClassFinder(java.util.List<java.lang.Class> classes)
Method Detail

getResource

protected java.net.URL getResource(java.lang.String className)
Specified by:
getResource in class AbstractFinder

loadClass

protected java.lang.Class<?> loadClass(java.lang.String fixedName)
                                throws java.lang.ClassNotFoundException
Specified by:
loadClass in class AbstractFinder
Throws:
java.lang.ClassNotFoundException

readClassDef

protected void readClassDef(java.lang.String className)


Copyright © 2005-2011. All Rights Reserved.