public class ServerPluginManager extends Object
| Constructor and Description |
|---|
ServerPluginManager(AbstractTypeServerPluginContainer pc)
Creates a plugin manager for the given plugin container.
|
| Modifier and Type | Method and Description |
|---|---|
protected ServerPluginComponent |
createServerPluginComponent(ServerPluginEnvironment environment)
This will create a new
ServerPluginComponent instance for that is used to
initialize and shutdown a particular server plugin. |
protected void |
disablePlugin(String pluginName) |
protected void |
enablePlugin(String pluginName) |
protected org.apache.commons.logging.Log |
getLog() |
AbstractTypeServerPluginContainer |
getParentPluginContainer()
Returns the plugin container that whose plugins are managed by this manager.
|
protected org.rhq.core.domain.plugin.ServerPlugin |
getPlugin(ServerPluginEnvironment pluginEnv)
Given a plugin environment, return its
ServerPlugin representation, which should also include
the plugin configuration and scheduled jobs configuration. |
ServerPluginEnvironment |
getPluginEnvironment(String pluginName)
Given a plugin name, this returns that plugin's environment.
|
Collection<ServerPluginEnvironment> |
getPluginEnvironments()
Returns the
ServerPluginEnvironments for every plugin this manager has loaded. |
protected ServerPluginComponent |
getServerPluginComponent(String pluginName)
Returns the main plugin component instance that is responsible for initializing and managing
the plugin.
|
protected ServerPluginContext |
getServerPluginContext(ServerPluginEnvironment env) |
protected void |
initialize()
Initializes the plugin manager to prepare it to start loading plugins.
|
protected Object |
instantiatePluginClass(ServerPluginEnvironment environment,
String className)
Instantiates a class with the given name within the given environment's classloader using
the class' no-arg constructor.
|
protected boolean |
isPluginEnabled(String pluginName) |
protected boolean |
isPluginLoaded(String pluginName) |
protected void |
loadPlugin(ServerPluginEnvironment env,
boolean enabled)
Informs the plugin manager that a plugin with the given environment needs to be loaded.
|
protected Class<?> |
loadPluginClass(ServerPluginEnvironment environment,
String className,
boolean initialize)
Loads a class with the given name within the given environment's classloader.
|
protected ServerPluginEnvironment |
rebuildServerPluginEnvironment(ServerPluginEnvironment env)
Given a plugin environment, this will rebuild a new one with up-to-date information.
|
protected void |
reloadPlugin(String pluginName,
boolean enabled)
This will reload a plugin allowing you to enable or disable it.
|
protected void |
shutdown()
Shuts down this manager.
|
protected void |
startPlugin(String pluginName) |
protected void |
startPlugins() |
protected void |
stopPlugin(String pluginName) |
protected void |
stopPlugins() |
protected void |
unloadPlugin(String pluginName)
Informs the plugin manager that a plugin with the given name is to be unloaded.
|
protected void |
unloadPlugin(String pluginName,
boolean keepClassLoader)
Informs the plugin manager that a plugin with the given name is to be unloaded.
|
public ServerPluginManager(AbstractTypeServerPluginContainer pc)
pc - the plugin manager's owning plugin containerpublic AbstractTypeServerPluginContainer getParentPluginContainer()
public Collection<ServerPluginEnvironment> getPluginEnvironments()
ServerPluginEnvironments for every plugin this manager has loaded.
The returned collection is a copy and not backed by this manager.public ServerPluginEnvironment getPluginEnvironment(String pluginName)
The plugin's name is defined in its plugin descriptor - specifically the XML root node's "name" attribute (e.g. <server-plugin name="thePluginName").
pluginName - the plugin whose environment is to be returnedprotected void initialize()
throws Exception
Exception - if failed to initializeprotected void shutdown()
unloaded.protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception
enabled is false, in which case the plugin will not
be initialized.env - the environment of the plugin to be loadedenabled - true if the plugin should be initialized; false if
the plugin's existence should be noted but it should not be initialized or startedException - if the plugin manager cannot load the plugin or deems the plugin invalid.
Typically, this method will not throw an exception unless enabled is
true - loading a disabled plugin is trivial and should not
fail or throw an exception.protected void startPlugins()
protected void startPlugin(String pluginName)
protected void stopPlugins()
protected void stopPlugin(String pluginName)
protected void unloadPlugin(String pluginName) throws Exception
pluginName - the name of the plugin to be unloadedException - if the plugin manager cannot unload the pluginprotected void unloadPlugin(String pluginName, boolean keepClassLoader) throws Exception
keepClassLoader is true, this is the same as
unloadPlugin(String).
You want to keep the classloader if you are only temporarily unloading the plugin, and
will load it back soon.
Subclasses of this plugin manager class will normally not override this method; instead,
they will typically want to override unloadPlugin(String).pluginName - the name of the plugin to be unloadedkeepClassLoader - if true the classloader is not destroyedException - if the plugin manager cannot unload the pluginprotected void reloadPlugin(String pluginName, boolean enabled) throws Exception
start the plugin component if you enable it.
This will stop the plugin component if you disable it.
This will ensure any new plugin configuration will be re-loaded.pluginName - the name of the loaded plugin that is to be enabled or disabledenabled - true if you want to enable the plugin; false
if you want to disable itException - if the plugin was never loaded before or the reload failedprotected boolean isPluginLoaded(String pluginName)
protected boolean isPluginEnabled(String pluginName)
protected ServerPluginComponent getServerPluginComponent(String pluginName)
null if a plugin has not defined a plugin component.pluginName - the name of the plugin whose plugin component is to be returnednull if the plugin has not defined a plugin component.
null is also returned if the plugin is not initialized yet.protected org.apache.commons.logging.Log getLog()
protected ServerPluginContext getServerPluginContext(ServerPluginEnvironment env)
protected ServerPluginEnvironment rebuildServerPluginEnvironment(ServerPluginEnvironment env) throws Exception
env - the original environmentException - if the environment could not be rebuilt - probably due to an invalid descriptor
in the plugin jar or the plugin jar is now missingprotected org.rhq.core.domain.plugin.ServerPlugin getPlugin(ServerPluginEnvironment pluginEnv)
ServerPlugin representation, which should also include
the plugin configuration and scheduled jobs configuration.pluginEnv - protected ServerPluginComponent createServerPluginComponent(ServerPluginEnvironment environment) throws Exception
ServerPluginComponent instance for that is used to
initialize and shutdown a particular server plugin. If there is no plugin component
configured for the given plugin, null is returned.
The new object will be loaded in the plugin's specific classloader.environment - the environment in which the plugin will executenull if there is no plugin component to be associated with the given pluginException - if failed to create the instanceprotected Class<?> loadPluginClass(ServerPluginEnvironment environment, String className, boolean initialize) throws Exception
initialize is true.environment - the environment that has the classloader where the class will be loadedclassName - the class to loadinitialize - whether the class must be initializedException - if failed to load the classprotected Object instantiatePluginClass(ServerPluginEnvironment environment, String className) throws Exception
environment - the environment that has the classloader where the class will be loadedclassName - the class to instantiateException - if failed to instantiate the classCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.