org.rhq.plugins.byteman
Class BytemanAgentDiscoveryComponent

java.lang.Object
  extended by org.rhq.plugins.byteman.BytemanAgentDiscoveryComponent
All Implemented Interfaces:
ClassLoaderFacet<BytemanAgentComponent>, ManualAddFacet<BytemanAgentComponent>, ResourceDiscoveryComponent<BytemanAgentComponent>

public class BytemanAgentDiscoveryComponent
extends Object
implements ResourceDiscoveryComponent<BytemanAgentComponent>, ManualAddFacet<BytemanAgentComponent>, ClassLoaderFacet<BytemanAgentComponent>

Discovers a Byteman agent.

Author:
John Mazzitelli

Field Summary
static String DEFAULT_BYTEMAN_ADDRESS
           
static String DEFAULT_BYTEMAN_PORT
           
static String PLUGIN_CONFIG_PROP_ADDRESS
           
static String PLUGIN_CONFIG_PROP_CLIENT_JAR
           
static String PLUGIN_CONFIG_PROP_PORT
           
 
Constructor Summary
BytemanAgentDiscoveryComponent()
           
 
Method Summary
 DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration, ResourceDiscoveryContext<BytemanAgentComponent> context)
           
 Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BytemanAgentComponent> context)
           
 List<URL> getAdditionalClasspathUrls(ResourceDiscoveryContext<BytemanAgentComponent> context, DiscoveredResourceDetails details)
           
static String getJarAttribute(String jarPath, String attributeName, String defaultValue)
          Static utility method that can extract a main attribute value from a given jar file's manifest.
protected  String getVersion(String address, String port, String jarPath)
          Tries to determine the version of the remote byteman agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BYTEMAN_ADDRESS

public static final String DEFAULT_BYTEMAN_ADDRESS
See Also:
Constant Field Values

DEFAULT_BYTEMAN_PORT

public static final String DEFAULT_BYTEMAN_PORT
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_ADDRESS

public static final String PLUGIN_CONFIG_PROP_ADDRESS
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_PORT

public static final String PLUGIN_CONFIG_PROP_PORT
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_CLIENT_JAR

public static final String PLUGIN_CONFIG_PROP_CLIENT_JAR
See Also:
Constant Field Values
Constructor Detail

BytemanAgentDiscoveryComponent

public BytemanAgentDiscoveryComponent()
Method Detail

discoverResources

public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BytemanAgentComponent> context)
Specified by:
discoverResources in interface ResourceDiscoveryComponent<BytemanAgentComponent>

discoverResource

public DiscoveredResourceDetails discoverResource(Configuration pluginConfiguration,
                                                  ResourceDiscoveryContext<BytemanAgentComponent> context)
                                           throws InvalidPluginConfigurationException
Specified by:
discoverResource in interface ManualAddFacet<BytemanAgentComponent>
Throws:
InvalidPluginConfigurationException

getAdditionalClasspathUrls

public List<URL> getAdditionalClasspathUrls(ResourceDiscoveryContext<BytemanAgentComponent> context,
                                            DiscoveredResourceDetails details)
                                     throws Exception
Specified by:
getAdditionalClasspathUrls in interface ClassLoaderFacet<BytemanAgentComponent>
Throws:
Exception

getVersion

protected String getVersion(String address,
                            String port,
                            String jarPath)
Tries to determine the version of the remote byteman agent. If, for some reason, the remote agent cannot be contacted, the manifest within the given jar will be used as the version as a "best guess". If all else fails, "0" will be returned as the version.

Parameters:
address - the address of the remote byteman agent listener
port - the port that the remote byteman agent is listening to
jarPath - the path to the byteman jar (which may be the client jar, or the core byteman jar)
Returns:
the version of the managed byteman agent; "0" if unknown

getJarAttribute

public static String getJarAttribute(String jarPath,
                                     String attributeName,
                                     String defaultValue)
Static utility method that can extract a main attribute value from a given jar file's manifest.

Parameters:
jarPath - location of the jar file
attributeName - name of the main attribute to retrieve
defaultValue - if the manifest doesn't have the attribute or the manifest itself doesn't exist, this is returned
Returns:
the value of the attribute


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