Command
Action Abstract class
The action abstract class provides a default way to implement command interface. It has two parameters:
▪ ID. It's used to identify the unit when in a complex flow.
▪ Type. It's used to identify the type of Commands. In this toolkit, the following two types are reserved:
▪ entry. It means that it will be executed when enter its parent.
▪ exit. It means its parent should end after this command.
See the following code for example:
public class Journal extends Action<Map<String, Object>,String, Exception>{
public String execute(Map<String, Object>context) throws Exception{
Integer counter = (Integer) context.get("counter");
counter = counter + 1;
context.put("counter", counter);
return "ok";
}
}
It is totally stateless so please follow the stateless model such as do not call any APIs outside execute() etc, it’ll cause unpredictable result.
See also