org.rhq.core.clientapi.descriptor
Class AgentPluginDescriptorUtil

java.lang.Object
  extended by org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil

public abstract class AgentPluginDescriptorUtil
extends Object

Utilities for agent plugin descriptors.


Constructor Summary
AgentPluginDescriptorUtil()
           
 
Method Summary
static void addPluginToDependencyGraph(PluginDependencyGraph dependencyGraph, PluginDescriptor descriptor)
          Given an existing dependency graph and a plugin descriptor, this will add that plugin and its dependencies to the dependency graph.
static Plugin determineObsoletePlugin(Plugin plugin1, Plugin plugin2)
          Determines which of the two plugins is obsolete - in other words, this determines which plugin is older.
static ComparableVersion getPluginVersion(File pluginFile, PluginDescriptor descriptor)
          Returns the version for the plugin represented by the given descriptor/file.
static PluginDescriptor loadPluginDescriptorFromUrl(URL pluginJarFileUrl)
          Loads a plugin descriptor from the given plugin jar and returns it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentPluginDescriptorUtil

public AgentPluginDescriptorUtil()
Method Detail

determineObsoletePlugin

public static Plugin determineObsoletePlugin(Plugin plugin1,
                                             Plugin plugin2)
Determines which of the two plugins is obsolete - in other words, this determines which plugin is older. Each plugin must have the same logical name, but one of which will be determined to be obsolete and should not be deployed. If they have the same MD5, they are identical, so null will be returned. Otherwise, the versions are compared and the one with the oldest version is obsolete. If they have the same versions, the one with the oldest timestamp is obsolete. If they have the same timestamp too, we have no other way to determine obsolescence so plugin1 will be picked arbitrarily and a message will be logged when this occurs.

Parameters:
plugin1 -
plugin2 -
Returns:
a reference to the obsolete plugin (plugin1 or plugin2 reference will be returned) null is returned if they are the same (i.e. they have the same MD5)
Throws:
IllegalArgumentException - if the two plugins have different logical names

getPluginVersion

public static ComparableVersion getPluginVersion(File pluginFile,
                                                 PluginDescriptor descriptor)
                                          throws Exception
Returns the version for the plugin represented by the given descriptor/file. If the descriptor defines a version, that is considered the version of the plugin. However, if the plugin descriptor does not define a version, the plugin jar's manifest is searched for an implementation version string and if one is found that is the version of the plugin. If the manifest entry is also not found, the plugin does not have a version associated with it, which causes this method to throw an exception.

Parameters:
pluginFile - the plugin jar
descriptor - the plugin descriptor as found in the plugin jar (if null, the plugin file will be read and the descriptor parsed from it)
Returns:
the version of the plugin
Throws:
Exception - if the plugin is invalid, there is no version for the plugin or the version string is invalid

addPluginToDependencyGraph

public static void addPluginToDependencyGraph(PluginDependencyGraph dependencyGraph,
                                              PluginDescriptor descriptor)
Given an existing dependency graph and a plugin descriptor, this will add that plugin and its dependencies to the dependency graph.

Parameters:
dependencyGraph -
descriptor -

loadPluginDescriptorFromUrl

public static PluginDescriptor loadPluginDescriptorFromUrl(URL pluginJarFileUrl)
                                                    throws PluginContainerException
Loads a plugin descriptor from the given plugin jar and returns it. This is a static method to provide a convienence method for others to be able to use.

Parameters:
pluginJarFileUrl - URL to a plugin jar file
Returns:
the plugin descriptor found in the given plugin jar file
Throws:
PluginContainerException - if failed to find or parse a descriptor file in the plugin jar


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