org.pentaho.reporting.libraries.base.util
Class ClassQueryTool
public abstract
class
ClassQueryTool
extends Object
The class-query tool loads classes using a classloader and calls "processClass" for each class encountered. This is
highly expensive and sometimes dangerous excercise as the classloading may trigger static initializers and may
exhaust the "permgen" space of the Virtual machine.
If possible anyhow, do not use this class.
Author: Thomas Morgner
Method Summary |
protected boolean | isValidClass(String className)
Checks, whether the class is valid. |
protected abstract void | processClass(ClassLoader classLoader, Class c)
The handler method that is called for every class encountered on the classpath.
|
void | processDirectory(File directory)
Processes all entries from a given directory, ignoring any subdirectory contents.
|
protected void | processEntry(ClassLoader classLoader, String entryName)
Processes a single class-file entry. |
protected ClassQueryTool()
The default constructor.
protected boolean isValidClass(String className)
Checks, whether the class is valid. If the class-name is not considered valid by this method, the class will
not be processed. Use this to pre-filter the class-stream as loading classes is expensive.
Parameters: className the name of the class.
Returns: true, if the class should be processed, false otherwise.
protected abstract void processClass(ClassLoader classLoader, Class c)
The handler method that is called for every class encountered on the classpath.
Parameters: classLoader the classloader used to load the class. c the class that should be handled.
public void processDirectory(File directory)
Processes all entries from a given directory, ignoring any subdirectory contents.
If the directory contains sub-directories these directories are not searched for JAR or ZIP files.
In addition to the directory given as parameter, the direcories and JAR/ZIP-files on the classpath are also
searched for entries.
If directory is null, only the classpath is searched.
Parameters: directory the directory to be searched, or null to just use the classpath.
Throws: IOException if an error occured while loading the resources from the directory. SecurityException if access to the system properties or access to the classloader is restricted.
protected void processEntry(ClassLoader classLoader, String entryName)
Processes a single class-file entry. The method will try to load the given entry as java-class and if that
successeds will then call the "processClass" method to let the real implementation handle the class.
Parameters: classLoader the classloader that should be used for class- and resource loading. entryName the file name in the classpath.