com.tivoli.twg.engine
Class TWGDefaultTask

java.lang.Object
  extended bycom.tivoli.twg.engine.TWGObject
      extended bycom.tivoli.twg.engine.TWGPersistentObject
          extended bycom.tivoli.twg.engine.TWGTask
              extended bycom.tivoli.twg.engine.TWGDefaultTask
All Implemented Interfaces:
GenericWaiter, TWGBaseShadowedObject, TWGClientServiceListener, TWGConsoleSpecShadowedObject, TWGGetSetInterface, TWGPersistentObjectSubclassRestorable

public class TWGDefaultTask
extends TWGTask
implements GenericWaiter

This class provides a default implementation of TWGTask which is an abstract class. It provides implementations for the following abstract methods:

This class also has constructors that can create an instance based on a properties file or a Properties object.


Field Summary
static java.lang.String CLASSNAME
          Our classname
static byte IPCFLAGS_SAVE_MASK
           
static byte WANT_ACTIVATION_COMMAND
           
static byte WANT_MO_ADDRCHG_COMMAND
           
static byte WANT_MO_LIFECYCLE_COMMAND
           
static byte WANT_MO_STATE_COMMAND
           
 
Fields inherited from class com.tivoli.twg.engine.TWGTask
clientTasks, dataStoreVersion, privileges, propertiesFileName, props, SUBTASK_ACT_COMPLETE, SUBTASK_ACT_FAILED, SUBTASK_ACT_PENDING, subtasks, TASK_BIND_INSTANCE, TASK_DELETED, TASK_SERVER_AUTOLOAD, TASK_SERVER_ENABLE_JIT, TASK_SERVER_NO_RUN_THREAD, TASK_SERVER_SAME_JVM, TASK_SERVER_SAME_JVM_CONFIGURABLE, TASK_SERVER_SYNCHRONOUS, TASK_SERVER_TYPE_JAVA, TASK_SERVER_TYPE_NATIVE, TASK_SERVER_TYPE_NONE, TASK_STATE_FAILED, TASK_STATE_STARTED, TASK_STATE_STARTING, TASK_STATE_STOPPED, TASK_STATE_STOPPING, tasks, tasksByToid
 
Fields inherited from class com.tivoli.twg.engine.TWGPersistentObject
CLASS_NAME, SIZEOF_BYTE, SIZEOF_CHAR, SIZEOF_DOUBLE, SIZEOF_FLOAT, SIZEOF_INT, SIZEOF_LONG, SIZEOF_SHORT
 
Constructor Summary
TWGDefaultTask()
          Default constructor to allow for persistant object restore
TWGDefaultTask(java.util.Properties props)
          Constructor using a properties object to specify the data for this TWGTask.
TWGDefaultTask(java.util.Properties props, java.lang.String extensionClassName)
          Constructor using a properties object to specify the data for this TWGTask.
TWGDefaultTask(java.lang.String propertiesFileName)
          Constructor using a properties file to specify the data for this TWGTask.
TWGDefaultTask(java.lang.String propertiesFileName, java.lang.String extensionClassName)
          Constructor using a properties file to specify the data for this TWGTask.
 
Method Summary
 boolean addClassOfInterest(java.lang.String mocName)
          Add a managed object to the classesOfInterest set for managed object lifecycle, state change and address entry change notifications.
static void addRemoteMOServiceListener(Command cmd)
          Register command sender's IPC path for MO service added notification commands.
protected  void checkPersistentStoreLevel()
          Check to see if persistent store needs to be updated for any reason
 void done(boolean complete)
          This method is required for using the GenericWaiter/GenericPoller support.
 long getCommandCode()
          Method to get command code for service node IPC to server task process.
static void initialize()
          This class method is called by TWGTask during its initialization processing.
 boolean isDebugTaskActivation()
          Deprecated.  
 boolean isDone()
          This method is required for using the GenericWaiter/GenericPoller support.
 boolean removeClassOfInterest(java.lang.String mocName)
          Remove a managed object from the classesOfInterest set for managed object lifecycle, state change and address entry change notifications.
static void removeRemoteMOServiceListener(Command cmd)
          Deregister command sender's IPC path for service added and deleted notification commands.
protected  void restoreData(TWGPersistentObjectDictionary dictionary, boolean resolveObjectReferences)
          Method for restoring persistent object data.
protected  void saveData(TWGPersistentObjectDictionary dictionary)
          Method for saving persistent object data.
 boolean serverActivate()
          This method is called by the server to activate this task.
 boolean serverDeactivate()
          This method is called by the server when it needs to deactivate a task.
 boolean serverTaskThread()
          This method is called during task server activation.
 void setCommandCode(long commandCode)
          Method to set the command code for service node IPC to server task process.
 void setDebugTaskActivation(boolean flag)
          Deprecated.  
 void setIpcFlag(byte flag, boolean value)
          Method to set or clear the bit flags that control what information is forwarded over the service node IPC to a server task process.
 int subtaskActivate(TWGTaskActivation act)
          This method is called by the server when a subtask is to be activated.
 void subtaskDeactivate(TWGTaskActivation act)
          This method is called by the server when it receives a console command to deactivate a subtask or if the task activation has been cancelled via the scheduler.
static void terminate()
          Deactivate all active tasks
static void updateDelayedTasks()
           
 
Methods inherited from class com.tivoli.twg.engine.TWGTask
addClient, addClient, addSubtask, addSubtask, attachAllAllowedTasks, AttachObjectToConsole, checkPrivileges, clientServiceAdded, clientServiceRemoved, Delete, deleteTask, deleteTask, Destroy, destroyActivation, detachAllDisallowedTasks, DetachObjectFromAllConsoles, DetachObjectFromConsole, dumpProperties, getAllSubtasks, getAllTaskIdentifiers, getAttributeIDList, getAttributeType, getAttributeValue, getClientTaskCount, getClientTasks, GetConShadowClass, getExtensionClassName, getGuiClass, getGuiParms, getHelpTopicsMapping, getID, getImageSet, getParent, getParentID, getPrivilege s, getPropertiesFileName, getProperty, getProperty, getResourceBundle, getServerMaxHeapParm, getServerMinHeapParm, getServerName, getServerParms, getServerType, getServiceNode, GetShadowRecord, GetShadowVersion, getState, getSubtask, getSubtaskCount, getTask, getTask, getTaskData, getTitle, getTitleKey, hasServerRunThread, hasSubtask, isBoundInstance, isDisabled, isDisabledSubtask, isLiteralTitle, isSchedulerReady, isServerAutoLoad, isServerJIT, isServerSameJVM, isServerSameJVMConfigurable, isServerSynchronous, isTaskDeleted, isTaskIconHidden, isTaskID, isUnrestricted, putTask, removeSubtask, serverActivationFailed, serverDeactivationComplete, setAttributeValue, setBoundInstance, setExtensionClassName, setGuiClass, setGuiParms, setHelpTopicsMapping, setID, setImageSet, setImageSet, setLiteralTitle, SetObjectID, setParent, setPrivileges, setPropertiesFileName, setResourceBundle, setServerAutoLoad, setServerJIT, setServerMaxHeapParm, setServerMinHeapParm, setServerName, setServerParms, setServerRunThread, setServerSameJVM, setServerSameJVMConfigurable, setServerSynchronous, setServerType, setServiceNode, setTaskData, setTaskIconHidden, setTempDisabled, setTitleKey, setUnrestricted, subtaskActivationComplete, toString, unsetParent, UpdateShadowVersion
 
Methods inherited from class com.tivoli.twg.engine.TWGPersistentObject
enableAsyncWrites, fromPersistID, isNewPersistentStore, isSaveRequired, PersistID, restore, restoreAll, save, save, setSaveRequired, toPersistID
 
Methods inherited from class com.tivoli.twg.engine.TWGObject
AllObjects, AllObjects, DumpTWGObjects, FindObject, isDeleted, isNewObject, isPersistent, isPersistent, isValid, isValid, ObjectID, setDistinctObjectID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
Our classname

See Also:
Constant Field Values

WANT_ACTIVATION_COMMAND

public static final byte WANT_ACTIVATION_COMMAND
See Also:
Constant Field Values

WANT_MO_LIFECYCLE_COMMAND

public static final byte WANT_MO_LIFECYCLE_COMMAND
See Also:
Constant Field Values

WANT_MO_STATE_COMMAND

public static final byte WANT_MO_STATE_COMMAND
See Also:
Constant Field Values

WANT_MO_ADDRCHG_COMMAND

public static final byte WANT_MO_ADDRCHG_COMMAND
See Also:
Constant Field Values

IPCFLAGS_SAVE_MASK

public static final byte IPCFLAGS_SAVE_MASK
See Also:
Constant Field Values
Constructor Detail

TWGDefaultTask

public TWGDefaultTask()
Default constructor to allow for persistant object restore


TWGDefaultTask

public TWGDefaultTask(java.lang.String propertiesFileName)
               throws com.tivoli.twg.engine.TWGTaskCreationException,
                      java.util.MissingResourceException
Constructor using a properties file to specify the data for this TWGTask.

Parameters:
propertiesFileName - The name of the properties file to load and get properties from.
Throws:
TWGTaskCreationException - when syntax errors are discovered in the data retrieved from the properties file.
java.util.MissingResourceException

TWGDefaultTask

public TWGDefaultTask(java.lang.String propertiesFileName,
                      java.lang.String extensionClassName)
               throws com.tivoli.twg.engine.TWGTaskCreationException,
                      java.util.MissingResourceException
Constructor using a properties file to specify the data for this TWGTask.

Parameters:
propertiesFileName - The name of the properties file to load and get properties from.
extensionClassName - The name of the extension class instantiating this task.
Throws:
TWGTaskCreationException - when syntax errors are discovered in the data retrieved from the properties file.
java.util.MissingResourceException

TWGDefaultTask

public TWGDefaultTask(java.util.Properties props)
               throws com.tivoli.twg.engine.TWGTaskCreationException,
                      java.util.MissingResourceException
Constructor using a properties object to specify the data for this TWGTask. Note: The Properties object does not become part of this task's persistent data. It is only available during the constructor.

Parameters:
props - The properties object to get properties from.
Throws:
TWGTaskCreationException - when syntax errors are discovered in the data retrieved from the properties file.
java.util.MissingResourceException

TWGDefaultTask

public TWGDefaultTask(java.util.Properties props,
                      java.lang.String extensionClassName)
               throws com.tivoli.twg.engine.TWGTaskCreationException,
                      java.util.MissingResourceException
Constructor using a properties object to specify the data for this TWGTask. Note: The Properties object does not become part of this task's persistent data. It is only available during the constructor.

Parameters:
props - The properties object to get properties from.
extensionClassName - The name of the extension class instantiating this task.
Throws:
TWGTaskCreationException - when syntax errors are discovered in the data retrieved from the properties file.
java.util.MissingResourceException
Method Detail

initialize

public static void initialize()
This class method is called by TWGTask during its initialization processing.


terminate

public static void terminate()
Description copied from class: TWGTask
Deactivate all active tasks


serverActivate

public boolean serverActivate()
This method is called by the server to activate this task. The default The default behavior of this method depends on how this task has been initialized. Also, if this task has a ServiceNode value, then activation will not complete until the named service node has been detected.

Specified by:
serverActivate in class TWGTask
Returns:
true to indicate successful server task activation, or false to indicate a failure.

serverTaskThread

public boolean serverTaskThread()
This method is called during task server activation. If the task runs in another process then this method simply returns true. If the task is to be run in a thread in the server's JVM, then this method calls the task's run() method.

Specified by:
serverTaskThread in class TWGTask
Returns:
true if task doesn't need a thread, but the server task should still be considered to be in a started state, otherwise false indicating the server task has ended, and the server will do any necessary cleanup and notification.

serverDeactivate

public boolean serverDeactivate()
This method is called by the server when it needs to deactivate a task. Generally, this is done during server shutdown. This is where the task can do any required termination processing. The default behavior of this method is:

Specified by:
serverDeactivate in class TWGTask
Returns:
true to indicate that serverDeactivation is complete, or false to indicate that clean-up is still in progress and completion will be signaled by calling serverDeactivationComplete().

subtaskActivate

public int subtaskActivate(TWGTaskActivation act)
This method is called by the server when a subtask is to be activated. This method will only be called when the task is in the TASK_RUNNING state. In order for the engine to properly track the state of tasks, the subtaskActivated() method of the TWGTaskActivation parameter must be called. If the * specified subtask is configured to have clients automatically started, then they are started before this call is made. If the server task is running in the server's JVM, then its subtaskActivate() method is called. If the server task is running in another process and a service node has been specified, then a TaskActivationCommand is sent to the service node.

Specified by:
subtaskActivate in class TWGTask
Parameters:
act - the TWGTaskActivation object for this subtask activation.
Returns:
Use one of the following final values:
  • SUBTASK_ACT_COMPLETE - completed successfully
  • SUBTASK_ACT_FAILED - subtask activation failed
  • SUBTASK_ACT_PENDING - subtask activation will complete asynchronously and report results by calling subtaskActivateComplete()

subtaskDeactivate

public void subtaskDeactivate(TWGTaskActivation act)
This method is called by the server when it receives a console command to deactivate a subtask or if the task activation has been cancelled via the scheduler. This method will only be called when the task is in the TASK_RUNNING state. In order for the engine to properly track the state of tasks, the subtaskDexctivated() method of the TWGTaskActivation object must be called. If the server task is running in the server's JVM, then its subtaskDeactivate() is called. If the server task is running in another process and a service node has been specified, then a TaskDeactivationCommand is sent to the service node. If the specified subtask is configured to have clients automatically started, then they are stopped at this time.

Specified by:
subtaskDeactivate in class TWGTask
Parameters:
act - the TWGTaskActivation object for this subtask activation.

addRemoteMOServiceListener

public static void addRemoteMOServiceListener(Command cmd)
Register command sender's IPC path for MO service added notification commands.


removeRemoteMOServiceListener

public static void removeRemoteMOServiceListener(Command cmd)
Deregister command sender's IPC path for service added and deleted notification commands.


restoreData

protected void restoreData(TWGPersistentObjectDictionary dictionary,
                           boolean resolveObjectReferences)
                    throws TWGPersistentObjectRestoreException
Method for restoring persistent object data.

Overrides:
restoreData in class TWGTask
Parameters:
resolveObjectReferences - used to indicate if object references should be resolved during restore.
Throws:
TWGPersistentObjectRestoreException - thrown to abort restore procedure.

getCommandCode

public long getCommandCode()
Method to get command code for service node IPC to server task process.

Returns:
long command code specified during TWGDefaultTask construction.

setCommandCode

public void setCommandCode(long commandCode)
Method to set the command code for service node IPC to server task process.

Parameters:
commandCode - long value of command code to use

setIpcFlag

public void setIpcFlag(byte flag,
                       boolean value)
Method to set or clear the bit flags that control what information is forwarded over the service node IPC to a server task process.

Parameters:
flag - The flag to set. Use one of these static int values:
  • WANT_ACTIVATION_COMMAND
  • WANT_MO_LIFECYCLE_COMMAND
  • WANT_MO_STATE_COMMAND
  • WANT_MO_ADDRCHG_COMMAND
value - true to set the flag, false to clear it

saveData

protected void saveData(TWGPersistentObjectDictionary dictionary)
                 throws TWGPersistentObjectSaveException
Method for saving persistent object data.

Overrides:
saveData in class TWGTask
Throws:
TWGPersistentObjectSaveException - thrown to abort save procedure.

isDone

public boolean isDone()
This method is required for using the GenericWaiter/GenericPoller support. Depending on the current state of the task, this method checks for various conditions and returns the appropriate boolean value. This method should not be called by any class except GenericPoller.

Specified by:
isDone in interface GenericWaiter
Returns:
true if the event has occurred.
See Also:
com.tivoli.twg.libs.GenericWaiter.

done

public void done(boolean complete)
This method is required for using the GenericWaiter/GenericPoller support. Depending on the current state of the task and the value of the boolean parameter, this method makes the appropriate state changes for this TWGDefaultTask object. This method should not be called by any class except GenericPoller.

Specified by:
done in interface GenericWaiter
Parameters:
complete - true if the event has occurred (i.e. true was returned from an isDone() call), false if the the specified number of retries have been attempted without getting isDone=true
See Also:
com.tivoli.twg.libs.GenericWaiter.

addClassOfInterest

public boolean addClassOfInterest(java.lang.String mocName)
Add a managed object to the classesOfInterest set for managed object lifecycle, state change and address entry change notifications. This method should only be called during extension initialization in the InitComplete method.

Parameters:
mocName - String name of the managed object class to add to the classes of interest collection
Returns:
boolean true if classesOfInterest was modified, false if the specified managed object class name was already in the collection

removeClassOfInterest

public boolean removeClassOfInterest(java.lang.String mocName)
Remove a managed object from the classesOfInterest set for managed object lifecycle, state change and address entry change notifications.

Parameters:
mocName - String name of the managed object class to remove from the classes of interest collection
Returns:
boolean true if classesOfInterest was modified, false if the specified managed object class name was not in the collection

checkPersistentStoreLevel

protected void checkPersistentStoreLevel()
Check to see if persistent store needs to be updated for any reason

Overrides:
checkPersistentStoreLevel in class TWGTask

updateDelayedTasks

public static void updateDelayedTasks()

setDebugTaskActivation

public void setDebugTaskActivation(boolean flag)
Deprecated.  

Set this task to open a window in the task activation processing. This window allows an instance of this task's server to be launched under a debugger before the task activation takes place. When this flag is set to true, the task server is marked ready for activations even though a "Ready For Activations" command has not been received by the task infrastructure. This compensates for the fact that when the task server is brought up under the debugger, the command is sent before the engine needs it. Note: This value is not stored persistently, so you must add code to your extension to set it during engine initialization.

Parameters:
flag - set to true to open the window, false for normal task activation processing

isDebugTaskActivation

public boolean isDebugTaskActivation()
Deprecated.  

Test to see if the debug task activation flag has been set.

Returns:
boolean true means that the window described in setDebugTaskActivation() is open, false means that normal task activation processing will occur