org.rhq.enterprise.server.plugin
Class ServerPluginsBean

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.ServerPluginsBean
All Implemented Interfaces:
ServerPluginsLocal

public class ServerPluginsBean
extends Object
implements ServerPluginsLocal

A server API into the server plugin infrastructure.

Author:
John Mazzitelli

Constructor Summary
ServerPluginsBean()
           
 
Method Summary
 List<org.rhq.core.domain.plugin.PluginKey> disableServerPlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          Disables the plugins and unschedules their jobs.
 List<org.rhq.core.domain.plugin.PluginKey> enableServerPlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          Enables the plugins and restarts them.
 List<org.rhq.core.domain.plugin.ServerPlugin> getAllServerPlugins()
          Returns a list of all the installed and deleted server plugins in the database.
 List<org.rhq.core.domain.plugin.ServerPlugin> getAllServerPluginsById(List<Integer> pluginIds)
          Get a list of both installed and deleted plugins from their IDs.
 Map<ServerPluginType,List<org.rhq.core.domain.plugin.PluginKey>> getInstalledServerPluginsGroupedByType()
          This will return a map containing all installed plugins that are both enabled and disabled.
 long getLastConfigurationChangeTimestamp(int pluginId)
          Given a plugin ID, this will return a timestamp (in epoch millis) that indicates the last time when the plugin's configuration changed.
 org.rhq.core.domain.plugin.ServerPlugin getServerPlugin(org.rhq.core.domain.plugin.PluginKey key)
          Returns a plugin with the given key.
 org.rhq.core.domain.configuration.definition.ConfigurationDefinition getServerPluginConfigurationDefinition(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Returns the definition for the given plugin's global plugin configuration.
 List<ControlDefinition> getServerPluginControlDefinitions(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Returns the metadata for all control operations for the given plugin.
 ServerPluginDescriptorType getServerPluginDescriptor(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Given a plugin key, returns the descriptor for that plugin.
 List<org.rhq.core.domain.plugin.PluginKey> getServerPluginKeysByEnabled(boolean enabled)
          Returns a list of plugin keys for only those server plugins whose enabled flag is equal to the given parameter.
 org.rhq.core.domain.plugin.ServerPlugin getServerPluginRelationships(org.rhq.core.domain.plugin.ServerPlugin plugin)
          Methods in this object that return plugins normally do not include the data from relationships with the plugin (for example, the plugin configuration and scheduled jobs related to the plugin).
 List<org.rhq.core.domain.plugin.ServerPlugin> getServerPlugins()
          Returns a list of all the installed server plugins in the database
 List<org.rhq.core.domain.plugin.ServerPlugin> getServerPluginsById(List<Integer> pluginIds)
          Get a list of plugins from their IDs.
 org.rhq.core.domain.configuration.definition.ConfigurationDefinition getServerPluginScheduledJobsDefinition(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Returns the definition for the given plugin's scheduled jobs configuration.
 org.rhq.core.domain.plugin.PluginStatusType getServerPluginStatus(org.rhq.core.domain.plugin.PluginKey pluginKey)
          Given the key of a server plugin, this will return the status of that plugin.
 ControlResults invokeServerPluginControl(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.PluginKey pluginKey, String controlName, org.rhq.core.domain.configuration.Configuration params)
          Invokes a control operation on a given plugin and returns the results.
 void purgeServerPlugin(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.PluginKey pluginKey)
          Purges the server plugin from the database.
 List<org.rhq.core.domain.plugin.PluginKey> purgeServerPlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          Purges the undeployed plugins from the system so there is no record of them to have ever existed.
 org.rhq.core.domain.plugin.ServerPlugin registerServerPlugin(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.ServerPlugin plugin, File pluginFile)
          Registers the given plugin to the database.
 void restartMasterPluginContainer(org.rhq.core.domain.auth.Subject subject)
          Recycles the master plugin container, essentially shutting down all server plugins and then restarting them.
 void setServerPluginEnabledFlag(org.rhq.core.domain.auth.Subject subject, int pluginId, boolean enabled)
          Turns on or off the enabled flag in the database but does NOT restart the server plugin.
 void setServerPluginStatus(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds, org.rhq.core.domain.plugin.PluginStatusType status)
          Sets the status flag in the database but does NOT restart the server plugin container.
 List<org.rhq.core.domain.plugin.PluginKey> undeployServerPlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          Removes the plugins from the system and unschedules their jobs.
 org.rhq.core.domain.plugin.ServerPlugin updateServerPluginExceptContent(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.ServerPlugin plugin)
          Given a plugin that already exists, this will update that plugin's data in the database, except for the content, which is left as-is.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPluginsBean

public ServerPluginsBean()
Method Detail

restartMasterPluginContainer

public void restartMasterPluginContainer(org.rhq.core.domain.auth.Subject subject)
Description copied from interface: ServerPluginsLocal
Recycles the master plugin container, essentially shutting down all server plugins and then restarting them.

Specified by:
restartMasterPluginContainer in interface ServerPluginsLocal
Parameters:
subject - the user asking to restart the master plugin container

getServerPlugins

public List<org.rhq.core.domain.plugin.ServerPlugin> getServerPlugins()
Description copied from interface: ServerPluginsLocal
Returns a list of all the installed server plugins in the database

Specified by:
getServerPlugins in interface ServerPluginsLocal
Returns:
all installed server plugins found in the DB

getAllServerPlugins

public List<org.rhq.core.domain.plugin.ServerPlugin> getAllServerPlugins()
Description copied from interface: ServerPluginsLocal
Returns a list of all the installed and deleted server plugins in the database. When a plugin is "undeployed", it still exists in the database, but is flagged as "deleted". This method returns those deleted plugins in addition to those plugins that are still installed.

Specified by:
getAllServerPlugins in interface ServerPluginsLocal
Returns:
all installed and deleted server plugins found in the DB

getServerPlugin

public org.rhq.core.domain.plugin.ServerPlugin getServerPlugin(org.rhq.core.domain.plugin.PluginKey key)
Description copied from interface: ServerPluginsLocal
Returns a plugin with the given key.

Specified by:
getServerPlugin in interface ServerPluginsLocal
Parameters:
key - identifies the plugin to find
Returns:
the named plugin

getServerPluginRelationships

public org.rhq.core.domain.plugin.ServerPlugin getServerPluginRelationships(org.rhq.core.domain.plugin.ServerPlugin plugin)
Description copied from interface: ServerPluginsLocal
Methods in this object that return plugins normally do not include the data from relationships with the plugin (for example, the plugin configuration and scheduled jobs related to the plugin). Call this method to fill in that data that wasn't originally loaded.

Specified by:
getServerPluginRelationships in interface ServerPluginsLocal
Returns:
the same plugin, with the relationship data loaded

getServerPluginsById

public List<org.rhq.core.domain.plugin.ServerPlugin> getServerPluginsById(List<Integer> pluginIds)
Description copied from interface: ServerPluginsLocal
Get a list of plugins from their IDs.

Specified by:
getServerPluginsById in interface ServerPluginsLocal
Parameters:
pluginIds - the IDs of the plugins to load.
Returns:
plugins matching the given IDs

getAllServerPluginsById

public List<org.rhq.core.domain.plugin.ServerPlugin> getAllServerPluginsById(List<Integer> pluginIds)
Description copied from interface: ServerPluginsLocal
Get a list of both installed and deleted plugins from their IDs.

Specified by:
getAllServerPluginsById in interface ServerPluginsLocal
Parameters:
pluginIds - the IDs of the plugins to load.
Returns:
plugins matching the given IDs

getLastConfigurationChangeTimestamp

public long getLastConfigurationChangeTimestamp(int pluginId)
Description copied from interface: ServerPluginsLocal
Given a plugin ID, this will return a timestamp (in epoch millis) that indicates the last time when the plugin's configuration changed. This looks at both plugin configuration and schedule job configuration.

Specified by:
getLastConfigurationChangeTimestamp in interface ServerPluginsLocal
Returns:
time when the plugin's configuration was last updated; will be 0 if the plugin has no configuration to change.

getServerPluginDescriptor

public ServerPluginDescriptorType getServerPluginDescriptor(org.rhq.core.domain.plugin.PluginKey pluginKey)
                                                     throws Exception
Description copied from interface: ServerPluginsLocal
Given a plugin key, returns the descriptor for that plugin.

Specified by:
getServerPluginDescriptor in interface ServerPluginsLocal
Returns:
descriptor parsed from the file in the plugin jar
Throws:
Exception - if the descriptor could not be retrieved or parsed for the given plugin

getServerPluginKeysByEnabled

public List<org.rhq.core.domain.plugin.PluginKey> getServerPluginKeysByEnabled(boolean enabled)
Description copied from interface: ServerPluginsLocal
Returns a list of plugin keys for only those server plugins whose enabled flag is equal to the given parameter.

Specified by:
getServerPluginKeysByEnabled in interface ServerPluginsLocal
Parameters:
enabled - if true, return only the keys of plugins that are enabled; if false, return only the keys of plugins that are disabled.
Returns:
list of plugin keys that match the enabled criteria

enableServerPlugins

public List<org.rhq.core.domain.plugin.PluginKey> enableServerPlugins(org.rhq.core.domain.auth.Subject subject,
                                                                      List<Integer> pluginIds)
                                                               throws Exception
Description copied from interface: ServerPluginsLocal
Enables the plugins and restarts them.

Specified by:
enableServerPlugins in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginIds - the plugins to be enabled
Returns:
the list of keys of the plugins that were enabled
Throws:
Exception - if failed to disable a plugin

disableServerPlugins

public List<org.rhq.core.domain.plugin.PluginKey> disableServerPlugins(org.rhq.core.domain.auth.Subject subject,
                                                                       List<Integer> pluginIds)
                                                                throws Exception
Description copied from interface: ServerPluginsLocal
Disables the plugins and unschedules their jobs.

Specified by:
disableServerPlugins in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginIds - the plugins to be disabled
Returns:
the list of keys of the plugins that were disabled
Throws:
Exception - if failed to disable a plugin

undeployServerPlugins

public List<org.rhq.core.domain.plugin.PluginKey> undeployServerPlugins(org.rhq.core.domain.auth.Subject subject,
                                                                        List<Integer> pluginIds)
                                                                 throws Exception
Description copied from interface: ServerPluginsLocal
Removes the plugins from the system and unschedules their jobs.

Specified by:
undeployServerPlugins in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginIds - the plugins to be undeployed
Returns:
the list of keys of plugins that were undeployed
Throws:
Exception - if failed to undeploy a plugin

purgeServerPlugins

public List<org.rhq.core.domain.plugin.PluginKey> purgeServerPlugins(org.rhq.core.domain.auth.Subject subject,
                                                                     List<Integer> pluginIds)
                                                              throws Exception
Description copied from interface: ServerPluginsLocal
Purges the undeployed plugins from the system so there is no record of them to have ever existed. This deletes all remnants of the plugin from the database.

Specified by:
purgeServerPlugins in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginIds - the plugins to be purged
Returns:
the list of keys of plugins that were purged
Throws:
Exception - if failed to purge a plugin

setServerPluginEnabledFlag

public void setServerPluginEnabledFlag(org.rhq.core.domain.auth.Subject subject,
                                       int pluginId,
                                       boolean enabled)
                                throws Exception
Description copied from interface: ServerPluginsLocal
Turns on or off the enabled flag in the database but does NOT restart the server plugin. This has "requires new" semantics, so the results are committed immediately upon return.

Specified by:
setServerPluginEnabledFlag in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginId - the plugin to be enabled
enabled - the value of the enabled flag for the plugin
Throws:
Exception

setServerPluginStatus

public void setServerPluginStatus(org.rhq.core.domain.auth.Subject subject,
                                  List<Integer> pluginIds,
                                  org.rhq.core.domain.plugin.PluginStatusType status)
                           throws Exception
Description copied from interface: ServerPluginsLocal
Sets the status flag in the database but does NOT restart the server plugin container. If the status is PluginStatusType.DELETED, the enabled flag is also flipped to false. This has "requires new" semantics, so the results are committed immediately upon return.

Specified by:
setServerPluginStatus in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginIds - the plugins to be enabled
Throws:
Exception

registerServerPlugin

public org.rhq.core.domain.plugin.ServerPlugin registerServerPlugin(org.rhq.core.domain.auth.Subject subject,
                                                                    org.rhq.core.domain.plugin.ServerPlugin plugin,
                                                                    File pluginFile)
                                                             throws Exception
Description copied from interface: ServerPluginsLocal
Registers the given plugin to the database. This ensures the database is up-to-date with the new plugin details. If the master plugin container is up, it will attempt to restart the plugin so the new changes are picked up.

Specified by:
registerServerPlugin in interface ServerPluginsLocal
Parameters:
subject - the user that needs to have permissions to add a plugin to the system
plugin - the plugin definition
pluginFile - the actual plugin file itself
Returns:
the plugin after being persisted
Throws:
Exception - if failed to fully register the plugin

purgeServerPlugin

public void purgeServerPlugin(org.rhq.core.domain.auth.Subject subject,
                              org.rhq.core.domain.plugin.PluginKey pluginKey)
Description copied from interface: ServerPluginsLocal
Purges the server plugin from the database. This ensures that, after this method returns, the given plugin will be unknown. The plugin can be installed again later. This has "requires new" semantics, so the results are committed immediately upon return. This is really a supporting method for #reRegisterServerPlugin(Subject, ServerPlugin, File) - you'll probably want to use that instead. Do not blindly purge server plugins using this method unless you know what you are doing.

Specified by:
purgeServerPlugin in interface ServerPluginsLocal
Parameters:
subject - user making the request
pluginKey - the key of the server plugin to delete

updateServerPluginExceptContent

public org.rhq.core.domain.plugin.ServerPlugin updateServerPluginExceptContent(org.rhq.core.domain.auth.Subject subject,
                                                                               org.rhq.core.domain.plugin.ServerPlugin plugin)
                                                                        throws Exception
Description copied from interface: ServerPluginsLocal
Given a plugin that already exists, this will update that plugin's data in the database, except for the content, which is left as-is. If the plugin did not yet exist, an exception is thrown. You can use this to update the plugin's scheduled jobs configuration and plugin configuration.

Specified by:
updateServerPluginExceptContent in interface ServerPluginsLocal
Parameters:
subject - user making the request
plugin - existing plugin with updated data
Returns:
the updated plugin
Throws:
Exception - if the plugin did not already exist or an error occurred that caused the update to fail

getServerPluginStatus

public org.rhq.core.domain.plugin.PluginStatusType getServerPluginStatus(org.rhq.core.domain.plugin.PluginKey pluginKey)
Description copied from interface: ServerPluginsLocal
Given the key of a server plugin, this will return the status of that plugin. Use this to determine if a plugin has been deleted or not.

Specified by:
getServerPluginStatus in interface ServerPluginsLocal
Parameters:
pluginKey - the key of the plugin whose status is to be returned.
Returns:
the status of the plugin, to indicate if the plugin has been deleted or is installed. null indicates an unknown plugin.

getInstalledServerPluginsGroupedByType

public Map<ServerPluginType,List<org.rhq.core.domain.plugin.PluginKey>> getInstalledServerPluginsGroupedByType()
Description copied from interface: ServerPluginsLocal
This will return a map containing all installed plugins that are both enabled and disabled.

Specified by:
getInstalledServerPluginsGroupedByType in interface ServerPluginsLocal
Returns:
keys of all enabled and disabled plugins, keyed on their types

getServerPluginConfigurationDefinition

public org.rhq.core.domain.configuration.definition.ConfigurationDefinition getServerPluginConfigurationDefinition(org.rhq.core.domain.plugin.PluginKey pluginKey)
                                                                                                            throws Exception
Description copied from interface: ServerPluginsLocal
Returns the definition for the given plugin's global plugin configuration.

Specified by:
getServerPluginConfigurationDefinition in interface ServerPluginsLocal
Returns:
the plugin configuration definition
Throws:
Exception

getServerPluginScheduledJobsDefinition

public org.rhq.core.domain.configuration.definition.ConfigurationDefinition getServerPluginScheduledJobsDefinition(org.rhq.core.domain.plugin.PluginKey pluginKey)
                                                                                                            throws Exception
Description copied from interface: ServerPluginsLocal
Returns the definition for the given plugin's scheduled jobs configuration.

Specified by:
getServerPluginScheduledJobsDefinition in interface ServerPluginsLocal
Returns:
the scheduled jobs definition
Throws:
Exception

getServerPluginControlDefinitions

public List<ControlDefinition> getServerPluginControlDefinitions(org.rhq.core.domain.plugin.PluginKey pluginKey)
                                                          throws Exception
Description copied from interface: ServerPluginsLocal
Returns the metadata for all control operations for the given plugin. If there are no control operations, an empty list is returned.

Specified by:
getServerPluginControlDefinitions in interface ServerPluginsLocal
Returns:
list of control definitions that are defined for the given plugin
Throws:
Exception - if failed to determine a plugin's control definitions

invokeServerPluginControl

public ControlResults invokeServerPluginControl(org.rhq.core.domain.auth.Subject subject,
                                                org.rhq.core.domain.plugin.PluginKey pluginKey,
                                                String controlName,
                                                org.rhq.core.domain.configuration.Configuration params)
                                         throws Exception
Description copied from interface: ServerPluginsLocal
Invokes a control operation on a given plugin and returns the results. This method blocks until the plugin component completes the invocation.

Specified by:
invokeServerPluginControl in interface ServerPluginsLocal
Parameters:
subject - user making the request, must have the proper permissions
pluginKey - identifies the plugin whose control operation is to be invoked
controlName - identifies the name of the control operation to invoke
params - parameters to pass to the control operation; may be null
Returns:
the results of the invocation
Throws:
Exception


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.