Class RootIIAR
- All Implemented Interfaces:
CallableByActionName,AutoCloseable
Root actor for the IIActorSystem hierarchy.
This actor serves as the top-level parent for all user-created actors in the system. Having a ROOT actor provides several benefits:
- Easy enumeration of top-level actors via
getChildren - Unified actor tree traversal starting from a single root
- Clear separation between system infrastructure and user actors
The ROOT actor is automatically created when an IIActorSystem
is instantiated. User actors added via IIActorSystem.addIIActor(com.scivicslab.pojoactor.workflow.IIActorRef<T>)
become children of ROOT.
Actor Tree Structure
IIActorSystem
└── ROOT
├── loader
│ └── analyzer
└── nodeGroup
├── node-192.168.5.13
└── node-192.168.5.14
Available Actions
print- Prints the argument to standard outputlistChildren- Returns names of all top-level actorsgetChildCount- Returns the number of top-level actorsprintTree- Returns ASCII tree representation of actor hierarchy
- Since:
- 2.12.0
- Author:
- devteam@scivicslab.com
-
Field Summary
FieldsFields inherited from class com.scivicslab.pojoactor.core.ActorRef
actorName, actorSystem, object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncallByActionName(String actionName, String args) Invokes an action by name on this actor.Methods inherited from class com.scivicslab.pojoactor.workflow.IIActorRef
hasAnnotatedAction, invokeAnnotatedAction, parseFirstArgumentMethods inherited from class com.scivicslab.pojoactor.core.ActorRef
ask, ask, askNow, clearJsonState, clearPendingMessages, close, createChild, expandVariables, getJsonBoolean, getJsonInt, getJsonString, getJsonString, getLastResult, getName, getNamesOfChildren, getParentName, hasJson, hasJsonState, initLogger, isAlive, json, putJson, setLastResult, setParentName, system, tell, tell, tellNow, toStringOfJson, toStringOfYaml
-
Field Details
-
ROOT_NAME
The name of the root actor.- See Also:
-
-
Constructor Details
-
RootIIAR
Constructs a new RootIIAR.- Parameters:
system- the actor system managing this root actor
-
-
Method Details
-
callByActionName
Description copied from class:IIActorRefInvokes an action by name on this actor.This method uses a three-stage dispatch mechanism:
- @Action annotation: Checks the IIActorRef subclass for methods
annotated with
Actionmatching the action name. This keeps the POJO clean - only the IIActorRef adapter needs workflow-related code. - Built-in JSON State API: Handles putJson, getJson, hasJson, clearJson, and printJson actions.
- Unknown action: Returns failure for unrecognized actions.
DO NOT OVERRIDE THIS METHOD. Use
@Actionannotation on your methods instead. The@Actionannotation provides cleaner, more maintainable code compared to overriding with switch statements.Recommended pattern:
public class MyActor extends IIActorRef<Void> { public MyActor(String name, IIActorSystem system) { super(name, null, system); } @Action("doSomething") public ActionResult doSomething(String args) { // implementation return new ActionResult(true, "done"); } }Deprecated pattern (do not use):
// BAD: Don't override callByActionName with switch statement @Override public ActionResult callByActionName(String actionName, String args) { return switch (actionName) { case "doSomething" -> doSomething(args); default -> super.callByActionName(actionName, args); }; }- Specified by:
callByActionNamein interfaceCallableByActionName- Overrides:
callByActionNamein classIIActorRef<Object>- Parameters:
actionName- the name of the action to invokeargs- the arguments as a JSON string- Returns:
- the result of the action
- @Action annotation: Checks the IIActorRef subclass for methods
annotated with
-