net.simplace.core.service.ClassFinder
This utility class was based originally on Daniel Le Berre's RTSI
class. This class can be called in different modes, but the principal use is to determine what subclasses/implementations of a given class/interface exist in the current runtime environment.
public class ClassFinder {
// Class Methods public static
ClassFinder getInstance();
returns The singleton instance
public static boolean exists(String aClassName);
public static void
main(String[] args);
// Public Instance Methods public final void refreshLocations();
Rescan the classpath, cacheing all possible file locations.
public final Vector
findSubclasses(String aStartsWithFilter, String fqcn);
- aStartsWithFilter
- fqcn
Name of superclass/interface on which to search
returns Vector
public Vector
findResources(String aPackage, String aRegexp);
returns a Vector of Resources
public final List getErrors();
returns List of Errors
public final URL
getLocationOf(Class cls);
The result of the last search is cached in this object, along with the URL that corresponds to each class returned. This method may be called to query the cache for the location at which the given class was found.
null
will be returned if the given class was not found during the last search, or if the result cache has been cleared.
returns location of the class
public final Map getClasspathLocations();
Determine every URL location defined by the current classpath, and it's associated package name.
returns Map of URL location defined by the current classpath, and it's associated package name
public Collection
getResources(String pattern);
for all elements of java.class.path get a Collection of resources Pattern
pattern = Pattern.compile(".*"); gets all resources
- aPackage
- pattern
the pattern to match
returns the resources in the order they are found
}
Returned by: getInstance()