Jive Messenger 2.2.2 Javadoc

org.jivesoftware.messenger.container
Class PluginManager

java.lang.Object
  extended by org.jivesoftware.messenger.container.PluginManager

public class PluginManager
extends Object

Loads and manages plugins. The plugins directory is monitored for any new plugins, and they are dynamically loaded.

An instance of this class can be obtained using:

XMPPServer.getInstance().getPluginManager()

Author:
Matt Tucker
See Also:
Plugin, XMPPServer.getPluginManager()

Constructor Summary
PluginManager(File pluginDir)
          Constructs a new plugin manager.
 
Method Summary
 String getAuthor(Plugin plugin)
          Returns the author of a plugin.
 String getDescription(Plugin plugin)
          Returns the description of a plugin.
 PluginDevEnvironment getDevEnvironment(Plugin plugin)
          Returns a plugin's dev environment if development mode is enabled for the plugin.
 String getName(Plugin plugin)
          Returns the name of a plugin.
 Plugin getPlugin(String name)
          Returns a plugin by name or null if a plugin with that name does not exist.
 File getPluginDirectory(Plugin plugin)
          Returns the plugin's directory.
 Collection<Plugin> getPlugins()
          Returns a Collection of all installed plugins.
 String getVersion(Plugin plugin)
          Returns the version of a plugin.
 Class loadClass(Plugin plugin, String className)
          Loads a class from the classloader of a plugin.
 void shutdown()
          Shuts down all running plugins.
 void start()
          Starts plugins and the plugin monitoring service.
 void unloadPlugin(String pluginName)
          Unloads a plugin.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginManager

public PluginManager(File pluginDir)
Constructs a new plugin manager.

Parameters:
pluginDir - the plugin directory.
Method Detail

start

public void start()
Starts plugins and the plugin monitoring service.


shutdown

public void shutdown()
Shuts down all running plugins.


getPlugins

public Collection<Plugin> getPlugins()
Returns a Collection of all installed plugins.

Returns:
a Collection of all installed plugins.

getPlugin

public Plugin getPlugin(String name)
Returns a plugin by name or null if a plugin with that name does not exist. The name is the name of the directory that the plugin is in such as "broadcast".

Parameters:
name - the name of the plugin.
Returns:
the plugin.

getPluginDirectory

public File getPluginDirectory(Plugin plugin)
Returns the plugin's directory.

Parameters:
plugin - the plugin.
Returns:
the plugin's directory.

unloadPlugin

public void unloadPlugin(String pluginName)
Unloads a plugin. The Plugin.destroyPlugin() method will be called and then any resources will be released. The name should be the name of the plugin directory and not the name as given by the plugin meta-data. This method only removes the plugin but does not delete the plugin JAR file. Therefore, if the plugin JAR still exists after this method is called, the plugin will be started again the next time the plugin monitor process runs. This is useful for "restarting" plugins.

This method is called automatically when a plugin's JAR file is deleted.

Parameters:
pluginName - the name of the plugin to unload.

loadClass

public Class loadClass(Plugin plugin,
                       String className)
                throws ClassNotFoundException,
                       IllegalAccessException,
                       InstantiationException
Loads a class from the classloader of a plugin.

Parameters:
plugin - the plugin.
className - the name of the class to load.
Returns:
the class.
Throws:
ClassNotFoundException - if the class was not found.
IllegalAccessException - if not allowed to access the class.
InstantiationException - if the class could not be created.

getDevEnvironment

public PluginDevEnvironment getDevEnvironment(Plugin plugin)
Returns a plugin's dev environment if development mode is enabled for the plugin.

Parameters:
plugin - the plugin.
Returns:
the plugin dev environment, or null if development mode is not enabled for the plugin.

getName

public String getName(Plugin plugin)
Returns the name of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, null will be returned. Note that this value is distinct from the name of the plugin directory.

Parameters:
plugin - the plugin.
Returns:
the plugin's name.

getDescription

public String getDescription(Plugin plugin)
Returns the description of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, null will be returned.

Parameters:
plugin - the plugin.
Returns:
the plugin's description.

getAuthor

public String getAuthor(Plugin plugin)
Returns the author of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, null will be returned.

Parameters:
plugin - the plugin.
Returns:
the plugin's author.

getVersion

public String getVersion(Plugin plugin)
Returns the version of a plugin. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, null will be returned.

Parameters:
plugin - the plugin.
Returns:
the plugin's version.

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.