org.apache.openejb.util
Class AnnotationFinder

java.lang.Object
  extended by org.apache.openejb.util.AnnotationFinder

public class AnnotationFinder
extends Object

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: 903000 $ $Date: 2010-01-25 23:23:38 +0100 (Mo, 25. Jan 2010) $
Author:
David Blevins

Nested Class Summary
static interface AnnotationFinder.Filter
           
static class AnnotationFinder.FoundException
           
static class AnnotationFinder.NotFoundException
           
 class AnnotationFinder.Visitor
           
 
Field Summary
static int classes
           
 
Constructor Summary
AnnotationFinder(ClassLoader classLoader)
          Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the classloader's parent.
AnnotationFinder(ClassLoader classLoader, boolean excludeParent)
          Creates a ClassFinder that will search the urls in the specified classloader.
AnnotationFinder(ClassLoader classLoader, ClassLoader exclude)
          Creates a ClassFinder that will search the urls in the specified classloader excluding the urls in the 'exclude' classloader.
AnnotationFinder(ClassLoader classLoader, Collection<URL> urls)
           
AnnotationFinder(ClassLoader classLoader, URL url)
           
 
Method Summary
 boolean find(AnnotationFinder.Filter filter)
           
 List<String> getClassesNotLoaded()
          Returns a list of classes that could not be loaded in last invoked findAnnotated* method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classes

public static int classes
Constructor Detail

AnnotationFinder

public AnnotationFinder(ClassLoader classLoader)
                 throws 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:
Exception - if something goes wrong

AnnotationFinder

public AnnotationFinder(ClassLoader classLoader,
                        boolean excludeParent)
                 throws 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:
Exception - if something goes wrong.

AnnotationFinder

public AnnotationFinder(ClassLoader classLoader,
                        ClassLoader exclude)
                 throws 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:
Exception - if something goes wrong

AnnotationFinder

public AnnotationFinder(ClassLoader classLoader,
                        URL url)

AnnotationFinder

public AnnotationFinder(ClassLoader classLoader,
                        Collection<URL> urls)
Method Detail

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.

Returns:
an unmodifiable live view of classes that could not be loaded in previous findAnnotated* call.

find

public boolean find(AnnotationFinder.Filter filter)


Copyright © 1999-2013 The Apache OpenEJB development community. All Rights Reserved.