org.mule.util.scan
Class ClasspathScanner
java.lang.Object
org.mule.util.scan.ClasspathScanner
public class ClasspathScanner
- extends java.lang.Object
This class can be used to scan the classpath for classtypes (or interfaces they implement) or for annotations on the classpath.
The type of scanner used depends on the class type passed in. There are currently 3 types of scanner;
This scanner uses ASM to search class byte code rather than the classes themselves making orders of magnitude better performance
and uses a lot less memory. ASM seems to be the fasted of the byte code manipulation libraries i.e. JavaAssist or BCEL
Note that the scanner will not scan inner or anonymous classes.
Method Summary |
protected void |
addClassToSet(java.lang.Class c,
java.util.Set<java.lang.Class> set,
int flags)
|
protected ClassScanner |
getScanner(java.lang.Class clazz)
Works out the correct scanner based on the class passed in
Note that these could be better architected by breaking out filters into strategy objects, but for now this
suits my needs |
protected boolean |
hasFlag(int flags,
int flag)
|
protected java.lang.Class |
loadClass(java.lang.String name)
|
protected java.util.Set<java.lang.Class> |
processFileUrl(java.net.URL url,
java.lang.String basepath,
java.lang.Class clazz,
int flags)
|
protected java.util.Set<java.lang.Class> |
processJarUrl(java.net.URL url,
java.lang.String basepath,
java.lang.Class clazz,
int flags)
|
java.util.Set<java.lang.Class> |
scanFor(java.lang.Class clazz)
|
java.util.Set<java.lang.Class> |
scanFor(java.lang.Class clazz,
int flags)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INCLUDE_ABSTRACT
public static final int INCLUDE_ABSTRACT
- See Also:
- Constant Field Values
INCLUDE_INTERFACE
public static final int INCLUDE_INTERFACE
- See Also:
- Constant Field Values
INCLUDE_INNER
public static final int INCLUDE_INNER
- See Also:
- Constant Field Values
INCLUDE_ANONYMOUS
public static final int INCLUDE_ANONYMOUS
- See Also:
- Constant Field Values
DEFAULT_FLAGS
public static final int DEFAULT_FLAGS
- See Also:
- Constant Field Values
logger
protected final transient Log logger
- logger used by this class
ClasspathScanner
public ClasspathScanner(java.lang.String... basepaths)
ClasspathScanner
public ClasspathScanner(java.lang.ClassLoader classLoader,
java.lang.String... basepaths)
scanFor
public java.util.Set<java.lang.Class> scanFor(java.lang.Class clazz)
throws java.io.IOException
- Throws:
java.io.IOException
scanFor
public java.util.Set<java.lang.Class> scanFor(java.lang.Class clazz,
int flags)
throws java.io.IOException
- Throws:
java.io.IOException
processJarUrl
protected java.util.Set<java.lang.Class> processJarUrl(java.net.URL url,
java.lang.String basepath,
java.lang.Class clazz,
int flags)
throws java.io.IOException
- Throws:
java.io.IOException
hasFlag
protected boolean hasFlag(int flags,
int flag)
processFileUrl
protected java.util.Set<java.lang.Class> processFileUrl(java.net.URL url,
java.lang.String basepath,
java.lang.Class clazz,
int flags)
throws java.io.IOException
- Throws:
java.io.IOException
addClassToSet
protected void addClassToSet(java.lang.Class c,
java.util.Set<java.lang.Class> set,
int flags)
loadClass
protected java.lang.Class loadClass(java.lang.String name)
getScanner
protected ClassScanner getScanner(java.lang.Class clazz)
- Works out the correct scanner based on the class passed in
Note that these could be better architected by breaking out filters into strategy objects, but for now this
suits my needs
- Parameters:
clazz
- the type to scan for
- Returns:
- a scanner suitable for handling the type passed in
- See Also:
AnnotationsScanner
,
InterfaceClassScanner
,
ImplementationClassScanner
Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.