Clearspace API (1.10.16) Core 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

Field Summary
protected  ApplicationLifeCycle.Listener applicationLifeCycleListener
           
protected  java.util.Map<java.util.Locale,java.util.List<java.util.ResourceBundle>> bundleCache
           
protected  java.util.Map<Plugin<?>,java.lang.String> childPluginMap
           
protected  java.util.Map<Plugin<?>,com.jivesoftware.base.plugin.PluginClassLoader> classloaders
           
protected  java.util.List<java.lang.String> customURLMapperList
           
protected  java.util.concurrent.ExecutorService delayedLoadExecutor
           
protected  java.util.Set<java.lang.String> devPlugins
           
protected  java.util.concurrent.ScheduledExecutorService executor
           
protected  java.util.concurrent.atomic.AtomicBoolean initialized
           
protected  java.util.Map<Plugin<?>,java.util.List<java.lang.String>> parentPluginMap
           
protected  java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> pluginCSSs
           
protected  java.io.File pluginDirectory
           
protected  java.util.Map<Plugin<?>,java.io.File> pluginDirs
           
protected  java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> pluginJavascripts
           
protected  java.util.Set<PluginListener> pluginListeners
           
protected  java.util.Map<java.lang.Object,PluginMetaDataImpl> pluginMeta
           
protected  com.jivesoftware.base.plugin.PluginMonitor pluginMonitor
           
protected  java.util.Map<java.lang.String,JiveProperties<java.lang.String,java.lang.String>> pluginProperties
           
protected  java.util.Map<java.lang.String,com.jivesoftware.base.plugin.PluginConfigurationProvider> pluginProviders
           
protected  java.util.Map<java.lang.String,Plugin<?>> plugins
           
 
Constructor Summary
PluginManager(java.io.File pluginDir)
          Constructs a new plugin manager.
 
Method Summary
protected  void addPluginCSSSourceURLs(java.lang.String pluginName, java.util.Collection<java.lang.String> urls)
          Add a collection of CSS urls for a plugin.
protected  void addPluginJavascriptSourceURLs(java.lang.String pluginName, java.util.Collection<java.lang.String> urls)
          Add a collection of javascript urls for a plugin.
 void addPluginListener(PluginListener listener)
          Registers a plugin applicationLifeCycleListener.
protected  void configureCaches(com.jivesoftware.base.plugin.PluginMetaData meta)
          Checks to see if the plugin has a cache-config.xml.
protected  void configureDWR(com.jivesoftware.base.plugin.PluginMetaData meta)
          Checks to see if the plugin has a dwr-plugin.xml.
protected  void configureUIComponents(org.dom4j.Document pluginXML, org.dom4j.Element parentPluginNode, java.lang.String pluginName)
           
protected  void configureWebwork(com.jivesoftware.base.plugin.PluginMetaData meta)
           
 void deletePlugin(Plugin<?> plugin)
          Removes a plugin from the system.
 void destroy()
          Shuts down all running plugins.
protected  com.jivesoftware.base.plugin.PluginClassLoader determinePluginClassLoader(java.io.File pluginDir, org.dom4j.Element parentPluginNode)
           
 java.util.Collection<java.lang.ClassLoader> getClassLoaders()
          Returns a collection of all plugin classloaders.
protected  java.util.Set<java.lang.String> getDevPlugins()
          Returns a set of all the plugins that have been specified with -DpluginDirs system property
 Plugin<?> getPlugin(java.lang.String name)
          Returns a plugin by name or null if a plugin with that name does not exist.
 com.jivesoftware.base.plugin.PluginClassLoader getPluginClassloader(Plugin<?> plugin)
          Returns the classloader of a plugin.
 java.util.Collection<java.lang.String> getPluginCSSSrcURLs()
          Returns a list of all CSS source urls defined by plugins
protected  java.io.File getPluginDirectory()
          Returns the directory {jiveHome}/plugins.
protected  java.io.File getPluginDirectory(Plugin<?> plugin)
          Returns the plugin's directory.
 java.util.Collection<java.lang.String> getPluginJavascriptSrcURLs()
          Returns a list of all javascript source urls defined by plugins
protected  java.util.Map<java.lang.String,Plugin<?>> getPluginMap()
          Returns a map of plugin name plugin entries.
 com.jivesoftware.base.plugin.PluginMetaData getPluginMetaData(Plugin<?> plugin)
          Returns meta data assosiated with the plugin.
 com.jivesoftware.base.plugin.PluginMetaData getPluginMetaData(java.lang.String name)
          Returns meta data associated with the plugin.
protected  com.jivesoftware.base.plugin.PluginMonitor getPluginMonitor()
          Returns the PluginMonitor instance.
protected  JiveProperties<java.lang.String,java.lang.String> getPluginProperties(java.lang.String pluginName)
          Returns a object for storing and receving property setting for a plugin.
 java.util.ResourceBundle getPluginResourceBundle(Plugin<?> plugin, java.util.Locale locale)
          Acquires a plugins resource bundle which should be stored in /plugin_i18n in the plugin's classloader.
 java.util.List<java.util.ResourceBundle> getPluginResourceBundles(java.util.Locale l)
          Returns all of the plugin resource bundles that match the specified locale.
 java.util.Collection<Plugin<?>> getPlugins()
          Returns a Collection of all installed plugins.
protected  void handleDatabase(Plugin<?> plugin, java.lang.String pluginName)
           
protected  int handleUpgradeTasks(java.io.File pluginDir, Plugin<?> p)
           
 void initialize(JiveContext ctx)
          Starts plugins and the plugin monitoring service.
 void installPlugin(java.io.InputStream in, java.lang.String pluginFilename)
          Installs or updates an existing plugin.
protected  void installPlugin(java.io.InputStream in, java.lang.String pluginFilename, boolean notifyCluster)
          Installs or updates an existing plugin, with the option to notify the rest of the cluster.
 boolean isInitialized()
           
 boolean isPluginDownloaded(java.lang.String pluginFilename)
          Returns true if the specified filename, that belongs to a plugin, exists.
protected  boolean isValidVersion(org.dom4j.Document pluginXML, java.io.File pluginDir, boolean validVersion)
           
 java.lang.Class<?> loadClass(Plugin<?> plugin, java.lang.String className)
          Loads a class from the classloader of a plugin.
 void loadPlugin(java.io.File pluginDir)
          Loads a plug-in module into the container.
protected  void registerMacro(BaseMacro macroWrapper)
          Registers a plugin macro with the owner's render manager.
protected  void registerMacros(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerPlugin(org.dom4j.Element parentPluginNode, com.jivesoftware.base.plugin.PluginClassLoader pluginLoader, Plugin<?> plugin, java.io.File pluginDir)
           
protected  void registerPluginCSSURLs(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerPluginJavascriptURLs(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerSitemeshElements(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerURLMapper(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerWebServices(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void registerWidgets(com.jivesoftware.base.plugin.PluginMetaData meta)
           
protected  void removePluginCSSURLs(java.lang.String pluginName)
          Remove CSS source urls specified by the plugin
protected  void removePluginJavaScriptURLs(java.lang.String pluginName)
          Remove javascript source urls specified by the plugin
 void removePluginListener(PluginListener listener)
          Unregisters a plugin applicationLifeCycleListener.
 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
 

Field Detail

pluginDirectory

protected java.io.File pluginDirectory

plugins

protected java.util.Map<java.lang.String,Plugin<?>> plugins

pluginMeta

protected java.util.Map<java.lang.Object,PluginMetaDataImpl> pluginMeta

classloaders

protected java.util.Map<Plugin<?>,com.jivesoftware.base.plugin.PluginClassLoader> classloaders

pluginDirs

protected java.util.Map<Plugin<?>,java.io.File> pluginDirs

executor

protected java.util.concurrent.ScheduledExecutorService executor

parentPluginMap

protected java.util.Map<Plugin<?>,java.util.List<java.lang.String>> parentPluginMap

childPluginMap

protected java.util.Map<Plugin<?>,java.lang.String> childPluginMap

devPlugins

protected java.util.Set<java.lang.String> devPlugins

pluginMonitor

protected com.jivesoftware.base.plugin.PluginMonitor pluginMonitor

pluginListeners

protected java.util.Set<PluginListener> pluginListeners

pluginProviders

protected java.util.Map<java.lang.String,com.jivesoftware.base.plugin.PluginConfigurationProvider> pluginProviders

pluginJavascripts

protected java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> pluginJavascripts

pluginCSSs

protected java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> pluginCSSs

pluginProperties

protected java.util.Map<java.lang.String,JiveProperties<java.lang.String,java.lang.String>> pluginProperties

bundleCache

protected java.util.Map<java.util.Locale,java.util.List<java.util.ResourceBundle>> bundleCache

delayedLoadExecutor

protected java.util.concurrent.ExecutorService delayedLoadExecutor

applicationLifeCycleListener

protected ApplicationLifeCycle.Listener applicationLifeCycleListener

customURLMapperList

protected java.util.List<java.lang.String> customURLMapperList

initialized

protected java.util.concurrent.atomic.AtomicBoolean initialized
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(JiveContext ctx)
Starts plugins and the plugin monitoring service.

Specified by:
initialize in interface JiveManager
Parameters:
ctx - the context to use during initialization

destroy

public void destroy()
Shuts down all running plugins.

Specified by:
destroy in interface JiveManager

isInitialized

public boolean isInitialized()

installPlugin

public void installPlugin(java.io.InputStream in,
                          java.lang.String pluginFilename)
                   throws com.jivesoftware.base.plugin.PluginException
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.
Throws:
PluginException - Thrown if there are issues installing the plugin.

installPlugin

protected void installPlugin(java.io.InputStream in,
                             java.lang.String pluginFilename,
                             boolean notifyCluster)
                      throws com.jivesoftware.base.plugin.PluginException
Installs or updates an existing plugin, with the option to notify the rest of the cluster. The cluster should not be notified if this is being called from a cluster task.

Parameters:
in - the input stream that contains the new plugin definition.
pluginFilename - the filename of the plugin to create or update.
notifyCluster - Whether or not the cluster should be notified.
Throws:
PluginException - Thrown if there are issues installing the plugin.

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<Plugin<?>> getPlugins()
Returns a Collection of all installed plugins.

Returns:
a Collection of all installed plugins.

getClassLoaders

public java.util.Collection<java.lang.ClassLoader> getClassLoaders()
Returns a collection of all plugin classloaders.

Returns:
a collection of all plugin classloaders.

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.

getPluginMetaData

public com.jivesoftware.base.plugin.PluginMetaData getPluginMetaData(java.lang.String name)
Returns meta data associated with the plugin.

Parameters:
name - The name of the plugin.
Returns:
meta data associated with the plugin.

getPluginMetaData

public com.jivesoftware.base.plugin.PluginMetaData getPluginMetaData(Plugin<?> plugin)
Returns meta data assosiated with the plugin.

Parameters:
plugin - The plugin to acquire meta data for
Returns:
meta data associated with the plugin.

getPluginJavascriptSrcURLs

public java.util.Collection<java.lang.String> getPluginJavascriptSrcURLs()
Returns a list of all javascript source urls defined by plugins

Returns:
a list of all javascript source urls defined by plugins

getPluginCSSSrcURLs

public java.util.Collection<java.lang.String> getPluginCSSSrcURLs()
Returns a list of all CSS source urls defined by plugins

Returns:
a list of all CSS source urls defined by plugins

addPluginJavascriptSourceURLs

protected void addPluginJavascriptSourceURLs(java.lang.String pluginName,
                                             java.util.Collection<java.lang.String> urls)
Add a collection of javascript urls for a plugin.

Parameters:
pluginName - The name of the plugin
urls - The urls added

addPluginCSSSourceURLs

protected void addPluginCSSSourceURLs(java.lang.String pluginName,
                                      java.util.Collection<java.lang.String> urls)
Add a collection of CSS urls for a plugin.

Parameters:
pluginName - The name of the plugin
urls - The urls added

removePluginJavaScriptURLs

protected void removePluginJavaScriptURLs(java.lang.String pluginName)
Remove javascript source urls specified by the plugin

Parameters:
pluginName - javascript source urls specified by the plugin

removePluginCSSURLs

protected void removePluginCSSURLs(java.lang.String pluginName)
Remove CSS source urls specified by the plugin

Parameters:
pluginName - CSS source urls specified by the plugin

getPluginDirectory

protected java.io.File getPluginDirectory(Plugin<?> plugin)
Returns the plugin's directory.

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

getPluginProperties

protected JiveProperties<java.lang.String,java.lang.String> getPluginProperties(java.lang.String pluginName)
Returns a object for storing and receving property setting for a plugin. Property stored in this object will be persisted and updated across the cluster.

Parameters:
pluginName - The name of the plugin to get a properties object for.
Returns:
Object for storing and receiving plugin properties.

getPluginResourceBundles

public java.util.List<java.util.ResourceBundle> getPluginResourceBundles(java.util.Locale l)
Returns all of the plugin resource bundles that match the specified locale.

Parameters:
l - The locale to acquire plugin resource bundles for.
Returns:
All the plugin resource bundles that match the locale.
See Also:
getPluginResourceBundle(com.jivesoftware.base.plugin.Plugin, java.util.Locale)

loadPlugin

public void loadPlugin(java.io.File pluginDir)
                throws com.jivesoftware.base.plugin.PluginException
Loads a plug-in module into the container. Loading consists of the following steps:

Parameters:
pluginDir - the plugin directory.
Throws:
PluginException - Thrown if there are issues installing the plugin.

registerPluginJavascriptURLs

protected void registerPluginJavascriptURLs(com.jivesoftware.base.plugin.PluginMetaData meta)

registerPluginCSSURLs

protected void registerPluginCSSURLs(com.jivesoftware.base.plugin.PluginMetaData meta)

registerWebServices

protected void registerWebServices(com.jivesoftware.base.plugin.PluginMetaData meta)

registerURLMapper

protected void registerURLMapper(com.jivesoftware.base.plugin.PluginMetaData meta)

registerSitemeshElements

protected void registerSitemeshElements(com.jivesoftware.base.plugin.PluginMetaData meta)

registerMacros

protected void registerMacros(com.jivesoftware.base.plugin.PluginMetaData meta)
                       throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

registerWidgets

protected void registerWidgets(com.jivesoftware.base.plugin.PluginMetaData meta)
                        throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

registerMacro

protected void registerMacro(BaseMacro macroWrapper)
Registers a plugin macro with the owner's render manager.

Parameters:
macroWrapper - The macro to register

registerPlugin

protected void registerPlugin(org.dom4j.Element parentPluginNode,
                              com.jivesoftware.base.plugin.PluginClassLoader pluginLoader,
                              Plugin<?> plugin,
                              java.io.File pluginDir)

isValidVersion

protected boolean isValidVersion(org.dom4j.Document pluginXML,
                                 java.io.File pluginDir,
                                 boolean validVersion)

handleDatabase

protected void handleDatabase(Plugin<?> plugin,
                              java.lang.String pluginName)
                       throws java.lang.Exception
Throws:
java.lang.Exception

configureUIComponents

protected void configureUIComponents(org.dom4j.Document pluginXML,
                                     org.dom4j.Element parentPluginNode,
                                     java.lang.String pluginName)
                              throws java.lang.Exception
Throws:
java.lang.Exception

configureWebwork

protected void configureWebwork(com.jivesoftware.base.plugin.PluginMetaData meta)

configureDWR

protected void configureDWR(com.jivesoftware.base.plugin.PluginMetaData meta)
Checks to see if the plugin has a dwr-plugin.xml. If so we will add this configuration to the dwr configuration.

Parameters:
meta - The meta data object for the plugin.

configureCaches

protected void configureCaches(com.jivesoftware.base.plugin.PluginMetaData meta)
Checks to see if the plugin has a cache-config.xml. If so we will register the cache config info with the cache factory.

Parameters:
meta - The meta data object for the plugin.

getPluginResourceBundle

public java.util.ResourceBundle getPluginResourceBundle(Plugin<?> plugin,
                                                        java.util.Locale locale)
Acquires a plugins resource bundle which should be stored in /plugin_i18n in the plugin's classloader.

Parameters:
plugin - The plugin to acquire a resource bundle for.
locale - The locale of the resource bundle.
Returns:
The resource bundle for a plugin.

determinePluginClassLoader

protected com.jivesoftware.base.plugin.PluginClassLoader determinePluginClassLoader(java.io.File pluginDir,
                                                                                    org.dom4j.Element parentPluginNode)

handleUpgradeTasks

protected int handleUpgradeTasks(java.io.File pluginDir,
                                 Plugin<?> p)

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.

getPluginClassloader

public com.jivesoftware.base.plugin.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 applicationLifeCycleListener. 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 applicationLifeCycleListener. The plugin applicationLifeCycleListener will not longer be notified when plugins are loaded and unloaded.

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

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<java.lang.String> 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<java.lang.String,Plugin<?>> 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.

Clearspace Project Page

Copyright © 1999-2007 Jive Software.