com.ibm.dse.automaton.ext
Class DSEOperationState

java.lang.Object
  |
  +--com.ibm.dse.base.DSEHandler
        |
        +--com.ibm.dse.automaton.DSEState
              |
              +--com.ibm.dse.automaton.ext.DSEOperationState
Direct Known Subclasses:
DSESyncProcState

public class DSEOperationState
extends DSEState
implements OperationRepliedListener

This class is an extension of the DSEState which implements an state which is related to an operation. When an operation state is reached, the Automaton must look for the associated operation (whose is defined in the typeIdInfo attribute) chain it to the appropriate context, and execute it. The operation has the responsibility of firing an event when it ends. This event must contain a parameter named "dse_exitEventName". This parameter must contain the name of the event that the state machine will use to change to the next state. The operation context is chained to the processor context, but the data sharing should be done using the map formats.

See Also:
Serialized Form

Field Summary
static java.lang.String EXIT_EVENT_NAME
          Name of the parameter where the operation must store the name of the event that the automaton will use to go on with the flow.
protected  DataMapperFormat inputFormat
          Map format used to map data from the calling processor context to the context of the operation/processor which this state executes.
protected  Operation operation
          Operation which this state will execute.
protected  Semaphore operationRepliedSemaphore
          Semaphore where the execution will wait until the operation raises an operationRepliedEvent.
protected  DataMapperFormat outputFormat
          Map format used to map data from the context of the operation/processor which this state executes to the calling processor context.
 
Fields inherited from class com.ibm.dse.automaton.DSEState
ABORT_PROCESS, actionHandlers, CHANGE_STATE, CONTINUE, DEFAULT_TYPE, done, entryActionsTags, EXECUTE_ACTION_AND_CHANGESTATE, exitActionsTags, exitEventName, FINAL_TYPE, ignoreEntryActions, INITIAL_TYPE, name, PAGE_TYPE, pqThread, processor, runningModeFlag, sharedNotifiers, SKIP_ACTION, SKIP_ALL_ACTIONS, SKIP_CONDITIONS, SUBFLOW_TYPE, suspendedThread, SUSPENDTIME, tag, transitions, type, typeIdInfo
 
Constructor Summary
DSEOperationState()
           
 
Method Summary
 void activate()
          Activates an operation state.
 boolean chainOrAssignContext(Operation theOperation)
          This method checks to see if the operation has a context, if not then we need to assign one.
protected  void doDataMapping(DataMapperFormat format, Context sourceCtx, Context targetCtx)
          This utility method maps data from the source context to the target context using the supplied DataMapperFormat.
protected  DataMapperFormat getDataMapFormat(Tag formatName)
          This utility method returns a DataMapperFormat for the supplied format name.
 DataMapperFormat getInputFormat()
          Returns the input format attribute of this class.
 Operation getOperation()
          Returns the operation attribute of this class.
 DataMapperFormat getOutputFormat()
          Returns the output format attribute of this class.
 void handleOperationRepliedEvent(OperationRepliedEvent event)
          This method signals the semaphore where the state's activate method is waiting for the operation end.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes the state of this object from externalized data.
protected  void processQueue(Vector otherTrigs)
          This method processes the events queue of the processor; the behaviour is the same than the parent's behaviour, so be careful when doing changes in the parent's activate activate method.
protected  Operation readOperation()
          Gets the operation from the operation name, stored in the typeIdInfo state's attribute.
 void setInputFormat(DataMapperFormat newInputFormat)
          Sets the input format attribute of this class.
 void setOperation(Operation newOperation)
          Sets the input format attribute of this class.
 void setOutputFormat(DataMapperFormat newOutputFormat)
          Sets the output format attribute format.
protected  void signalEvent()
          Creates and signals an event which will be processed by the state itself.
 
Methods inherited from class com.ibm.dse.automaton.DSEState
abort, addHandlersForAction, dispatchEvent, doEntryActions, doExitActions, externalizer, fireDSEChangeStateEvent, fireDSEChangeStateEvent, fireDSEChangeStateEvent, getEntryActions, getExitActions, getGuardConditionResult, getInstanceOfAction, getName, getProcessor, getTag, getTransitions, getType, getTypeIdInfo, isIgnoreEntryActions, isRunningModeFlag, processEventQueue, readExternal, readExternal, removeExternal, removeHandlersForAction, removeHandlersForAction, resume, setEntryActions, setExitActions, setIgnoreEntryActions, setName, setProcessor, setTag, setTransitions, setType, setTypeIdInfo, subscribeToShareNotifiers, suspend, terminate, toString, toStrings, toTags, unsubscribeToSharedNotifiers, writeExternal, writeExternal
 
Methods inherited from class com.ibm.dse.base.DSEHandler
handleEvent, handleEvent, stopHandlingEvent, stopHandlingEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

operationRepliedSemaphore

protected Semaphore operationRepliedSemaphore
Semaphore where the execution will wait until the operation raises an operationRepliedEvent.

EXIT_EVENT_NAME

public static final java.lang.String EXIT_EVENT_NAME
Name of the parameter where the operation must store the name of the event that the automaton will use to go on with the flow. This parameter is passed within the operationRepliedEvent.

inputFormat

protected DataMapperFormat inputFormat
Map format used to map data from the calling processor context to the context of the operation/processor which this state executes.

outputFormat

protected DataMapperFormat outputFormat
Map format used to map data from the context of the operation/processor which this state executes to the calling processor context.

operation

protected Operation operation
Operation which this state will execute.
Constructor Detail

DSEOperationState

public DSEOperationState()
Method Detail

activate

public void activate()
              throws DSEInvalidArgumentException,
                     DSEProcessorException
Activates an operation state. The operation must fire an event, and this class will listen for this event. The event raised from the operation must contain information about the event that will be used to change the state. This method will wait until this event is received. Then it will try to raise the event received created from the information received from the operation. The state must process this event and put it on the queue. Afterwards the event queue is processed, and this provokes a change state.
Overrides:
activate in class DSEState
Throws:
DSEInvalidArgumentException -  
DSEProcessorException -  

chainOrAssignContext

public boolean chainOrAssignContext(Operation theOperation)
                             throws DSEProcessorException
This method checks to see if the operation has a context, if not then we need to assign one. If the operation already has a context, we need to chain the operation context to an existing context. In either case the value of the linkContextTo attribute is the context to be used. If the context was assigned, this method returns true.
Parameters:
thisOp - com.ibm.dse.base.Operation
contextName - java.lang.String
Returns:
boolean

doDataMapping

protected void doDataMapping(DataMapperFormat format,
                             Context sourceCtx,
                             Context targetCtx)
                      throws DSEException
This utility method maps data from the source context to the target context using the supplied DataMapperFormat.
Parameters:
format - com.ibm.dse.base.DataMapperFormat
sourceCtx - com.ibm.dse.base.Context
targetCtx - com.ibm.dse.base.Context
Throws:
DSEException -  

getDataMapFormat

protected DataMapperFormat getDataMapFormat(Tag formatName)
                                     throws DSEException
This utility method returns a DataMapperFormat for the supplied format name.
Parameters:
formatName - com.ibm.dse.base.Tag
Returns:
com.ibm.dse.base.DataMapperFormat
Throws:
DSEException -  

getInputFormat

public DataMapperFormat getInputFormat()
Returns the input format attribute of this class.
Returns:
com.ibm.dse.base.DataMapperFormat

getOperation

public Operation getOperation()
Returns the operation attribute of this class.
Returns:
com.ibm.dse.base.Operation

getOutputFormat

public DataMapperFormat getOutputFormat()
Returns the output format attribute of this class.
Returns:
com.ibm.dse.base.DataMapperFormat

handleOperationRepliedEvent

public void handleOperationRepliedEvent(OperationRepliedEvent event)
This method signals the semaphore where the state's activate method is waiting for the operation end. Must get from the event received the name of the event that will be used to change state.
Specified by:
handleOperationRepliedEvent in interface OperationRepliedListener
Parameters:
event - com.ibm.dse.base.OperationRepliedEvent

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEException
Initializes the state of this object from externalized data. This extension will only add the map formats to what the parent method.
Overrides:
initializeFrom in class DSEState
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException -  
DSEException -  

processQueue

protected void processQueue(Vector otherTrigs)
                     throws DSEInvalidArgumentException,
                            DSEProcessorException
This method processes the events queue of the processor; the behaviour is the same than the parent's behaviour, so be careful when doing changes in the parent's activate activate method.
Parameters:
otherTrigs - Vector

readOperation

protected Operation readOperation()
                           throws DSEInvalidArgumentException
Gets the operation from the operation name, stored in the typeIdInfo state's attribute.
Parameters:
operationName - java.lang.String
Returns:
com.ibm.dse.base.Operation
Throws:
DSEInvalidArgumentException - The exception description.

setInputFormat

public void setInputFormat(DataMapperFormat newInputFormat)
Sets the input format attribute of this class.
Parameters:
newInputFormat - com.ibm.dse.base.DataMapperFormat

setOperation

public void setOperation(Operation newOperation)
Sets the input format attribute of this class.
Parameters:
newOperation - com.ibm.dse.base.Operation

setOutputFormat

public void setOutputFormat(DataMapperFormat newOutputFormat)
Sets the output format attribute format.
Parameters:
newOutputFormat - com.ibm.dse.base.DataMapperFormat

signalEvent

protected void signalEvent()
                    throws DSEProcessorException
Creates and signals an event which will be processed by the state itself. This event is built with information got from the event received from the operation. The constructed event will be used to change the state.