org.rhq.enterprise.server.resource.metadata
Class PluginManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.resource.metadata.PluginManagerBean
All Implemented Interfaces:
PluginManagerLocal

public class PluginManagerBean
extends Object
implements PluginManagerLocal


Constructor Summary
PluginManagerBean()
           
 
Method Summary
 void deletePlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          This method puts the plugin into a deleted state and removes the plugin JAR file from the file system.
 void disablePlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
           
 void enablePlugins(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
           
 List<org.rhq.core.domain.plugin.Plugin> findAllDeletedPlugins()
           
 List<org.rhq.core.domain.plugin.Plugin> findPluginsMarkedForPurge()
           
 List<org.rhq.core.domain.plugin.Plugin> getAllPluginsById(List<Integer> pluginIds)
          Returns a list of plugins with the specified ids.
 List<org.rhq.core.domain.plugin.Plugin> getInstalledPlugins()
          Returns the list of all plugins deployed in the server.
 org.rhq.core.domain.plugin.Plugin getPlugin(String name)
          Returns the information on the given plugin as found in the database.
 File getPluginDropboxDirectory()
          Returns the directory where plugins can be dropped for inclusion into the system.
 List<org.rhq.core.domain.plugin.Plugin> getPlugins()
           
 List<org.rhq.core.domain.plugin.Plugin> getPluginsByResourceTypeAndCategory(String resourceTypeName, org.rhq.core.domain.resource.ResourceCategory resourceCategory)
           
 List<PluginStats> getPluginStats(List<Integer> pluginIds)
           
 boolean installPluginJar(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.Plugin newPlugin, PluginDescriptor pluginDescriptor, File pluginFile)
          Exists only for transactional boundary reasons.
 boolean isReadyForPurge(org.rhq.core.domain.plugin.Plugin plugin)
           
 void markPluginsForPurge(org.rhq.core.domain.auth.Subject subject, List<Integer> pluginIds)
          Schedules a plugin to be purged.
 void purgePlugins(List<org.rhq.core.domain.plugin.Plugin> plugins)
          Permanently deletes the plugins from the database.
 void registerPlugin(org.rhq.core.domain.auth.Subject subject, org.rhq.core.domain.plugin.Plugin plugin, PluginDescriptor pluginDescriptor, File pluginFile, boolean forceUpdate)
          For server-side registration of plugin archives.
 boolean registerPluginTypes(org.rhq.core.domain.plugin.Plugin newPlugin, PluginDescriptor pluginDescriptor, boolean newOrUpdated, boolean forceUpdate)
          Exists only to for transactional boundary reasons.
 void setPluginEnabledFlag(org.rhq.core.domain.auth.Subject subject, int pluginId, boolean enabled)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginManagerBean

public PluginManagerBean()
Method Detail

getPlugin

public org.rhq.core.domain.plugin.Plugin getPlugin(String name)
Returns the information on the given plugin as found in the database.

Specified by:
getPlugin in interface PluginManagerLocal
Parameters:
name - the name of a plugin
Returns:
the plugin with the specified name
Throws:
javax.persistence.NoResultException - when no plugin with that name exists

markPluginsForPurge

public void markPluginsForPurge(org.rhq.core.domain.auth.Subject subject,
                                List<Integer> pluginIds)
                         throws Exception
Description copied from interface: PluginManagerLocal
Schedules a plugin to be purged. Purging a plugin permanently deletes it from the database. Purging is done asynchronously and will not happen until all resource types defined by the plugin have first been purged. Plugins must first be deleted before they can be purged. A plugin is considered a candidate for being purged if its status is set to DELETED and its ctime is set to Plugin.PURGED. This method does not flip the status of the plugins to DELETED since it assumes that has already been done. It only sets ctime to PURGED.

Specified by:
markPluginsForPurge in interface PluginManagerLocal
Parameters:
subject - The user purging the plugin
pluginIds - The ids of the plugins to be purged
Throws:
Exception - if an error occurs
See Also:
PurgePluginsJob

isReadyForPurge

public boolean isReadyForPurge(org.rhq.core.domain.plugin.Plugin plugin)
Specified by:
isReadyForPurge in interface PluginManagerLocal
Parameters:
plugin - The plugin to check
Returns:
true if the plugin can be purged, false otherwise. A plugin can only be purged when all resource types defined by the plugin have already been purged.

purgePlugins

public void purgePlugins(List<org.rhq.core.domain.plugin.Plugin> plugins)
Description copied from interface: PluginManagerLocal
Permanently deletes the plugins from the database. This method assumes that the plugins are already in the deleted state. This method is not intended for general use. It is called from PurgePluginsJob.

Specified by:
purgePlugins in interface PluginManagerLocal
Parameters:
plugins - The plugins to remove from the database.

getPlugins

public List<org.rhq.core.domain.plugin.Plugin> getPlugins()
Specified by:
getPlugins in interface PluginManagerLocal
Returns:
A list of all plugins deployed in the server, including deleted plugins

getInstalledPlugins

public List<org.rhq.core.domain.plugin.Plugin> getInstalledPlugins()
Description copied from interface: PluginManagerLocal
Returns the list of all plugins deployed in the server.

Specified by:
getInstalledPlugins in interface PluginManagerLocal
Returns:
list of plugins deployed

findAllDeletedPlugins

public List<org.rhq.core.domain.plugin.Plugin> findAllDeletedPlugins()
Specified by:
findAllDeletedPlugins in interface PluginManagerLocal
Returns:
All plugins that have been marked deleted.

findPluginsMarkedForPurge

public List<org.rhq.core.domain.plugin.Plugin> findPluginsMarkedForPurge()
Specified by:
findPluginsMarkedForPurge in interface PluginManagerLocal
Returns:
All plugins that are scheduled to be purged.

getAllPluginsById

public List<org.rhq.core.domain.plugin.Plugin> getAllPluginsById(List<Integer> pluginIds)
Description copied from interface: PluginManagerLocal
Returns a list of plugins with the specified ids. Both installed and deleted plugins will be included in the results.

Specified by:
getAllPluginsById in interface PluginManagerLocal
Parameters:
pluginIds - The ids of the plugins to fetch
Returns:
A list of plugins with the specified ids

getPluginsByResourceTypeAndCategory

public List<org.rhq.core.domain.plugin.Plugin> getPluginsByResourceTypeAndCategory(String resourceTypeName,
                                                                                   org.rhq.core.domain.resource.ResourceCategory resourceCategory)
Specified by:
getPluginsByResourceTypeAndCategory in interface PluginManagerLocal

enablePlugins

public void enablePlugins(org.rhq.core.domain.auth.Subject subject,
                          List<Integer> pluginIds)
                   throws Exception
Specified by:
enablePlugins in interface PluginManagerLocal
Throws:
Exception

disablePlugins

public void disablePlugins(org.rhq.core.domain.auth.Subject subject,
                           List<Integer> pluginIds)
                    throws Exception
Specified by:
disablePlugins in interface PluginManagerLocal
Throws:
Exception

deletePlugins

public void deletePlugins(org.rhq.core.domain.auth.Subject subject,
                          List<Integer> pluginIds)
                   throws Exception
Description copied from interface: PluginManagerLocal
This method puts the plugin into a deleted state and removes the plugin JAR file from the file system. It does not remove the plugin from the database. This method does not purge the plugin from the database in order to support HA deployments. In a HA deployment, if server A handles the request to delete the plugin and if it purges the plugin from the database, server B might see the plugin on the file system and not in the database. Server B would then proceed to try and re-install the plugin, not knowing it was deleted.

Specified by:
deletePlugins in interface PluginManagerLocal
Parameters:
subject - The user performing the deletion
pluginIds - The ids of the plugins to be deleted
Throws:
Exception - if an error occurs

getPluginStats

public List<PluginStats> getPluginStats(List<Integer> pluginIds)
Specified by:
getPluginStats in interface PluginManagerLocal

setPluginEnabledFlag

public void setPluginEnabledFlag(org.rhq.core.domain.auth.Subject subject,
                                 int pluginId,
                                 boolean enabled)
                          throws Exception
Specified by:
setPluginEnabledFlag in interface PluginManagerLocal
Throws:
Exception

getPluginDropboxDirectory

public File getPluginDropboxDirectory()
Description copied from interface: PluginManagerLocal
Returns the directory where plugins can be dropped for inclusion into the system.

Specified by:
getPluginDropboxDirectory in interface PluginManagerLocal
Returns:
directory where the plugin dropbox is located

registerPlugin

public void registerPlugin(org.rhq.core.domain.auth.Subject subject,
                           org.rhq.core.domain.plugin.Plugin plugin,
                           PluginDescriptor pluginDescriptor,
                           File pluginFile,
                           boolean forceUpdate)
                    throws Exception
Description copied from interface: PluginManagerLocal
For server-side registration of plugin archives. At server startup or as new plugins are runtime deployed the jar will have its descriptor read and parsed and the metadata for the plugin will be updated in the db. If you provide a non-null pluginFile, and the plugin is deemed to be new or updated, the content of the file will be streamed to the database. Note that if you provide a non-null file, you must ensure its MD5 matches that of the file (i.e. this method will not attempt to recompute the file's MD5, it will assume the caller has already done that and provided the proper MD5 in plugin).

NOTE ** This call will register the plugin in a new transaction.

Specified by:
registerPlugin in interface PluginManagerLocal
plugin - The plugin object being deployed
pluginDescriptor - The plugin descriptor file
pluginFile - the actual plugin file whose content will be stored in the database (will be ignored if null)
forceUpdate - if true, the plugin's types will be updated, even if the plugin hasn't changed since the last time it was registered
Throws:
Exception

installPluginJar

public boolean installPluginJar(org.rhq.core.domain.auth.Subject subject,
                                org.rhq.core.domain.plugin.Plugin newPlugin,
                                PluginDescriptor pluginDescriptor,
                                File pluginFile)
                         throws Exception
Description copied from interface: PluginManagerLocal
Exists only for transactional boundary reasons. Not for general consumption.

Specified by:
installPluginJar in interface PluginManagerLocal
Throws:
Exception

registerPluginTypes

public boolean registerPluginTypes(org.rhq.core.domain.plugin.Plugin newPlugin,
                                   PluginDescriptor pluginDescriptor,
                                   boolean newOrUpdated,
                                   boolean forceUpdate)
                            throws Exception
Description copied from interface: PluginManagerLocal
Exists only to for transactional boundary reasons. Not for general consumption.

Specified by:
registerPluginTypes in interface PluginManagerLocal
Throws:
Exception


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