Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.plugin
Class PluginManager

java.lang.Object
  extended by com.jivesoftware.base.plugin.PluginManager
All Implemented Interfaces:
JiveManager

public class PluginManager
extends java.lang.Object
implements JiveManager

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

See Also:
Plugin

Nested Class Summary
static class PluginManager.License
          An enumberation for plugin license agreement types.
 
Constructor Summary
PluginManager(java.io.File pluginDir)
          Constructs a new plugin manager.
 
Method Summary
 void addActionMapping(java.lang.String namespace, java.lang.String action, Plugin plugin)
          Used to map a namespace and action to a plugin.
 void addPluginListener(PluginListener listener)
          Registers a plugin listener.
 void deletePlugin(Plugin plugin)
          Removes a plugin from the system.
 void destroy()
          Shuts down all running plugins.
 java.lang.String getAuthor(Plugin plugin)
          Returns the author of a plugin.
 java.lang.String getDatabaseKey(Plugin plugin)
          Returns the database schema key of a plugin, if it exists.
 int getDatabaseVersion(Plugin plugin)
          Returns the database schema version of a plugin, if it exists.
 java.lang.String getDescription(Plugin plugin)
          Returns the description of a plugin.
protected  java.util.Set getDevPlugins()
          Returns a set of all the plugins that have been specified with -DpluginDirs system property
 PluginManager.License getLicense(Plugin plugin)
          Returns the license agreement type that the plugin is governed by.
 java.lang.String getMinServerVersion(Plugin plugin)
          Returns the minimum server version this plugin can run within.
 java.lang.String getName(Plugin plugin)
          Returns the name of a plugin.
 Plugin getPlugin(java.lang.String name)
          Returns a plugin by name or null if a plugin with that name does not exist.
 PluginClassLoader getPluginClassloader(Plugin plugin)
          Returns the classloader of a plugin.
protected  java.io.File getPluginDirectory()
          Returns the directory {jiveHome}/plugins.
 java.io.File getPluginDirectory(Plugin plugin)
          Returns the plugin's directory.
 Plugin getPluginForAction(java.lang.String namepace, java.lang.String action)
          Returns what plugin (if any) is mapped to a specific namespace and action.
protected  java.util.Map getPluginMap()
          Returns a map of plugin name plugin entries.
protected  com.jivesoftware.base.plugin.PluginMonitor getPluginMonitor()
          Returns the PluginMonitor instance.
 java.util.Collection getPlugins()
          Returns a Collection of all installed plugins.
 java.lang.String getVersion(Plugin plugin)
          Returns the version of a plugin.
 void initialize()
          Starts plugins and the plugin monitoring service.
 boolean installPlugin(java.io.InputStream in, java.lang.String pluginFilename)
          Installs or updates an existing plugin.
 boolean isPluginDownloaded(java.lang.String pluginFilename)
          Returns true if the specified filename, that belongs to a plugin, exists.
 java.lang.Class loadClass(Plugin plugin, java.lang.String className)
          Loads a class from the classloader of a plugin.
protected  void loadPlugin(java.io.File pluginDir)
          Loads a plug-in module into the container.
 void removePluginListener(PluginListener listener)
          Unregisters a plugin listener.
 void restartPlugin(Plugin plugin)
          Restarts the specified plugin.
 void unloadPlugin(java.lang.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(java.io.File pluginDir)
Constructs a new plugin manager.

Parameters:
pluginDir - the plugin directory.
Method Detail

initialize

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

Specified by:
initialize in interface JiveManager

destroy

public void destroy()
Shuts down all running plugins.

Specified by:
destroy in interface JiveManager

installPlugin

public boolean installPlugin(java.io.InputStream in,
                             java.lang.String pluginFilename)
Installs or updates an existing plugin.

Parameters:
in - the input stream that contains the new plugin definition.
pluginFilename - the filename of the plugin to create or update.
Returns:
true if the plugin was successfully installed or updated.

isPluginDownloaded

public boolean isPluginDownloaded(java.lang.String pluginFilename)
Returns true if the specified filename, that belongs to a plugin, exists.

Parameters:
pluginFilename - the filename of the plugin to create or update.
Returns:
true if the specified filename, that belongs to a plugin, exists.

getPlugins

public java.util.Collection getPlugins()
Returns a Collection of all installed plugins.

Returns:
a Collection of all installed plugins.

getPlugin

public Plugin getPlugin(java.lang.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 java.io.File getPluginDirectory(Plugin plugin)
Returns the plugin's directory.

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

loadPlugin

protected void loadPlugin(java.io.File pluginDir)
Loads a plug-in module into the container. Loading consists of the following steps:

Parameters:
pluginDir - the plugin directory.

unloadPlugin

public void unloadPlugin(java.lang.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 java.lang.Class loadClass(Plugin plugin,
                                 java.lang.String className)
                          throws java.lang.ClassNotFoundException,
                                 java.lang.IllegalAccessException,
                                 java.lang.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:
java.lang.ClassNotFoundException - if the class was not found.
java.lang.IllegalAccessException - if not allowed to access the class.
java.lang.InstantiationException - if the class could not be created.

getName

public java.lang.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 java.lang.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 java.lang.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 java.lang.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.

getMinServerVersion

public java.lang.String getMinServerVersion(Plugin plugin)
Returns the minimum server version this plugin can run within. 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.

getDatabaseKey

public java.lang.String getDatabaseKey(Plugin plugin)
Returns the database schema key of a plugin, if it exists. 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 database schema key or null if it doesn't exist.

getDatabaseVersion

public int getDatabaseVersion(Plugin plugin)
Returns the database schema version of a plugin, if it exists. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, -1 will be returned.

Parameters:
plugin - the plugin.
Returns:
the plugin's database schema version or -1 if it doesn't exist.

getLicense

public PluginManager.License getLicense(Plugin plugin)
Returns the license agreement type that the plugin is governed by. The value is retrieved from the plugin.xml file of the plugin. If the value could not be found, PluginManager.License.other is returned.

Parameters:
plugin - the plugin.
Returns:
the plugin's license agreement.

getPluginClassloader

public PluginClassLoader getPluginClassloader(Plugin plugin)
Returns the classloader of a plugin.

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

addPluginListener

public void addPluginListener(PluginListener listener)
Registers a plugin listener. Plugin Listeners allow a notification of when a plugin is loaded and unloaded.

Parameters:
listener - The plugin to register.
See Also:
PluginListener

removePluginListener

public void removePluginListener(PluginListener listener)
Unregisters a plugin listener. The plugin listener will not longer be notified when plugins are loaded and unloaded.

Parameters:
listener - the plugin to remove as a listener.

addActionMapping

public void addActionMapping(java.lang.String namespace,
                             java.lang.String action,
                             Plugin plugin)
Used to map a namespace and action to a plugin. This is used so that the correct plugin classloader can be acquired for webwork.

Parameters:
namespace - The namespace of the action to map the plugin too.
action - The action to map the plugin too.
plugin - The plugin to map to this namespace, action.

getPluginForAction

public Plugin getPluginForAction(java.lang.String namepace,
                                 java.lang.String action)
Returns what plugin (if any) is mapped to a specific namespace and action. If there is no plugin mapped to the namespace null will be returned.

Parameters:
namepace - The namespace to acquire a plugin for.
action - The action to acquire a plugin for.
Returns:
The plugin (if any) is mapped to a specific namespace and action

deletePlugin

public void deletePlugin(Plugin plugin)
Removes a plugin from the system. This will delete the plugin from the jiveHome/plugins directory. Calling this method will notify the cluster.

Parameters:
plugin - The plugin too delete.

restartPlugin

public void restartPlugin(Plugin plugin)
Restarts the specified plugin.

Parameters:
plugin - the specified plugin.

getDevPlugins

protected java.util.Set getDevPlugins()
Returns a set of all the plugins that have been specified with -DpluginDirs system property

Returns:
a set of all the plugins that have been specified with -DpluginDirs system property

getPluginMap

protected java.util.Map getPluginMap()
Returns a map of plugin name plugin entries.

Returns:
a map of plugin name plugin entries.

getPluginDirectory

protected java.io.File getPluginDirectory()
Returns the directory {jiveHome}/plugins.

Returns:
the directory {jiveHome}/plugins.

getPluginMonitor

protected com.jivesoftware.base.plugin.PluginMonitor getPluginMonitor()
Returns the PluginMonitor instance.

Returns:
the PluginMonitor instance.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.