org.xnap.plugin
Class PluginManager

java.lang.Object
  extended by org.xnap.plugin.PluginManager

public class PluginManager
extends java.lang.Object

This class keeps track of all available and enabled plugins.


Nested Class Summary
static class PluginManager.PluginInfoComparator
          Compares PluginInfo objects by name.
 
Field Summary
static java.lang.String PLUGIN_FILENAME
           
 
Method Summary
 boolean add(PluginInfo info)
          Adds a new plugin information object to the list of available plugins.
 PluginInfo add(java.util.Properties props)
          Constructs a PluginInfo object from props and invokes add(PluginInfo) if info is valid.
 boolean addFromPackage(PackageInfo p)
          Adds a plugin from package info.
 void addPluginListener(PluginListener l)
          Adds the specified plugin listener to receive plugin events.
 PluginInfo getCorePackage()
          Returns the xnap-core package.
static java.lang.String getCoreVersion()
           
 int getEnabledCount()
          Returns the number of enabled plugins.
 PluginInfo getInfoByName(java.lang.String name)
          Returns the information record for plugin with name.
static PluginManager getInstance()
           
 void guiStarted()
          Invoked by XNapFrame.
 void guiStopped()
          Invoked by XNapFrame.
 java.util.Iterator infos()
          Return a sorted iterator over a copy of all PluginInfo objects.
 Plugin load(PluginInfo info)
          Loads the plugin described by info.
 void remove(PluginInfo info)
           
 void removePluginListener(PluginListener l)
          Removes the specified plugin listener.
static java.lang.String[] resolveClassPath(PluginInfo info)
          Resolves the class path of info to absolute filenames.
 void restore()
          Restores the state of the plugin manager from the Preferences.
 void save()
          Disables all plugins and saves the state of the PluginManager.
 void setEnabled(Plugin plugin, boolean enable)
           
 int size()
          Returns the number of plugins.
 void updateFromPackageManager()
          Updates the list of available plugins from XNapPackageManager.
 void write()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLUGIN_FILENAME

public static final java.lang.String PLUGIN_FILENAME
Method Detail

getInstance

public static PluginManager getInstance()

add

public PluginInfo add(java.util.Properties props)
Constructs a PluginInfo object from props and invokes add(PluginInfo) if info is valid.

See Also:
PluginManager()

add

public boolean add(PluginInfo info)
Adds a new plugin information object to the list of available plugins.

If the plugin was already known and info has a lower version or the plugin was already loaded, info is not added.

Returns:
true, if info was added; false, otherwise

addFromPackage

public boolean addFromPackage(PackageInfo p)
                       throws ParseException,
                              UnsatisfiedDependenciesException
Adds a plugin from package info. The classpath is resolved to absolute jar file dependencies.

Returns:
true, if the plugin was added successfully
Throws:
ParseException
UnsatisfiedDependenciesException
See Also:
add(PluginInfo)

addPluginListener

public void addPluginListener(PluginListener l)
Adds the specified plugin listener to receive plugin events.


removePluginListener

public void removePluginListener(PluginListener l)
Removes the specified plugin listener.


getCorePackage

public PluginInfo getCorePackage()
Returns the xnap-core package.

Returns:
null, if package is not found

getCoreVersion

public static java.lang.String getCoreVersion()

getEnabledCount

public int getEnabledCount()
Returns the number of enabled plugins.


guiStarted

public void guiStarted()
Invoked by XNapFrame.


guiStopped

public void guiStopped()
Invoked by XNapFrame.


getInfoByName

public PluginInfo getInfoByName(java.lang.String name)
Returns the information record for plugin with name.

Parameters:
name - the plugin's name

infos

public java.util.Iterator infos()
Return a sorted iterator over a copy of all PluginInfo objects. Changes made to the iterator are not reflected.


load

public Plugin load(PluginInfo info)
            throws java.lang.Exception
Loads the plugin described by info. All required jar files are added to the class loader and the plugin class is instantiated.

Parameters:
info - the plugin to be loaded
Returns:
the instantiated plugin object
Throws:
java.lang.Exception

restore

public void restore()
Restores the state of the plugin manager from the Preferences.


save

public void save()
Disables all plugins and saves the state of the PluginManager.


setEnabled

public void setEnabled(Plugin plugin,
                       boolean enable)
                throws java.lang.Exception
Throws:
java.lang.Exception

size

public int size()
Returns the number of plugins.


remove

public void remove(PluginInfo info)

resolveClassPath

public static java.lang.String[] resolveClassPath(PluginInfo info)
                                           throws ParseException,
                                                  UnsatisfiedDependenciesException
Resolves the class path of info to absolute filenames.

Throws:
ParseException
UnsatisfiedDependenciesException

updateFromPackageManager

public void updateFromPackageManager()
Updates the list of available plugins from XNapPackageManager.


write

public void write()


Copyright © 2001-2005 XNap Team. All Rights Reserved.