org.rhq.enterprise.agent
Class PluginUpdate

java.lang.Object
  extended by org.rhq.enterprise.agent.PluginUpdate

public class PluginUpdate
extends Object

This object's job is to update any and all plugin jars that need to be updated. If this object determines that a more recent plugin jar exists, this will retrieve it and overwrite the current plugin jar with that latest plugin jar. This object can also be used if you just want to get information on the current set of plugins - see getCurrentPluginFiles().

Author:
John Mazzitelli, Ian Springer

Constructor Summary
PluginUpdate(CoreServerService core_server_service, PluginContainerConfiguration config)
          Constructor for PluginUpdate.
PluginUpdate(PluginContainerConfiguration config)
          Constructor for PluginUpdate that can only be used to get info on current plugins; calling updatePlugins() on the object will fail.
 
Method Summary
 List<File> getCurrentPluginFiles()
          Returns the list of all the plugin archive files.
 PluginContainerConfiguration getPluginContainerConfiguration()
           
static boolean isCurrentlyUpdating(PluginContainerConfiguration config)
          All PluginUpdate objects know if they are currently updating plugins given a specific config.
 List<Plugin> updatePlugins()
          This will compare the current set of plugins that exist locally with the set of latest plugins that are available from the core server service.
static boolean waitForUpdateToComplete(PluginContainerConfiguration config, long timeout)
          Blocks the calling thread for a maximum of the given amount of milliseconds timeout waiting for a plugin update to completely.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginUpdate

public PluginUpdate(CoreServerService core_server_service,
                    PluginContainerConfiguration config)
Constructor for PluginUpdate. You can pass in a null core_server_service if you only plan to use this object to obtain information on the currently installed plugins and not actually update them.

Parameters:
core_server_service - the server that is to be used to retrieve the latest plugins
config - the plugin container configuration used to find what current plugins exist locally

PluginUpdate

public PluginUpdate(PluginContainerConfiguration config)
Constructor for PluginUpdate that can only be used to get info on current plugins; calling updatePlugins() on the object will fail. you can only call getCurrentPluginFiles().

Parameters:
config - the plugin container configuration used to find what current plugins exist locally
Method Detail

isCurrentlyUpdating

public static boolean isCurrentlyUpdating(PluginContainerConfiguration config)
All PluginUpdate objects know if they are currently updating plugins given a specific config. Call this static method to ask if any plugin update object is currently updating plugins with the given configuration

Parameters:
config - used to determine where the plugins are being updated
Returns:
true if a plugin updater object is currently updating plugin; false if all plugins are up-to-date and nothing is being updated anymore.

waitForUpdateToComplete

public static boolean waitForUpdateToComplete(PluginContainerConfiguration config,
                                              long timeout)
                                       throws InterruptedException
Blocks the calling thread for a maximum of the given amount of milliseconds timeout waiting for a plugin update to completely. This will return sooner if the update finishes early or if there is no update currently happening.

Parameters:
config - used to determine where the plugins are being updated
timeout - max milliseconds to wait
Returns:
true if a plugin updater object is currently updating plugin and this method timed out; false if all plugins are up-to-date and nothing is being updated anymore.
Throws:
InterruptedException - if thread was interrupted while waiting

getPluginContainerConfiguration

public PluginContainerConfiguration getPluginContainerConfiguration()

updatePlugins

public List<Plugin> updatePlugins()
                           throws Exception
This will compare the current set of plugins that exist locally with the set of latest plugins that are available from the core server service. If we need to upgrade to one or more latest plugins, this method will download them and overwrite the old plugin jars they replace.

You can only call this method if a valid, non-null CoreServerService implementation was given to this object's constructor.

Returns:
a list of plugins that have been updated (empty list if we already had all the latest plugins)
Throws:
Exception - if failed to determine our current set of plugins due to the inability to calculate their MD5 hashcodes or failed to download a plugin

getCurrentPluginFiles

public List<File> getCurrentPluginFiles()
Returns the list of all the plugin archive files. These are the current set of plugins installed locally.

Returns:
the current list of locally installed plugin archive files


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