An operation state is a state in a transaction flow that is bound to an operation. To be able to navigate from an operation state to another state, the operation state should identify which are the events that may occur during the operation execution. These events become part of the operation state properties.
There are three ways to find out the events that should be part of the operation state definition:
▪ If the associated operation is an operation already available in your UDTT project, it is recommended that the technical developers add an annotation to the Java class that implements the operation to identify the events triggered by this operation. For example, if the operation triggers the events ‘ok’ and ‘error’, the annotation should be:
@EVENT({"ok","error"})
This way, when the operation state associated to this operation is created, the events panel is automatically populated with these two events and marked with a green arrow, meaning that the events have been populated directly from the operation and then cannot be deleted, although other events may be added manually.
Otherwise, the events are marked with a blue arrow.
The advantage of using the EVENT annotation is that whenever the operation events change, this is automatically reflected in the operation state. You can synchronize the operation state events information with the operation by clicking the button.
▪ You may create your own self-defined operation while creating the flow by going to the Operation tab in the Transaction Editor. Once you have provided the package and class name, you get into the operation editor panel, from where you can start coding your operation by clicking the ImplClass label.
The code generated is the following:
package com.ibm.btt.application.op; import com.ibm.btt.base.BTTServerOperation; /** * Class Generated by UDTT Tool * Created since: 2011/11/08 11:03:37 */ public class sampleOperation extends BTTServerOperation { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> */ public void execute() throws Exception { } }
To identify the events that will be generated by the operation, add the EVENT annotation before the execute() method, as shown in the following example for events ‘ok’ and ‘error’
package com.ibm.btt.application.op; import com.ibm.btt.base.BTTServerOperation; /** * Class Generated by UDTT Tool * Created since: 2011/11/08 11:03:37 */ public class sampleOperation extends BTTServerOperation { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> */ @EVENT({"ok","error"}) public void execute() throws Exception { } }
▪ If no event annotation has been added to the operation code, the technical developers should tell you (if you are not implementing the operation) what are the events that can be expected as a result of the operation execution and then they can be added manually as part of the operation state definition. The Add and Remove buttons are both enabled and the events added using this panel appear with a blue arrow.
The Operation state is represented in the statechart diagram by the following node: