edu.iu.iv.common.util
Class JarScanner

java.lang.Object
  |
  +--edu.iu.iv.common.util.JarScanner

public class JarScanner
extends java.lang.Object

A utility class that can dynamically load classes from a set of paths, which may be jar files or folders which contain jars. The classes can then be scanned to enumerate the subtypes of a given class.

Author:
Josh Bonner

Constructor Summary
JarScanner()
          Creates a JarScanner with no paths initially set.
JarScanner(java.lang.String[] jarPaths)
          Creates a JarScanner and uses it to scan the given paths.
 
Method Summary
 java.util.List getInstantiableSubtypes(java.lang.Class supertype)
          Returns a list of the classes loaded by this scanner that are instantiable subtypes of the given supertype.
 void setScanPaths(java.lang.String[] jarPaths)
          Loads the classes from the jar files located at the given set of paths.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarScanner

public JarScanner()
Creates a JarScanner with no paths initially set.


JarScanner

public JarScanner(java.lang.String[] jarPaths)
           throws java.io.IOException
Creates a JarScanner and uses it to scan the given paths.

Parameters:
jarPaths - the paths to scan
Throws:
java.io.IOException - if the scanner encounters an IO problem while processing one of the given paths
Method Detail

setScanPaths

public void setScanPaths(java.lang.String[] jarPaths)
                  throws java.io.IOException
Loads the classes from the jar files located at the given set of paths. The old class loader and set of loaded classes are discarded.

Parameters:
jarPaths - the paths to scan for jar files
Throws:
java.io.IOException - if an IO problem is encountered while processing one of the given paths

getInstantiableSubtypes

public java.util.List getInstantiableSubtypes(java.lang.Class supertype)
Returns a list of the classes loaded by this scanner that are instantiable subtypes of the given supertype.

Parameters:
supertype - the class whose subtypes are desired
Returns:
a list of subtype Classes