public class PluginManager extends Object
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()
These states are defined for plugin management:
plugins
directory.minServerVersion
definition.Plugin
,
XMPPServer.getPluginManager()
Constructor and Description |
---|
PluginManager(File pluginDir)
Constructs a new plugin manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addPluginListener(PluginListener listener)
Registers a PluginListener, which will now start receiving events regarding plugin creation and destruction.
|
void |
addPluginManagerListener(PluginManagerListener listener)
Registers a PluginManagerListener, which will now start receiving events regarding plugin management.
|
void |
deletePlugin(String pluginName)
Delete a plugin, which removes the plugin.jar/war file after which the plugin is unloaded.
|
String |
getAuthor(Plugin plugin)
Deprecated.
Moved to
PluginMetadataHelper.getAuthor(Plugin) . |
String |
getCanonicalName(Plugin plugin)
Returns the canonical name for a loaded plugin.
|
String |
getDatabaseKey(Plugin plugin)
Deprecated.
|
int |
getDatabaseVersion(Plugin plugin)
Deprecated.
|
String |
getDescription(Plugin plugin)
Deprecated.
|
PluginDevEnvironment |
getDevEnvironment(Plugin plugin)
Returns a plugin's dev environment if development mode is enabled for
the plugin.
|
String |
getLicense(Plugin plugin)
Deprecated.
Moved to
PluginMetadataHelper.getLicense(Plugin) . |
PluginMetadata |
getMetadata(String canonicalName)
Returns metadata for an extracted plugin, or null when the plugin is extracted nor loaded.
|
Map<String,PluginMetadata> |
getMetadataExtractedPlugins()
Returns metadata for all extracted plugins, mapped by their canonical name.
|
String |
getMinServerVersion(Plugin plugin)
Deprecated.
|
String |
getName(Plugin plugin)
Deprecated.
Moved to
PluginMetadataHelper.getName(Plugin) . |
Plugin |
getPlugin(String canonicalName)
Deprecated.
in Openfire 4.4 in favour of
getPluginByName(String) |
Optional<Plugin> |
getPluginByName(String pluginName)
Returns a loaded plugin by the name contained in the plugin.xml <name/> tag, ignoring case.
|
PluginClassLoader |
getPluginClassloader(Plugin plugin)
Returns the classloader of a plugin.
|
File |
getPluginDirectory(Plugin plugin)
Deprecated.
Use #getPluginPath() instead.
|
Path |
getPluginPath(Plugin plugin)
Returns the plugin's directory.
|
Collection<Plugin> |
getPlugins()
Returns a Collection of all loaded plugins.
|
Path |
getPluginsDirectory()
Returns the directory that contains all plugins.
|
String |
getVersion(Plugin plugin)
Deprecated.
Moved to
PluginMetadataHelper.getVersion(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 |
isExtracted(String canonicalName)
Returns true if the plugin by the specified name is extracted.
|
boolean |
isInstalled(String canonicalName)
Returns true if the plugin by the specified name is installed.
|
boolean |
isLoaded(String canonicalName)
Returns true if the plugin by the specified name is loaded.
|
boolean |
isMonitorTaskRunning() |
Class |
loadClass(Plugin plugin,
String className)
Loads a class from the classloader of a plugin.
|
boolean |
reloadPlugin(String pluginName) |
void |
removePluginListener(PluginListener listener)
Deregisters a PluginListener, which will no longer receive events.
|
void |
removePluginManagerListener(PluginManagerListener listener)
Deregisters a PluginManagerListener, which will no longer receive events.
|
void |
shutdown()
Shuts down all running plugins.
|
void |
start()
Starts plugins and the plugin monitoring service.
|
public PluginManager(File pluginDir)
pluginDir
- the directory containing all Openfire plugins, typically OPENFIRE_HOME/plugins/public void start()
public void shutdown()
public Path getPluginsDirectory()
public boolean installPlugin(InputStream in, String pluginFilename)
in
- the input stream that contains the new plugin definition.pluginFilename
- the filename of the plugin to create or update.public boolean isInstalled(String canonicalName)
plugins
directory.
Note that an installed plugin is not per definition an extracted plugin, and an extracted
plugin is not per definition a loaded plugin. A plugin that's extracted might, for instance, fail to
load, due to restrictions imposed by its minServerVersion
definition.canonicalName
- the canonical filename of the plugin (cannot be null).public boolean isExtracted(String canonicalName)
plugins
directory contains a subdirectory that matches the canonical name of the plugin.
Note that an installed plugin is not per definition an extracted plugin, and an extracted
plugin is not per definition a loaded plugin. A plugin that's extracted might, for instance, fail to
load, due to restrictions imposed by its minServerVersion
definition.canonicalName
- the canonical filename of the plugin (cannot be null).public boolean isLoaded(String canonicalName)
minServerVersion
definition.canonicalName
- the canonical filename of the plugin (cannot be null).public Map<String,PluginMetadata> getMetadataExtractedPlugins()
minServerVersion
definition.public PluginMetadata getMetadata(String canonicalName)
minServerVersion
definition.canonicalName
- the canonical name (lower case JAR/WAR file without exception) of the pluginpublic Collection<Plugin> getPlugins()
public String getCanonicalName(Plugin plugin)
plugin
- A plugin (cannot be null).@Deprecated public Plugin getPlugin(String canonicalName)
getPluginByName(String)
null
if a plugin with that name does not exist. The
canonical name is the lowercase-name of the plugin archive, without the file extension. For example: "broadcast".canonicalName
- the name of the plugin.public Optional<Plugin> getPluginByName(String pluginName)
pluginName
- the name of the plugin.@Deprecated public File getPluginDirectory(Plugin plugin)
plugin
- the plugin to get the directory forpublic Path getPluginPath(Plugin plugin)
plugin
- the plugin.public boolean isExecuted()
public void deletePlugin(String pluginName)
pluginName
- the plugin to deletepublic boolean reloadPlugin(String pluginName)
public Class loadClass(Plugin plugin, String className) throws ClassNotFoundException
plugin
- the plugin.className
- the name of the class to load.ClassNotFoundException
- if the class was not found.public PluginDevEnvironment getDevEnvironment(Plugin plugin)
plugin
- the plugin.null
if development
mode is not enabled for the plugin.@Deprecated public String getName(Plugin plugin)
PluginMetadataHelper.getName(Plugin)
.plugin
- the plugin to get the name for@Deprecated public String getDescription(Plugin plugin)
PluginMetadataHelper.getDescription(Plugin)
.plugin
- the plugin to get the description for@Deprecated public String getAuthor(Plugin plugin)
PluginMetadataHelper.getAuthor(Plugin)
.plugin
- the plugin to get the author for@Deprecated public String getVersion(Plugin plugin)
PluginMetadataHelper.getVersion(Plugin)
.plugin
- the plugin to get the version for@Deprecated public String getMinServerVersion(Plugin plugin)
PluginMetadataHelper.getMinServerVersion(Plugin)
.plugin
- the plugin to get the minimum server version for@Deprecated public String getDatabaseKey(Plugin plugin)
PluginMetadataHelper.getDatabaseKey(Plugin)
.plugin
- the plugin to get the database key for@Deprecated public int getDatabaseVersion(Plugin plugin)
PluginMetadataHelper.getDatabaseVersion(Plugin)
.plugin
- the plugin to get the database version for@Deprecated public String getLicense(Plugin plugin)
PluginMetadataHelper.getLicense(Plugin)
.plugin
- the plugin to get the licence forpublic PluginClassLoader getPluginClassloader(Plugin plugin)
plugin
- the plugin.public void addPluginListener(PluginListener listener)
listener
- the listener to be notified (cannot be null).public void removePluginListener(PluginListener listener)
listener
- the listener to be removed (cannot be null).public void addPluginManagerListener(PluginManagerListener listener)
listener
- the listener to be notified (cannot be null).public void removePluginManagerListener(PluginManagerListener listener)
listener
- the listener to be notified (cannot be null).public boolean isMonitorTaskRunning()
Copyright © 2003–2019 Ignite Realtime. All rights reserved.