|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.enterprise.server.plugin.pc.ServerPluginManager
public class ServerPluginManager
Provides functionality to manage plugins for a plugin container. Plugin containers can install their own plugin managers that are extensions to this class if they need to. Most of the methods here are protected; they are meant for the plugin container's use only. Usually, anything an external client needs will be done through a delegation method found on the plugin container.
| Constructor Summary | |
|---|---|
ServerPluginManager(AbstractTypeServerPluginContainer pc)
Creates a plugin manager for the given plugin container. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ServerPluginManager(AbstractTypeServerPluginContainer pc)
pc - the plugin manager's owning plugin container| Method Detail |
|---|
public 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 returned
protected 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 started
Exception - 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 unloaded
Exception - if the plugin manager cannot unload the plugin
protected 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 destroyed
Exception - if the plugin manager cannot unload the plugin
protected 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 it
Exception - if the plugin was never loaded before or the reload failed
protected void enablePlugin(String pluginName)
throws Exception
Exception
protected void disablePlugin(String pluginName)
throws Exception
Exceptionprotected 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 returned
null 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 environment
Exception - 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 execute
null if there is no plugin component to be associated with the given plugin
Exception - if failed to create the instance
protected 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 initialized
Exception - if failed to load the class
protected Object instantiatePluginClass(ServerPluginEnvironment environment,
String className)
throws Exception
environment - the environment that has the classloader where the class will be loadedclassName - the class to instantiate
Exception - if failed to instantiate the class
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||