JGAP

org.jgap.util
Class PluginDiscoverer

java.lang.Object
  extended by org.jgap.util.PluginDiscoverer

public class PluginDiscoverer
extends java.lang.Object

This class will (slightly inefficiently) look for all classes that implement a particular interface. It is useful for plugins. This is done by looking through the contents of all jar files in the classpath, as well as performing a recursive search for *.class files in the classpath directories This particular class may not work in restrictive ClassLoader environments such as Applets or WebStart. (It may...but unlikely and untested.)

Since:
2.3

Nested Class Summary
 class PluginDiscoverer.ClassFilter
          Filter that only matches class files
 class PluginDiscoverer.DirectoryFilter
          Filter that only matches subdirectories
 
Constructor Summary
PluginDiscoverer()
          Reads the list of jars and classpath folders into instance variables for later (cached) access.
PluginDiscoverer(java.lang.String a_jarFile)
          Prepares the discoverer for a single jar file
 
Method Summary
 java.util.List findImplementingClasses(java.lang.Class a_intrface)
          Finds all classes implementing the given interface
 java.util.List findImplementingClasses(java.lang.Class a_intrface, java.lang.String a_base, java.lang.String a_path)
          Finds all classes implementing the given interface within a given directory.
 java.util.List findImplementingClasses(java.lang.String a_fullInterfaceName)
          Finds all classes implementing the given interface
static void main(java.lang.String[] args)
          For testing purpose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginDiscoverer

public PluginDiscoverer()
Reads the list of jars and classpath folders into instance variables for later (cached) access.

Since:
2.3

PluginDiscoverer

public PluginDiscoverer(java.lang.String a_jarFile)
Prepares the discoverer for a single jar file

Parameters:
a_jarFile - String
Since:
3.2
Method Detail

findImplementingClasses

public java.util.List findImplementingClasses(java.lang.String a_fullInterfaceName)
                                       throws java.lang.ClassNotFoundException
Finds all classes implementing the given interface

Parameters:
a_fullInterfaceName - name of the interface (inclusive package name) to find implementing classes (not abstract) for
Returns:
list of class names that implement the given interface
Throws:
java.lang.ClassNotFoundException
Since:
2.4

findImplementingClasses

public java.util.List findImplementingClasses(java.lang.Class a_intrface)
Finds all classes implementing the given interface

Parameters:
a_intrface - the interface to check against
Returns:
list of class names that implement the given interface
Since:
2.3

findImplementingClasses

public java.util.List findImplementingClasses(java.lang.Class a_intrface,
                                              java.lang.String a_base,
                                              java.lang.String a_path)
Finds all classes implementing the given interface within a given directory.

Parameters:
a_intrface - Class
a_base - String
a_path - String
Returns:
List

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
For testing purpose

Parameters:
args - not used
Throws:
java.lang.Exception - in case of any problem
Since:
2.3

JGAP