Hyperic HQ Plugin API v. 4.4.0.2

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 java.lang.Object


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

See Also:
Constant Field Values

config

protected ConfigResponse config

FILE_DELIM

public static final java.lang.String FILE_DELIM
See Also:
Constant Field Values

FILE_DELIM_ESC

public static final java.lang.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 java.util.List toFileList(java.lang.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 java.lang.String[] getAbsoluteFiles(java.lang.String value,
                                              java.lang.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 java.lang.String getPlatformName()
Method to assist with naming of resources.

Returns:
The hostname of the current platform.

getName

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

Returns:
Name of the plugin instance.

setName

public void setName(java.lang.String name)

getTypeInfo

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

setTypeInfo

public void setTypeInfo(TypeInfo type)

getConfigSchema

public ConfigSchema getConfigSchema(TypeInfo info,
                                    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 ConfigSchema getCustomPropertiesSchema(java.lang.String name)

getCustomPropertiesSchema

public ConfigSchema getCustomPropertiesSchema(TypeInfo info)

getCustomPropertiesSchema

public ConfigSchema getCustomPropertiesSchema()

getManagerProperty

public java.lang.String getManagerProperty(java.lang.String key)

getPluginProperty

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


getProperties

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


getTypeProperties

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


getTypeProperty

public java.lang.String getTypeProperty(java.lang.String type,
                                        java.lang.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 java.lang.String getTypeProperty(TypeInfo type,
                                        java.lang.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 java.lang.String getTypeProperty(java.lang.String name)
Shortcut, same as: getTypeProperty(getTypeInfo().getName(), name);


getTypeNameProperty

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


getTypeNameProperty

public java.lang.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 ConfigResponse getConfig()

getConfig

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


configure

public void configure(ConfigResponse config)
               throws PluginException
Throws:
PluginException

getDefaultInstallPath

public java.lang.String getDefaultInstallPath()

getScriptExtension

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

getScriptExtension

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

getScriptExtension

public static java.lang.String getScriptExtension(boolean isWin32)

getLogName

protected java.lang.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(java.lang.String installpath)
Any jars that exist relative to the given installpath will be added to the plugin's classpath.


openResource

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

Throws:
java.io.IOException

getPluginClassName

public java.lang.String getPluginClassName(java.lang.String pluginType,
                                           java.lang.String resourceType)

Hyperic HQ Plugin API v. 4.4.0.2

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