Package com.scivicslab.pojoactor.core
Annotation Interface Action
Marks a method as callable by action name from workflow YAML.
Methods annotated with @Action are automatically discovered via reflection
and can be invoked through CallableByActionName.callByActionName(String, String).
This enables a mixin-like pattern where common actions can be defined in interfaces
with default methods and shared across multiple actor types.
Usage
Annotate methods that should be callable from workflow YAML:
public class NodeInterpreter extends Interpreter {
@Action("executeCommand")
public ActionResult executeCommand(String args) {
// Implementation
}
}
Mixin Pattern with Interface Default Methods
Define reusable actions in interfaces:
public interface CommandExecutable {
Node getNode(); // Abstract method for implementation to provide
@Action("executeCommand")
default ActionResult executeCommand(String args) {
String cmd = parseFirstArg(args);
return getNode().executeCommand(cmd);
}
}
// Multiple classes can implement the interface to gain the action
public class NodeInterpreter implements CommandExecutable {
private final Node node;
@Override
public Node getNode() { return node; }
}
Method Signature Requirements
Annotated methods must have the following signature:
- Return type:
ActionResult - Parameters: A single
Stringargument (JSON-formatted)
Workflow YAML Example
steps:
- states: ["0", "1"]
actions:
- actor: this
method: executeCommand # Matches @Action("executeCommand")
arguments: ["ls -la"]
GraalVM Native Image
When using GraalVM native image, annotated methods need to be registered
for reflection in reflect-config.json:
[
{
"name": "com.example.MyInterpreter",
"allDeclaredMethods": true,
"allPublicMethods": true
}
]
- Since:
- 2.15.0
- Author:
- devteam@scivicslab.com
- See Also:
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe action name used in workflow YAML to invoke this method.This name is used in the
methodfield of workflow actions. It should be a valid identifier, typically in camelCase format.- Returns:
- the action name
-