com.tivoli.twg.agent
Class TWGAgentExtension

java.lang.Object
  extended bycom.tivoli.twg.agent.TWGAgentExtension

public class TWGAgentExtension
extends java.lang.Object

Base class for agent extensions. Contains an agent extension's properties and (overridable) exit methods and provides static methods for agent extensions to interact with the agent and have "subextensions" of their own. Each agent extension must provide a properties file named "extname.exttype" where extname is the extension name and exttype is one of the supported extension types (e.g., "*.TWGSubagent" for base agent extensions). Optionally the extension may provide a subclass of this class, identified on property twg.extension.classname.


Field Summary
static java.lang.String EXT_CLASSNAME
          Optional property for extension's TWGAgentExtension subclass name
static java.lang.String EXT_NAME
          Optional property for extension's name resource (name ID in NLS resource)
static java.lang.String EXT_NLS_CLASS
          Optional property for extension's NLS resource (for strings)
static java.lang.String EXT_SERVICE_NODE
          Optional property (prefix) for extension's registered service node name(s)
static java.lang.String EXT_VENDOR
          Optional property for extension's vendor (vendor ID in NLS resource)
static java.lang.String EXT_VERSION
          Optional property for extension's version (resource ID in NLS resource)
protected  java.lang.String extName
           
protected  MultiLocaleBundle extNlsBundle
           
protected  java.util.Properties extProp
           
protected  java.lang.String extType
           
static java.lang.String KEY_CLASS
          Required keyword "classname:xx.xx.xx" for EXT_SERVICE_NODE property
static java.lang.String KEY_IFNOSERVER
          Optional property "twg.extension.ifnoserver:xxxx" (true/false) (default is false) - when true, service is loaded only if Director server not active
static java.lang.String KEY_NAME
          Required keyword "name:xxx" for EXT_SERVICE_NODE property
static java.lang.String KEY_PRESTART
          Optional keyword "prestart:xxxx" (true/false) for EXT_SERVICE_NODE property (default is false)
static java.lang.String KEY_PUBLISH_NAME
          Optional keyword "publishAs:xxx" for EXT_SERVICE_NODE property
 
Constructor Summary
TWGAgentExtension()
          Default constructor
 
Method Summary
 boolean deregisterService(java.lang.String name)
          Deregister service with agent
 java.lang.String DisplayName(java.util.Locale locale)
          Get extension's NLS name
 java.lang.String getName()
          Get extension name (properties filename)
 java.lang.String getNLSstring(java.util.Locale locale, java.lang.String property_name)
          Get extension's NLS string for given string ID
 java.lang.String getProperty(java.lang.String key)
          Get property value from extension's properties
 java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Get property value from extension's properties
 java.util.Properties getPropertySet()
          Get extension's properties
 MultiLocaleBundle getResourceBundle()
          Get extension's NLS resource bundle instance
 void initAgentExtension()
          Initialize agent extension Exit may be overridden by subclass to perform any initialization that is required before the agent becomes active.
 ServiceNode registerService(java.lang.String name, java.lang.String classname, boolean create)
          Register service with agent (and create if specified)
 ServiceNode registerService(java.lang.String name, java.lang.String publishName, java.lang.String classname, boolean create)
          Register service with agent (and create if specified)
 void runAgentExtension()
          Run agent extension Exit may be overridden by subclass to own the main thread for any long-running processing.
 void terminateAgentExtension()
          Terminate agent extension Exit may be overridden by subclass to perform any cleanup processing.
 java.lang.String VendorName(java.util.Locale locale)
          Get vendor name for extension
 java.lang.String VersionName(java.util.Locale locale)
          Get extension's version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXT_CLASSNAME

public static final java.lang.String EXT_CLASSNAME
Optional property for extension's TWGAgentExtension subclass name

See Also:
Constant Field Values

EXT_NLS_CLASS

public static final java.lang.String EXT_NLS_CLASS
Optional property for extension's NLS resource (for strings)

See Also:
Constant Field Values

EXT_NAME

public static final java.lang.String EXT_NAME
Optional property for extension's name resource (name ID in NLS resource)

See Also:
Constant Field Values

EXT_VENDOR

public static final java.lang.String EXT_VENDOR
Optional property for extension's vendor (vendor ID in NLS resource)

See Also:
Constant Field Values

EXT_VERSION

public static final java.lang.String EXT_VERSION
Optional property for extension's version (resource ID in NLS resource)

See Also:
Constant Field Values

EXT_SERVICE_NODE

public static final java.lang.String EXT_SERVICE_NODE
Optional property (prefix) for extension's registered service node name(s)

See Also:
Constant Field Values

KEY_NAME

public static final java.lang.String KEY_NAME
Required keyword "name:xxx" for EXT_SERVICE_NODE property

See Also:
Constant Field Values

KEY_CLASS

public static final java.lang.String KEY_CLASS
Required keyword "classname:xx.xx.xx" for EXT_SERVICE_NODE property

See Also:
Constant Field Values

KEY_PUBLISH_NAME

public static final java.lang.String KEY_PUBLISH_NAME
Optional keyword "publishAs:xxx" for EXT_SERVICE_NODE property

See Also:
Constant Field Values

KEY_PRESTART

public static final java.lang.String KEY_PRESTART
Optional keyword "prestart:xxxx" (true/false) for EXT_SERVICE_NODE property (default is false)

See Also:
Constant Field Values

KEY_IFNOSERVER

public static final java.lang.String KEY_IFNOSERVER
Optional property "twg.extension.ifnoserver:xxxx" (true/false) (default is false) - when true, service is loaded only if Director server not active

See Also:
Constant Field Values

extName

protected java.lang.String extName

extType

protected java.lang.String extType

extProp

protected java.util.Properties extProp

extNlsBundle

protected MultiLocaleBundle extNlsBundle
Constructor Detail

TWGAgentExtension

public TWGAgentExtension()
Default constructor

Method Detail

registerService

public ServiceNode registerService(java.lang.String name,
                                   java.lang.String classname,
                                   boolean create)
                            throws TWGAgentException
Register service with agent (and create if specified)

Parameters:
name - name of service node to register
classname - ServiceNode subclass name
create - true to create the service node immediately, otherwise service node is created on demand
Returns:
service node created (or null if create was not specified)
Throws:
TWGAgentException - if failed to register service

registerService

public ServiceNode registerService(java.lang.String name,
                                   java.lang.String publishName,
                                   java.lang.String classname,
                                   boolean create)
                            throws TWGAgentException
Register service with agent (and create if specified)

Parameters:
name - name of service node to register
publishName - name to publish service as
classname - ServiceNode subclass name
create - true to create the service node immediately, otherwise service node is created on demand
Returns:
service node created (or null if create was not specified)
Throws:
TWGAgentException - if failed to register service

deregisterService

public boolean deregisterService(java.lang.String name)
Deregister service with agent

Parameters:
name - name of service node to register
Returns:
true if deregistered, false if service was not registered

initAgentExtension

public void initAgentExtension()
                        throws TWGAgentExtensionException
Initialize agent extension Exit may be overridden by subclass to perform any initialization that is required before the agent becomes active. When this method completes agent extension is considered active, allowing agent startup to continue.

Throws:
TWGAgentExtensionException

terminateAgentExtension

public void terminateAgentExtension()
                             throws TWGAgentExtensionException
Terminate agent extension Exit may be overridden by subclass to perform any cleanup processing.

Throws:
TWGAgentExtensionException

runAgentExtension

public void runAgentExtension()
                       throws TWGAgentExtensionException
Run agent extension Exit may be overridden by subclass to own the main thread for any long-running processing.

Throws:
TWGAgentExtensionException

getProperty

public java.lang.String getProperty(java.lang.String key)
Get property value from extension's properties

Parameters:
key - - property key
Returns:
property value, or null if value not found

getProperty

public java.lang.String getProperty(java.lang.String key,
                                    java.lang.String defaultValue)
Get property value from extension's properties

Parameters:
key - - property key
defaultValue - - default property value if key not defined
Returns:
property value, or null if value not found

getPropertySet

public java.util.Properties getPropertySet()
Get extension's properties

Returns:
Properties for extension

VendorName

public java.lang.String VendorName(java.util.Locale locale)
Get vendor name for extension

Parameters:
locale - - locale requested for vendor name
Returns:
vendor name

getName

public java.lang.String getName()
Get extension name (properties filename)

Returns:
extension name

DisplayName

public java.lang.String DisplayName(java.util.Locale locale)
Get extension's NLS name

Parameters:
locale - - locale requested for extension name
Returns:
extension name (NLS string)

VersionName

public java.lang.String VersionName(java.util.Locale locale)
Get extension's version

Parameters:
locale - - locale requested for vendor name
Returns:
extension version name (NLS string)

getResourceBundle

public MultiLocaleBundle getResourceBundle()
Get extension's NLS resource bundle instance

Returns:
extension's NLS resource bundle

getNLSstring

public java.lang.String getNLSstring(java.util.Locale locale,
                                     java.lang.String property_name)
Get extension's NLS string for given string ID

Parameters:
locale - - locale to be requested
property_name - - name of property containing string ID
Returns:
value of string, or null if not found