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:
@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 on the button .
The code generated for you is the following:
package com.ibm.btt.application.op; import com.ibm.btt.base.BTTServerOperation; /** * Class Generated by BTT 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, you should 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 BTT 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 { } }
The Operation state is represented in the statechart diagram by the following node: