com.nhncorp.neptune.common.util
Class ClassList
java.lang.Object
com.nhncorp.neptune.common.util.ClassList
public abstract class ClassList
- extends java.lang.Object
This abstract class can be used to obtain a list of all classes in a classpath.
Caveat: When used in environments which utilize multiple class loaders--such as
a J2EE Container like Tomcat--it is important to select the correct classloader
otherwise the classes returned, if any, will be incompatible with those declared
in the code employing this class lister.
to get a reference to your classloader within an instance method use:
this.getClass().getClassLoader() or
Thread.currentThread().getContextClassLoader() anywhere else
- Since:
- 0.1.0
- Version:
- 0.2.0
- Author:
- Kris Dover
|
Method Summary |
static java.util.List<java.lang.Class> |
findClasses(java.lang.ClassLoader classLoader,
java.lang.Class classType,
java.lang.String packageFilter,
java.util.Set<java.lang.String> jarFilter)
Searches the classpath for all classes matching a specified search criteria,
returning them in a map keyed with the interfaces they implement or null if they
have no interfaces. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClassList
public ClassList()
findClasses
public static java.util.List<java.lang.Class> findClasses(java.lang.ClassLoader classLoader,
java.lang.Class classType,
java.lang.String packageFilter,
java.util.Set<java.lang.String> jarFilter)
throws java.lang.ClassNotFoundException
- Searches the classpath for all classes matching a specified search criteria,
returning them in a map keyed with the interfaces they implement or null if they
have no interfaces. The search criteria can be specified via interface, package
and jar name filter arguments
- Parameters:
classLoader - The classloader whose classpath will be traversedinterfaceFilter - A Set of fully qualified interface names to search for
or null to return classes implementing all interfacespackageFilter - A Set of fully qualified package names to search for or
or null to return classes in all packagesjarFilter - A Set of jar file names to search for or null to return
classes from all jars
- Returns:
- A Map of a Set of Classes keyed to their interface names
- Throws:
java.lang.ClassNotFoundException - if the current thread's classloader cannot load
a requested class for any reason