Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire.container
Class PluginManager

    java.lang.Object
      org.jivesoftware.openfire.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()`

Nested Class Summary
`static class` | `PluginManager.License` An enumberation for plugin license agreement types.

Constructor Summary
`PluginManager(File pluginDir)` Constructs a new plugin manager.

Method Summary
`void` | `addPluginListener(PluginListener listener)`
`void` | `addPluginManagerListener(PluginManagerListener listener)`
`String` | `getAuthor(Plugin plugin)` Returns the author of a plugin.
`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.
`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.
`PluginManager.License` | `getLicense(Plugin plugin)` Returns the license agreement type that the plugin is governed by.
`String` | `getMinServerVersion(Plugin plugin)` Returns the minimum server version this plugin can run within.
`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.
`PluginClassLoader` | `getPluginClassloader(Plugin plugin)` Returns the classloader of a plugin.
`File` | `getPluginDirectory(Plugin plugin)` Returns the plugin's directory.
`File` | `getPluginFile(String name)` Returns the JAR or WAR file that created the plugin.
`Collection<Plugin>` | `getPlugins()` Returns a Collection of all installed plugins.
`String` | `getVersion(Plugin plugin)` Returns the version of a plugin.
`boolean` | `installPlugin(InputStream in, String pluginFilename)` Installs or updates an existing plugin.
`boolean` | `isExecuted()` Returns true if at least one attempt to load plugins has been done.
`boolean` | `isPluginDownloaded(String pluginFilename)` Returns true if the specified filename, that belongs to a plugin, exists.
`Class` | `loadClass(Plugin plugin, String className)` Loads a class from the classloader of a plugin.
`void` | `removePluginListener(PluginListener listener)`
`void` | `removePluginManagerListener(PluginManagerListener listener)`
`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.

### installPlugin

    public boolean installPlugin(InputStream in,
                                 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(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 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.

### getPluginFile

    public File getPluginFile(String name)

  Returns the JAR or WAR file that created the plugin.

  Parameters:
    `name` - the name of the plugin.
  Returns:
    the plugin JAR or WAR file.

### isExecuted

    public boolean isExecuted()

  Returns true if at least one attempt to load plugins has been done. A true value does not mean that available plugins have been loaded nor that plugins to be added in the future are already loaded. :)

  TODO Current version does not consider child plugins that may be loaded in a second attempt. It either TODO consider plugins that were found but failed to be loaded due to some error.

  Returns:
    true if at least one attempt to load plugins has been done.

### 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.

### getMinServerVersion

    public 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 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)

### removePluginListener

    public void removePluginListener(PluginListener listener)

### addPluginManagerListener

    public void addPluginManagerListener(PluginManagerListener listener)

### removePluginManagerListener

    public void removePluginManagerListener(PluginManagerListener listener)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Jive Software.