com.tivoli.twg.engine
Class TWGExtension

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGObject
      extended bycom.tivoli.twg.engine.TWGExtension
All Implemented Interfaces:
TWGBaseShadowedObject, TWGShadowedObject
Direct Known Subclasses:
TWGBaseExtension, TWGRMONDeviceExtension

public abstract class TWGExtension
extends TWGObject
implements TWGShadowedObject

Base class for defining engine extension packages. Each extension package must define a subclass of TWGExtension, providing implementations of various initialization exits. During initialization, each file in the extensions directory (see TWGEnvironment.getExtensionsDirectory) matching the '*.TWGExt" pattern is opened and used to initialize a Properties object. If successful, the Properties are checked for the 'twg.extension.classname' property (which is the name of TWGExtension subclass for the extension package). This name is then used to load the class, create an instance using the default constructor (the property set is accessable during the constructor of the subclass, if needed).


Field Summary
static java.lang.String EXTENSION_CLASS
          Property for extension's classname
static java.lang.String EXTENSION_CLI_CLASS
          Property for cli bundle definition
static java.lang.String EXTENSION_DELAY_CLASS_INIT
          Property to delay the ClassInit call to after everyone else
static java.lang.String EXTENSION_DISABLED
          Property for extension's disabled state
static java.lang.String EXTENSION_NAME
          Property for extension's name resource (name ID in NLS resource)
static java.lang.String EXTENSION_NLS_CLASS
          Property for extension's NLS resource (for strings)
static java.lang.String EXTENSION_VENDOR
          Property for extension's vendor (vendor ID in NLS resource)
static java.lang.String EXTENSION_VERSION
          Property for extension's version
static int PREVIOUS_SERVER_VERSION_NEW_SERVER
          Previous server version: new server configuration or fresh install
 
Constructor Summary
protected TWGExtension()
          Default constructor for TWGExtension.
 
Method Summary
static void DoInitClassInstances()
          Execute second initialization method for all loaded extensions
static void DoInitClassRegistration()
          Execute first initialization method for all loaded extensions
static void DoInitCompletion()
          Execute final initialization method for all loaded extensions
static void DoStartupCompletion()
          Execute startup completion method for all loaded extensions
static void DoTermBegin()
          Execute first termination method for all loaded extensions
static void DoTermComplete()
          Execute final termination method for all loaded extensions
 java.lang.String ExtensionName(java.util.Locale locale)
          Get extension name for extension
static java.lang.String getActiveExtensionName()
          Return name of TWGExtension subclass currently active.
 java.lang.String GetConShadowClass()
          Get name of console shadow class.
static int getCurrentStartupVersion()
          Get version of server for current startup.
static int getLastStartupVersion()
          Get version of server during last successful startup.
 java.lang.String getNLSstring(java.util.Locale locale, java.lang.String property_name)
          Get NLS extension string for given ID
 java.lang.String getProperty(java.lang.String pname)
          Get extension property value.
 java.util.Properties getPropertySet()
          Get extension's property set.
static java.lang.Class GetRegisteredClass(java.lang.String cname)
          Return registered class
static java.lang.Class[] GetRegisteredClasses(java.lang.String superclass_name)
          Get list of loaded and registered subclasses which are subclasses of a given class.
 byte[] GetShadowRecord(java.util.Locale locale)
          Get buffer containing current values of the shadowed attributes to be delivered to the console shadow class.
 long GetShadowVersion()
          Get object state version.
 void InitClassInstances()
          Second initialization method, intended to allow extension to create default instances of classes registered during InitClassRegistration().
 void InitClassInstances(boolean is_enabled)
          Second initialization method, intended to allow extension to create default instances of classes registered during InitClassRegistration().
 void InitClassRegistration()
          First initialization method, intended to allow extensions to register classes.
 void InitClassRegistration(boolean is_enabled)
          First initialization method, intended to allow extensions to register classes.
 void InitCompletion()
          Final initialization method, intended to allow an extension to do any actions which may have required the other extensions to have completed the previous passes of initialization.
 void InitCompletion(boolean is_enabled)
          Final initialization method, intended to allow an extension to do any actions which may have required the other extensions to have completed the previous passes of initialization.
 boolean isClassInitDelayed()
          Check if extension wants to be called after everyone else has been called
 boolean isDisabled()
          Check if extension is disabled
static boolean isExtensionClassDefined(java.lang.String cn)
          Return true if given TWGExtension subclass has been defined
static boolean isNewInstallOrConfig()
          Check to see if this is a new install (or a fresh configuration
static boolean isRegistered(java.lang.String cname)
          Test to see if class was successfully registered
static boolean IsRegisteredClass(java.lang.String cname)
          Test to see if class was successfully registered
static boolean isUpdatedServerBuildOrVersion()
          Check to see if updated version or build
static boolean isUpdatedServerVersion()
          Check to see if updated server version (not just new build of same version)
static void LoadCommandBundles()
          Load CLI Bundles
 void RegisterClass(java.lang.String cname)
          Register a TWGObject-family subclass.
 void SetObjectID(long oid)
          Change the object ID to a new value
 void setProperty(java.lang.String pname, java.lang.String pvalue)
          Set extension property value.
 void StartupCompletion()
          Startup complete method, intended to allow an extension to do any actions which required the completion of server startup (including automatic startup of other tasks, etc).
 void StartupCompletion(boolean is_enabled)
          Startup complete method, intended to allow an extension to do any actions which required the completion of server startup (including automatic startup of other tasks, etc).
 void TermBegin()
          First termination method, intended to allow an extension to begin the process of termination.
 void TermBegin(boolean is_enabled)
          First termination method, intended to allow an extension to begin the process of termination.
 void TermComplete()
          Final termination method, intended to allow an extension to terminate any processing which may still be active.
 void TermComplete(boolean is_enabled)
          Final termination method, intended to allow an extension to terminate any processing which may still be active.
 void UpdateShadowVersion()
          Update object state version.
 java.lang.String VendorName(java.util.Locale locale)
          Get vendor name for extension
 java.lang.String VersionName(java.util.Locale locale)
          Get extension version
 
Methods inherited from class com.tivoli.twg.engine.TWGObject
AllObjects, AllObjects, Delete, Destroy, DumpTWGObjects, FindObject, isDeleted, isNewObject, isPersistent, isPersistent, isValid, isValid, ObjectID, setDistinctObjectID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTENSION_CLASS

public static final java.lang.String EXTENSION_CLASS
Property for extension's classname

See Also:
Constant Field Values

EXTENSION_VERSION

public static final java.lang.String EXTENSION_VERSION
Property for extension's version

See Also:
Constant Field Values

EXTENSION_NLS_CLASS

public static final java.lang.String EXTENSION_NLS_CLASS
Property for extension's NLS resource (for strings)

See Also:
Constant Field Values

EXTENSION_NAME

public static final java.lang.String EXTENSION_NAME
Property for extension's name resource (name ID in NLS resource)

See Also:
Constant Field Values

EXTENSION_VENDOR

public static final java.lang.String EXTENSION_VENDOR
Property for extension's vendor (vendor ID in NLS resource)

See Also:
Constant Field Values

EXTENSION_DISABLED

public static final java.lang.String EXTENSION_DISABLED
Property for extension's disabled state

See Also:
Constant Field Values

EXTENSION_DELAY_CLASS_INIT

public static final java.lang.String EXTENSION_DELAY_CLASS_INIT
Property to delay the ClassInit call to after everyone else

See Also:
Constant Field Values

EXTENSION_CLI_CLASS

public static final java.lang.String EXTENSION_CLI_CLASS
Property for cli bundle definition

See Also:
Constant Field Values

PREVIOUS_SERVER_VERSION_NEW_SERVER

public static final int PREVIOUS_SERVER_VERSION_NEW_SERVER
Previous server version: new server configuration or fresh install

See Also:
Constant Field Values
Constructor Detail

TWGExtension

protected TWGExtension()
Default constructor for TWGExtension. Any subclass must provide an implementation which (at least) calls this constructor. The properties for the extension are available after the TWGExtension constructor completes.

Method Detail

SetObjectID

public void SetObjectID(long oid)
                 throws DuplicateObjectIDException
Change the object ID to a new value

Overrides:
SetObjectID in class TWGObject
Parameters:
oid - - new object ID value
Throws:
DuplicateObjectIDException - if new ID is duplicate

getProperty

public java.lang.String getProperty(java.lang.String pname)
Get extension property value.

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

setProperty

public void setProperty(java.lang.String pname,
                        java.lang.String pvalue)
Set extension property value.

Parameters:
pname - - property name
pvalue - - property value
Since:
ITD V3.1

getPropertySet

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

Returns:
Properties set for extension instance.

RegisterClass

public void RegisterClass(java.lang.String cname)
                   throws java.lang.ClassNotFoundException
Register a TWGObject-family subclass. Used by TWGExtension subclasses during ClassRegistration() to introduce new classes to engine.

Parameters:
cname - - Name of class to be registered
Throws:
java.lang.ClassNotFoundException - if class not successfully loaded

GetRegisteredClasses

public static java.lang.Class[] GetRegisteredClasses(java.lang.String superclass_name)
Get list of loaded and registered subclasses which are subclasses of a given class.

Returns:
Class array of all matching classes

IsRegisteredClass

public static boolean IsRegisteredClass(java.lang.String cname)
Test to see if class was successfully registered

Parameters:
cname - - name of class to be checked
Returns:
true if class was successfully registered, else false

isRegistered

public static boolean isRegistered(java.lang.String cname)
Test to see if class was successfully registered

Parameters:
cname - - name of class to be checked
Returns:
true if class was successfully registered, else false

GetRegisteredClass

public static java.lang.Class GetRegisteredClass(java.lang.String cname)
Return registered class

Parameters:
cname - - name of registered class
Returns:
reference to registered class, or null if not loaded

LoadCommandBundles

public static void LoadCommandBundles()
                               throws TWGExtensionInitException
Load CLI Bundles

Throws:
TWGExtensionInitException - if any bundles failed to load

DoInitClassRegistration

public static void DoInitClassRegistration()
                                    throws TWGExtensionInitException
Execute first initialization method for all loaded extensions

Throws:
TWGExtensionInitException - if any extensions abort

DoInitClassInstances

public static void DoInitClassInstances()
                                 throws TWGExtensionInitException
Execute second initialization method for all loaded extensions

Throws:
TWGExtensionInitException - if any extensions abort

DoInitCompletion

public static void DoInitCompletion()
                             throws TWGExtensionInitException
Execute final initialization method for all loaded extensions

Throws:
TWGExtensionInitException - if any extensions abort

DoStartupCompletion

public static void DoStartupCompletion()
Execute startup completion method for all loaded extensions


DoTermBegin

public static void DoTermBegin()
                        throws TWGExtensionTermException
Execute first termination method for all loaded extensions

Throws:
TWGExtensionTermException - if any extensions abort

DoTermComplete

public static void DoTermComplete()
                           throws TWGExtensionTermException
Execute final termination method for all loaded extensions

Throws:
TWGExtensionTermException - if any extensions abort

InitClassRegistration

public void InitClassRegistration()
                           throws TWGExtensionInitException
First initialization method, intended to allow extensions to register classes. TWGExtension subclasses cannot assume during this pass that other specific extensions have already completed their registration. Also, instances of TWGPersistentObject classes cannot be created, and have not been restored as of this initialization pass. This method is only called when the extension is active.

Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

InitClassRegistration

public void InitClassRegistration(boolean is_enabled)
                           throws TWGExtensionInitException
First initialization method, intended to allow extensions to register classes. TWGExtension subclasses cannot assume during this pass that other specific extensions have already completed their registration. Also, instances of TWGPersistentObject classes cannot be created, and have not been restored as of this initialization pass. This method is optional, and is always called (even if the extension is disabled). The default implementation calls the InitClassRegistration() method when the extension is enabled.

Parameters:
is_enabled - - true if extension is enabled, false if not enabled
Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

InitClassInstances

public void InitClassInstances()
                        throws TWGExtensionInitException
Second initialization method, intended to allow extension to create default instances of classes registered during InitClassRegistration(). Always called after InitClassRegistration() pass and after TWGPersistObject instances are restored. TWGExtension subclasses cannot assume that other instances of TWGExtension have already completed this pass. Subclasses should be prepared to check for the existance of "default" object instances, and create them if they need to be created (i.e. during the first initialization of a new extension). This method is only called for active extensions.

Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

InitClassInstances

public void InitClassInstances(boolean is_enabled)
                        throws TWGExtensionInitException
Second initialization method, intended to allow extension to create default instances of classes registered during InitClassRegistration(). Always called after InitClassRegistration() pass and after TWGPersistObject instances are restored. TWGExtension subclasses cannot assume that other instances of TWGExtension have already completed this pass. Subclasses should be prepared to check for the existance of "default" object instances, and create them if they need to be created (i.e. during the first initialization of a new extension). This method is called for active or inactive extensions. Default implementation calls InitClassInstances() is extension is active.

Parameters:
is_enabled - - true if extension is enabled, false if not enabled
Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

InitCompletion

public void InitCompletion()
                    throws TWGExtensionInitException
Final initialization method, intended to allow an extension to do any actions which may have required the other extensions to have completed the previous passes of initialization. The default method does nothing. Method is only called for active extensions.

Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

InitCompletion

public void InitCompletion(boolean is_enabled)
                    throws TWGExtensionInitException
Final initialization method, intended to allow an extension to do any actions which may have required the other extensions to have completed the previous passes of initialization. The default method calls InitCompletion() if extension is active. Method is always called.

Parameters:
is_enabled - - true if enabled, false if disabled
Throws:
TWGExtensionInitException - if a fatal error occurs during the initialization method

StartupCompletion

public void StartupCompletion()
Startup complete method, intended to allow an extension to do any actions which required the completion of server startup (including automatic startup of other tasks, etc). The default method does nothing. Method is only called for active extensions.


StartupCompletion

public void StartupCompletion(boolean is_enabled)
Startup complete method, intended to allow an extension to do any actions which required the completion of server startup (including automatic startup of other tasks, etc). The default method does nothing.

Parameters:
is_enabled - - true if extension is enabled, false if not

TermBegin

public void TermBegin()
               throws TWGExtensionTermException
First termination method, intended to allow an extension to begin the process of termination. The only termination processing which should occur here is that which needs to be done before other extensions have executed TermCompletion() pass.

Throws:
TWGExtensionTermException - if an error occurs during the termination method

TermBegin

public void TermBegin(boolean is_enabled)
               throws TWGExtensionTermException
First termination method, intended to allow an extension to begin the process of termination. The only termination processing which should occur here is that which needs to be done before other extensions have executed TermCompletion() pass. Default calls TermBegin() if extension active.

Parameters:
is_enabled - - true if enabled, false if disabled
Throws:
TWGExtensionTermException - if an error occurs during the termination method

TermComplete

public void TermComplete()
                  throws TWGExtensionTermException
Final termination method, intended to allow an extension to terminate any processing which may still be active.

Throws:
TWGExtensionTermException - if an error occurs during the termination method

TermComplete

public void TermComplete(boolean is_enabled)
                  throws TWGExtensionTermException
Final termination method, intended to allow an extension to terminate any processing which may still be active. Default calls TermComplete() if extension active.

Parameters:
is_enabled - - true if enabled, false if not
Throws:
TWGExtensionTermException - if an error occurs during the termination method

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

ExtensionName

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

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

VersionName

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

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

getNLSstring

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

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

UpdateShadowVersion

public void UpdateShadowVersion()
Update object state version. This method must call the TWGActiveConsole.nextShadowVersion() to update its internal state_version attribute (a 'long' instance variable). This method should be called by any methods of the object's class or subclasses which modify attributes which are send to the shadow objects on the console).

Specified by:
UpdateShadowVersion in interface TWGBaseShadowedObject

GetShadowVersion

public long GetShadowVersion()
Get object state version. This returns value of state_version.

Specified by:
GetShadowVersion in interface TWGBaseShadowedObject
Returns:
state_version attribute value

GetConShadowClass

public java.lang.String GetConShadowClass()
Get name of console shadow class. This returns the name of TWGConObject subclass which is used to hold the attributes shadowed to the console.

Specified by:
GetConShadowClass in interface TWGBaseShadowedObject
Returns:
com.tivoli.twg.engine.TWGConObject subclass which object shadows to

GetShadowRecord

public byte[] GetShadowRecord(java.util.Locale locale)
Get buffer containing current values of the shadowed attributes to be delivered to the console shadow class. This data is delivered along with the ObjectID (so the ObjectID shouldn't be included in the shadowed data record).

Specified by:
GetShadowRecord in interface TWGBaseShadowedObject
Parameters:
locale - - Locale of requested data
Returns:
byte array containing opaque data representation of attribute values to be delivered to the console shadow class.

isExtensionClassDefined

public static boolean isExtensionClassDefined(java.lang.String cn)
Return true if given TWGExtension subclass has been defined

Parameters:
cn - - classname of TWGExtension subclass
Returns:
true if defined, false if not defined

getActiveExtensionName

public static java.lang.String getActiveExtensionName()
Return name of TWGExtension subclass currently active. This method will only return a class name during extension initialization and/or termination processing

Returns:
name of TWGExtension subclass currently active, or null if none

isDisabled

public final boolean isDisabled()
Check if extension is disabled


isClassInitDelayed

public final boolean isClassInitDelayed()
Check if extension wants to be called after everyone else has been called


isNewInstallOrConfig

public static boolean isNewInstallOrConfig()
Check to see if this is a new install (or a fresh configuration

Returns:
true if new install or configuration, false if not

isUpdatedServerBuildOrVersion

public static boolean isUpdatedServerBuildOrVersion()
Check to see if updated version or build

Returns:
true if updated versus last successful server startup

isUpdatedServerVersion

public static boolean isUpdatedServerVersion()
Check to see if updated server version (not just new build of same version)

Returns:
true if updated version versus last successful server startup

getLastStartupVersion

public static int getLastStartupVersion()
Get version of server during last successful startup.

Returns:
version of last run, or PREVIOUS_SERVER_VERSION_NEW_SERVER if new. Value is MMmmYYnndd, where MM=major version, mm=minor version, YY=years since 1990, nn=month of year, dd=day of month of build.

getCurrentStartupVersion

public static int getCurrentStartupVersion()
Get version of server for current startup.

Returns:
version of current run. Value is MMmmYYnndd, where MM=major version, mm=minor version, YY=years since 1990, nn=month of year, dd=day of month of build.