Hyperic HQ Plugin API v. 5.8.0

org.hyperic.hq.product
Class GenericPlugin

java.lang.Object
  extended by org.hyperic.hq.product.GenericPlugin
Direct Known Subclasses:
ConfigTrackPlugin, ControlPlugin, LiveDataPlugin, LogTrackPlugin, MeasurementPlugin, PlatformDetector, ProductPlugin, RtPlugin, ServerDetector

public abstract class GenericPlugin
extends Object


Field Summary
protected  org.hyperic.util.config.ConfigResponse config
           
static String FILE_DELIM
           
static String FILE_DELIM_ESC
           
static String PROP_NAME
          Key used to store value of XML resource name attribute.
 
Constructor Summary
GenericPlugin()
           
 
Method Summary
protected  void adjustClassPath(String installpath)
          Any jars that exist relative to the given installpath will be added to the plugin's classpath.
 void configure(org.hyperic.util.config.ConfigResponse config)
           
protected  String[] getAbsoluteFiles(String value, String dir)
          Expand a String to array of absolute file names.
 org.hyperic.util.config.ConfigResponse getConfig()
           
 String getConfig(String key)
          Shortcut, same as getConfig().getValue(key)
 org.hyperic.util.config.ConfigSchema getConfigSchema(TypeInfo info, org.hyperic.util.config.ConfigResponse config)
          The ConfigSchema used to render config options for this resource in the UI and client shell.
 org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema()
           
 org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema(String name)
           
 org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema(TypeInfo info)
           
 String getDefaultInstallPath()
           
protected  org.apache.commons.logging.Log getLog()
          Wrapper for LogFactory.getLog which uses the name returned by getLogName().
protected  String getLogName()
          Default name for getLog() method.
 String getManagerProperty(String key)
           
 String getName()
          Unique name used by PluginManager.getPlugin
static String getPlatformName()
          Method to assist with naming of resources.
 String getPluginClassName(String pluginType, String resourceType)
           
 PluginData getPluginData()
           
 String getPluginProperty(String name)
          Get a value defined by a <property> tag in the plugin's hq-plugin.xml
 String getPluginVersion()
           
 ProductPlugin getProductPlugin()
          Get the ProductPlugin that defined the TypeInfo for this plugin instance.
 Properties getProperties()
          Get all properties defined using <property> at the top-level in the plugin's hq-plugin.xml
static String getScriptExtension()
           
static String getScriptExtension(boolean isWin32)
           
 String getScriptExtension(TypeInfo info)
           
 TypeInfo getTypeInfo()
           
 String getTypeNameProperty()
          Shortcut, same as: getTypeNameProperty(getTypeInfo().getName());
 String getTypeNameProperty(String type)
          Shortcut, same as: getTypeProperty(type, PROP_NAME);
 Properties getTypeProperties()
          Get all properties defined using <property> within the resource tag (platform|server|service) for this type.
 String getTypeProperty(String name)
          Shortcut, same as: getTypeProperty(getTypeInfo().getName(), name);
 String getTypeProperty(String type, String name)
          Get a value defined by a <property> tag in the plugin's hq-plugin.xml, within a <server> or <service> tag for this plugin's type.
 String getTypeProperty(TypeInfo type, String name)
          If name property is not found for the given type, try using the type's parent.
 void init(PluginManager manager)
          Called when the plugin is loaded on the server and on the agent side.
 boolean isNetStatEnabled()
           
static boolean isWin32()
           
 InputStream openResource(String name)
          Wrapper around ClassLoader.getResource/getResourceAsStream to open a resource from this plugin's .jar file.
 void setData(PluginData data)
           
 void setName(String name)
           
 void setPluginVersion(String version)
           
 void setTypeInfo(TypeInfo type)
           
 void shutdown()
          Called when the server or agent is shutdown.
protected  List toFileList(String value)
          Expand a String to List of file names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_NAME

public static final String PROP_NAME
Key used to store value of XML resource name attribute.

See Also:
Constant Field Values

config

protected org.hyperic.util.config.ConfigResponse config

FILE_DELIM

public static final String FILE_DELIM
See Also:
Constant Field Values

FILE_DELIM_ESC

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

GenericPlugin

public GenericPlugin()
Method Detail

setData

public void setData(PluginData data)

getPluginData

public PluginData getPluginData()

toFileList

protected List toFileList(String value)
Expand a String to List of file names.

Parameters:
value - Comma delimited list of files
Returns:
List of String file names, which are trimmed and have unescaped any embedded commas ("%2C" -> ",")

getAbsoluteFiles

protected String[] getAbsoluteFiles(String value,
                                    String dir)
Expand a String to array of absolute file names.

Parameters:
value - Expanded using toFileList()
dir - Parent directory used to resolve relative file names.
Returns:
Array of absolute file names.

isNetStatEnabled

public boolean isNetStatEnabled()

isWin32

public static boolean isWin32()
Returns:
true if the current platform is in the Windows family.

getPlatformName

public static String getPlatformName()
Method to assist with naming of resources.

Returns:
The hostname of the current platform.

getName

public String getName()
Unique name used by PluginManager.getPlugin

Returns:
Name of the plugin instance.

setName

public void setName(String name)

getPluginVersion

public String getPluginVersion()

setPluginVersion

public void setPluginVersion(String version)

getTypeInfo

public TypeInfo getTypeInfo()
Returns:
The TypeInfo of this plugin from ProductPlugin.getTypes

setTypeInfo

public void setTypeInfo(TypeInfo type)

getConfigSchema

public org.hyperic.util.config.ConfigSchema getConfigSchema(TypeInfo info,
                                                            org.hyperic.util.config.ConfigResponse config)
The ConfigSchema used to render config options for this resource in the UI and client shell.

Parameters:
info - The TypeInfo of this plugin from ProductPlugin.getTypes
config - ConfigReponse of the parent resource (if any).
Returns:
ConfigSchema for this resource.

getCustomPropertiesSchema

public org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema(String name)

getCustomPropertiesSchema

public org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema(TypeInfo info)

getCustomPropertiesSchema

public org.hyperic.util.config.ConfigSchema getCustomPropertiesSchema()

getManagerProperty

public String getManagerProperty(String key)

getPluginProperty

public String getPluginProperty(String name)
Get a value defined by a <property> tag in the plugin's hq-plugin.xml


getProperties

public Properties getProperties()
Get all properties defined using <property> at the top-level in the plugin's hq-plugin.xml


getTypeProperties

public Properties getTypeProperties()
Get all properties defined using <property> within the resource tag (platform|server|service) for this type.


getTypeProperty

public String getTypeProperty(String type,
                              String name)
Get a value defined by a <property> tag in the plugin's hq-plugin.xml, within a <server> or <service> tag for this plugin's type.

Same as: getProperty(type + "." + name);


getTypeProperty

public String getTypeProperty(TypeInfo type,
                              String name)
If name property is not found for the given type, try using the type's parent. If not found using parent's type, try using top-level properties from hq-plugin.xml.


getTypeProperty

public String getTypeProperty(String name)
Shortcut, same as: getTypeProperty(getTypeInfo().getName(), name);


getTypeNameProperty

public String getTypeNameProperty(String type)
Shortcut, same as: getTypeProperty(type, PROP_NAME);


getTypeNameProperty

public String getTypeNameProperty()
Shortcut, same as: getTypeNameProperty(getTypeInfo().getName());


init

public void init(PluginManager manager)
          throws PluginException
Called when the plugin is loaded on the server and on the agent side.

Parameters:
manager - The plugin manager for this plugin type.
Throws:
PluginException

shutdown

public void shutdown()
              throws PluginException
Called when the server or agent is shutdown. Use this method to cleanup any resources that were created during the init() method.

Throws:
PluginException

getConfig

public org.hyperic.util.config.ConfigResponse getConfig()

getConfig

public String getConfig(String key)
Shortcut, same as getConfig().getValue(key)


configure

public void configure(org.hyperic.util.config.ConfigResponse config)
               throws PluginException
Throws:
PluginException

getDefaultInstallPath

public String getDefaultInstallPath()

getScriptExtension

public static String getScriptExtension()
Returns:
".bat" if isWin32() else ".sh"

getScriptExtension

public String getScriptExtension(TypeInfo info)
Returns:
".bat" if info.isWin32Platform() else ".sh"

getScriptExtension

public static String getScriptExtension(boolean isWin32)

getLogName

protected String getLogName()
Default name for getLog() method.


getLog

protected org.apache.commons.logging.Log getLog()
Wrapper for LogFactory.getLog which uses the name returned by getLogName().


getProductPlugin

public ProductPlugin getProductPlugin()
Get the ProductPlugin that defined the TypeInfo for this plugin instance.


adjustClassPath

protected void adjustClassPath(String installpath)
Any jars that exist relative to the given installpath will be added to the plugin's classpath.


openResource

public InputStream openResource(String name)
                         throws IOException
Wrapper around ClassLoader.getResource/getResourceAsStream to open a resource from this plugin's .jar file.

Throws:
IOException

getPluginClassName

public String getPluginClassName(String pluginType,
                                 String resourceType)

Hyperic HQ Plugin API v. 5.8.0

Copyright © 2004-2010 Hyperic, Inc. support@hyperic.net, All Rights Reserved.