IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.automaton.ext
Class DSEOperationState

java.lang.Object
  extended by com.ibm.btt.base.DSEHandler
      extended by com.ibm.btt.automaton.DSEState
          extended by com.ibm.btt.automaton.ext.DSEOperationState
All Implemented Interfaces:
State, Handler, OperationRepliedListener, java.io.Externalizable, java.io.Serializable, java.util.EventListener
Direct Known Subclasses:
DSESyncProcState

public class DSEOperationState
extends DSEState
implements OperationRepliedListener

This class is an extension of the DSEState. It implements a state that is related to an operation. When the operation state is reached, the Automaton looks for the associated operation (which is defined in the typeIdInfo attribute) chains it to the appropriate context, and executes it.

The operation has the responsibility of firing an event when it ends. This event contains a parameter named "dse_exitEventName". This parameter contains the name of the event that the state machine uses 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 in which the operation stores the name of the event that the automaton uses to go on with the flow.
 Tag inputFormatTag
          Map format used to map data from the calling processor context to the context of the operation/processor that this state executes.
protected  Operation operation
          Operation which this state will execute.
protected  Semaphore operationRepliedSemaphore
          Semaphore where the execution waits until the operation raises an operationRepliedEvent.
 Tag outputFormatTag
          Map format used to map data from the context of the operation/processor that this state executes to the calling processor context.
 
Fields inherited from class com.ibm.btt.automaton.DSEState
ABORT_PROCESS, actionHandlers, CHANGE_STATE, CONDITIONS, CONTINUE, DEFAULT_TYPE, done, ENTRY_ACTIONS, entryActionsTags, EXECUTE_ACTION_AND_CHANGESTATE, EXIT_ACTIONS, 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, TRANSITIONS, type, TYPE, TYPE_ID_INFO, typeIdInfo
 
Constructor Summary
DSEOperationState()
           
 
Method Summary
 void activate()
          Activates an operation state.
 boolean chainOrAssignContext(Operation theOperation)
          Verifies whether the operation has a context.
protected  void changeProcessorState(DSEEventObject event)
          This utility method is used to change the state of a processor in response to a change state event.
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  void fireDSEChangeStateEvent(java.lang.String targetStateName, boolean ignoreEntryActionsFlag, boolean ignoreExitActionsFlag, java.lang.String transitionName)
          Dispatches a change state event with required information.
 Tag getInputFormatTag()
          Returns the input format tag attribute of this class.
 Operation getOperation()
          Returns the operation attribute of this class.
 Tag getOutputFormatTag()
          Returns the output format tag attribute of this class.
 void handleOperationRepliedEvent(OperationRepliedEvent event)
          Signals the semaphore when 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 processEventQueue(Vector otherTrigs)
          Provides an internal routine for the activate() method.
protected  void processQueue(Vector otherTrigs)
          Processes the events queue of the processor.
protected  Operation readOperation()
          Gets the operation from the operation name stored in the typeIdInfo state's attribute.
 void setInputFormatTag(Tag newInputFormatTag)
          Sets the input format tag property.
 void setOperation(Operation newOperation)
          Sets the input format property.
 void setOutputFormatTag(Tag newOutputFormatTag)
          Sets the output format tag property.
protected  void signalEvent()
          Creates and signals the event that the state processes.
 
Methods inherited from class com.ibm.btt.automaton.DSEState
abort, addHandlersForAction, dispatchEvent, doEntryActions, doExitActions, externalizer, fireDSEChangeStateEvent, fireDSEChangeStateEvent, fireDSEChangeStateEvent, getEntryActions, getExitActions, getGuardConditionResult, getInstanceOfAction, getName, getProcessor, getTag, getTransitions, getType, getTypeIdInfo, isIgnoreEntryActions, isRunningModeFlag, 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.btt.base.DSEHandler
handleEvent, handleEvent, stopHandlingEvent, stopHandlingEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.btt.base.Handler
handleEvent, handleEvent, stopHandlingEvent, stopHandlingEvent
 

Field Detail

operationRepliedSemaphore

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


EXIT_EVENT_NAME

public static final java.lang.String EXIT_EVENT_NAME
Name of the parameter in which the operation stores the name of the event that the automaton uses to go on with the flow. This parameter is passed within the operationRepliedEvent.

See Also:
Constant Field Values

inputFormatTag

public Tag inputFormatTag
Map format used to map data from the calling processor context to the context of the operation/processor that this state executes.


outputFormatTag

public Tag outputFormatTag
Map format used to map data from the context of the operation/processor that 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 listens for it. The event raised from the operation must contain event information that is used to change the state.

This method waits until this event is received. It then tries to raise the event created from the information received from the operation. The state processes this event and put it on the queue. Processing the event queue provokes a state change.

Specified by:
activate in interface State
Overrides:
activate in class DSEState
Throws:
DSEInvalidArgumentException
DSEProcessorException

chainOrAssignContext

public boolean chainOrAssignContext(Operation theOperation)
                             throws DSEProcessorException
Verifies whether the operation has a context. If it does not, this method assigns the context identified the linkContextTo property. If the operation already has a context, this method chains the operation context to the linkContextTo context. If the method assigns the context, this method returns true.

Parameters:
thisOp - com.ibm.btt.base.Operation
contextName - java.lang.String
Returns:
boolean - True if the context was assigned
Throws:
DSEProcessorException

changeProcessorState

protected void changeProcessorState(DSEEventObject event)
                             throws DSEProcessorException
This utility method is used to change the state of a processor in response to a change state event. It extracts required information from the event object and uses this information to change state.

Parameters:
event - com.ibm.btt.base.DSEEventObject
Throws:
DSEProcessorException

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.btt.base.DataMapperFormat
sourceCtx - com.ibm.btt.base.Context
targetCtx - com.ibm.btt.base.Context
Throws:
DSEException

fireDSEChangeStateEvent

protected void fireDSEChangeStateEvent(java.lang.String targetStateName,
                                       boolean ignoreEntryActionsFlag,
                                       boolean ignoreExitActionsFlag,
                                       java.lang.String transitionName)
                                throws DSEProcessorException
Dispatches a change state event with required information.

Parameters:
targetStateName - java.lang.String
ignoreEntryActionsFlag - boolean
ignoreExitActionsFlag - boolean
transitionName - java.lang.String
Throws:
DSEProcessorException

getInputFormatTag

public Tag getInputFormatTag()
Returns the input format tag attribute of this class.

Returns:
com.ibm.btt.base.Tag

getOperation

public Operation getOperation()
Returns the operation attribute of this class.

Returns:
com.ibm.btt.base.Operation

getOutputFormatTag

public Tag getOutputFormatTag()
Returns the output format tag attribute of this class.

Returns:
com.ibm.btt.base.Tag

handleOperationRepliedEvent

public void handleOperationRepliedEvent(OperationRepliedEvent event)
Signals the semaphore when the state's activate method is waiting for the operation end. This method must get the name of the event that will be used to change state from the event received.

Specified by:
handleOperationRepliedEvent in interface OperationRepliedListener
Parameters:
event - com.ibm.btt.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 only adds the map formats to what the parent method does.

Specified by:
initializeFrom in interface State
Overrides:
initializeFrom in class DSEState
Parameters:
aTag - com.ibm.btt.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException
DSEException

processEventQueue

protected void processEventQueue(Vector otherTrigs)
                          throws DSEInvalidArgumentException,
                                 DSEProcessorException
Provides an internal routine for the activate() method. It loops and processes the eventQueue:
  1. Gets an event out of the eventQueue
  2. Checks to see if the event is changeState (if so, executes the change)
  3. Gets the transitions for the event
  4. Loops the actions for those transitions
    1. Instantiates the Action
    2. Chains or assigns its context
    3. Registers the Automaton's interest in events fired by the Action (if there are any events) by adding the current State to its handlerslist
    4. Loops through any conditions the action may have, instantiating and evaluating each condition
    5. Executes the action the loop is on
    6. Removes the handler and event(s) from its list if it registered the Automaton's interest
    7. Unchains its context if it was chained
    8. Closes the action
  5. Lastly, changes to the next state (by adding a "changeState" event to the queue) if there is nothing else to do in this state (that is, no more event/transition pairs to cycle through this method) and there is a targetState specified in the last transition

Overrides:
processEventQueue in class DSEState
Parameters:
otherTrigs - com.ibm.btt.base.Vector
Throws:
DSEInvalidArgumentException
DSEProcessorException

processQueue

protected void processQueue(Vector otherTrigs)
                     throws DSEInvalidArgumentException,
                            DSEProcessorException
Processes the events queue of the processor. The behavior is the same as the parent's behavior so take care when changing the parent's activate method.

Parameters:
otherTrigs - Vector
Throws:
DSEInvalidArgumentException
DSEProcessorException

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.btt.base.Operation
Throws:
DSEInvalidArgumentException - The exception description.

setInputFormatTag

public void setInputFormatTag(Tag newInputFormatTag)
Sets the input format tag property.

Parameters:
newInputFormatTag - com.ibm.btt.base.Tag

setOperation

public void setOperation(Operation newOperation)
Sets the input format property.

Parameters:
newOperation - com.ibm.btt.base.Operation

setOutputFormatTag

public void setOutputFormatTag(Tag newOutputFormatTag)
Sets the output format tag property.

Parameters:
newOutputFormatTag - com.ibm.btt.base.Tag

signalEvent

protected void signalEvent()
                    throws DSEProcessorException
Creates and signals the event that the state processes. This method builds the event from event information received from the operation. The constructed event is used to change the state.

Throws:
DSEProcessorException

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2010