net.sourceforge.jsxe
Class JARClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bynet.sourceforge.jsxe.JARClassLoader

public class JARClassLoader
extends ClassLoader

A class loader implementation that loads classes from JAR files. Also manages getting files from plugin JARs.

Since:
jsXe 0.4 beta
Version:
$Id: JARClassLoader.java,v 1.18 2006/02/04 00:34:38 ian_lewis Exp $
Author:
Ian Lewis (IanLewis@member.fsf.org)

Field Summary
static String PLUGIN_CLASS
           
static String PLUGIN_DESCRIPTION
           
static String PLUGIN_HUMAN_READABLE_NAME
           
static String PLUGIN_NAME
           
static String PLUGIN_URL
           
static String PLUGIN_VERSION
           
 
Constructor Summary
JARClassLoader()
           
 
Method Summary
 ArrayList addDirectory(String path)
          Adds all jar files in a directory to the search path for the class loader.
 void addJarFile(File file)
          Adds a jar file to the search path for the class loader and loads the jar as a plugin
 void addJarFile(String path)
          Adds a jar file to the search path for the class loader and loads the jar as a plugin.
protected  Class findClass(String name)
           
protected  URL findResource(String name)
           
protected  Enumeration findResources(String name)
           
 ActionPlugin getActionPlugin(String name)
          Gets an action plugin by name.
 ArrayList getActionPluginNames()
          Returns an ArrayList object containing the names of the all installed action plugins that are not view plugins.
 ArrayList getActionPlugins()
          Gets all action plugins that are not view plugins.
 ArrayList getAllPluginNames()
          Gets a list of all the names of the loaded plugins.
 ArrayList getAllPlugins()
          Gets all plugins.
 ActionPlugin getPlugin(String name)
          Gets the plugin with the given name.
 String getPluginProperty(ActionPlugin plugin, String key)
          Gets a property for the given plugin.
 String getPluginProperty(String name, String key)
          Gets a property for the plugin with the given name.
 ViewPlugin getViewPlugin(String name)
          Gets the view plugin with the given name
 ArrayList getViewPluginNames()
          Gets the names of all loaded view plugins
 ArrayList getViewPlugins()
          Gets all view plugins.
 ArrayList startPlugins()
          Starts all the plugins from their respective jar files.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGIN_NAME

public static final String PLUGIN_NAME
See Also:
Constant Field Values

PLUGIN_CLASS

public static final String PLUGIN_CLASS
See Also:
Constant Field Values

PLUGIN_VERSION

public static final String PLUGIN_VERSION
See Also:
Constant Field Values

PLUGIN_URL

public static final String PLUGIN_URL
See Also:
Constant Field Values

PLUGIN_HUMAN_READABLE_NAME

public static final String PLUGIN_HUMAN_READABLE_NAME
See Also:
Constant Field Values

PLUGIN_DESCRIPTION

public static final String PLUGIN_DESCRIPTION
See Also:
Constant Field Values
Constructor Detail

JARClassLoader

public JARClassLoader()
Method Detail

findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Throws:
ClassNotFoundException

findResources

protected Enumeration findResources(String name)
                             throws IOException
Throws:
IOException

findResource

protected URL findResource(String name)

addJarFile

public void addJarFile(String path)
                throws FileNotFoundException,
                       IOException
Adds a jar file to the search path for the class loader and loads the jar as a plugin.

Parameters:
path - the path to the jar file
Throws:
FileNotFoundException
IOException

addJarFile

public void addJarFile(File file)
                throws FileNotFoundException,
                       IOException
Adds a jar file to the search path for the class loader and loads the jar as a plugin

Parameters:
file - the file to add
Throws:
FileNotFoundException
IOException

addDirectory

public ArrayList addDirectory(String path)
Adds all jar files in a directory to the search path for the class loader.

Parameters:
path - the path for the directory containing jar files
Returns:
an ArrayList of pathnames of jar files that could not be loaded.

getAllPluginNames

public ArrayList getAllPluginNames()
Gets a list of all the names of the loaded plugins.

Returns:
an ArrayList of strings containing the names of the plugins
Since:
jsXe 0.3pre15

getAllPlugins

public ArrayList getAllPlugins()
Gets all plugins.

Returns:
an ArrayList of plugins
Since:
jsXe 0.3pre15

getViewPluginNames

public ArrayList getViewPluginNames()
Gets the names of all loaded view plugins

Returns:
an ArrayList of ViewPlugins

getViewPlugins

public ArrayList getViewPlugins()
Gets all view plugins. You should run startPlugins() before calling this function.

Returns:
an ArrayList of ViewPlugin objects

getViewPlugin

public ViewPlugin getViewPlugin(String name)
Gets the view plugin with the given name

Returns:
the view plugin

getActionPluginNames

public ArrayList getActionPluginNames()
Returns an ArrayList object containing the names of the all installed action plugins that are not view plugins.

Returns:
an ArrayList of ActionPlugins

getActionPlugins

public ArrayList getActionPlugins()
Gets all action plugins that are not view plugins. You should run startPlugins() before calling this function.

Returns:
an ArrayList of ActionPlugin objects

getActionPlugin

public ActionPlugin getActionPlugin(String name)
Gets an action plugin by name. Not for use in retrieving ViewPlugins.

Parameters:
name - the name of the ActionPlugin you want to retrieve.
Returns:
the ActionPlugin or null if a plugin with the name given is not loaded.

getPlugin

public ActionPlugin getPlugin(String name)
Gets the plugin with the given name. This may return either view plugins or ActionPlugins

Returns:
the plugin with the given name
Since:
jsXe 0.3pre15

startPlugins

public ArrayList startPlugins()
Starts all the plugins from their respective jar files.

Returns:
an ArrayList of errors (either Strings or Exceptions).

getPluginProperty

public String getPluginProperty(String name,
                                String key)
Gets a property for the plugin with the given name.

Returns:
the value of the property
Since:
jsXe 0.3pre15

getPluginProperty

public String getPluginProperty(ActionPlugin plugin,
                                String key)
Gets a property for the given plugin.

Returns:
the value of the property.
Since:
jsXe 0.3pre15