org.deepfs.fsml.util
Class Loader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.deepfs.fsml.util.Loader

public final class Loader
extends ClassLoader

Some utility methods for loading class files from folders, packages or jar files.

Author:
Workgroup DBIS, University of Konstanz 2005-10, ISC License, Bastian Lemke

Method Summary
static Class<?>[] load(Package pkg, Class<?> superClass)
           Loads all subclasses of superClass from the package pkg.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

load

public static Class<?>[] load(Package pkg,
                              Class<?> superClass)
                       throws IOException

Loads all subclasses of superClass from the package pkg. The classes may either be in a directory or inside a java archive file. If one of the classes is already loaded, nothing is done (but the class will be included in the results).

superClass may be an abstract class, an interface or a regular class. Every class inside the package pkg that implements the interface or extends the class is loaded.

This method breaks after the first error. Subsequent classes are not loaded.

Parameters:
pkg - the package to load the classes from
superClass - either the interface that has to be implemented by the classes or a class that has to be extended
Returns:
an array with all the loaded classes
Throws:
IOException - if the classes are located inside a JAR file and any error occurs while reading from this file