Class IIActorSystem
- Direct Known Subclasses:
DistributedActorSystem
In order to use ActorRef from an interpreter,
it must have an interface that can call methods by their name strings.
The IIActorRef class exists for this purpose.
This IIActorSystem is a subclass of ActorSystem with the function of managing IIActorRef.
The IIActorSystem can manage ordinary ActorRefs as well as the IIActorRefs,
so the two can be used intermixed in a program.
The following methods have been added to manage IIActorRef objects:
-
addIIActor -
getIIActor -
hasIIActor -
removeIIActor -
terminateIIActors
- Author:
- devteam@scivicslab.com
-
Nested Class Summary
Nested classes/interfaces inherited from class com.scivicslab.pojoactor.core.ActorSystem
ActorSystem.Builder -
Field Summary
Fields inherited from class com.scivicslab.pojoactor.core.ActorSystem
actors, systemName, workerPools -
Constructor Summary
ConstructorsConstructorDescriptionIIActorSystem(String systemName) Constructs a new IIActorSystem with the specified system name.IIActorSystem(String systemName, int threadNum) Constructs a new IIActorSystem with the specified system name and thread count. -
Method Summary
Modifier and TypeMethodDescription<T> IIActorRef<T> addIIActor(IIActorRef<T> actor) Adds an interpreter-interfaced actor to this system as a child of ROOT.<T> IIActorRef<T> getIIActor(String name) Retrieves an interpreter-interfaced actor by name.intReturns the number of interpreter-interfaced actors in this system.getRoot()Returns the ROOT actor of this system.Returns the names of all top-level actors (direct children of ROOT).List<IIActorRef<?>> Returns a list of all top-level actors (direct children of ROOT).booleanhasIIActor(String name) Checks if an interpreter-interfaced actor with the given name exists.Returns the names of all interpreter-interfaced actors in this system.voidremoveIIActor(String name) Removes an interpreter-interfaced actor from this system.List<IIActorRef<?>> resolveActorPath(String fromActorName, String actorPath) Resolves an actor path relative to a given actor using Unix-style path notation.voidTerminates all interpreter-interfaced actors managed by this system.Methods inherited from class com.scivicslab.pojoactor.core.ActorSystem
actorOf, addActor, addActor, addActor, addManagedThreadPool, addWorkStealingPool, getActor, getLogger, getManagedThreadPool, getManagedThreadPool, getWorkStealingPool, getWorkStealingPool, hasActor, initLogger, isAlive, isAlive, removeActor, root, setLogger, terminate, toString
-
Constructor Details
-
IIActorSystem
Constructs a new IIActorSystem with the specified system name.A ROOT actor is automatically created as the top-level parent for all user actors.
- Parameters:
systemName- the name of this actor system
-
IIActorSystem
Constructs a new IIActorSystem with the specified system name and thread count.A ROOT actor is automatically created as the top-level parent for all user actors.
- Parameters:
systemName- the name of this actor systemthreadNum- the number of threads in the worker pool
-
-
Method Details
-
addIIActor
Adds an interpreter-interfaced actor to this system as a child of ROOT.The actor is automatically added as a child of the ROOT actor, establishing the parent-child relationship in the actor tree.
If the actor already has a parent set, it is added to the system without modifying the parent-child relationship.
- Type Parameters:
T- the type of the actor object- Parameters:
actor- the actor reference to add- Returns:
- the added actor reference
-
getIIActor
Retrieves an interpreter-interfaced actor by name.- Type Parameters:
T- the type of the actor object- Parameters:
name- the name of the actor to retrieve- Returns:
- the actor reference, or
nullif not found
-
hasIIActor
Checks if an interpreter-interfaced actor with the given name exists.- Parameters:
name- the name of the actor to check- Returns:
trueif the actor exists,falseotherwise
-
removeIIActor
Removes an interpreter-interfaced actor from this system.If the actor is a direct child of ROOT, it is also removed from ROOT's children list.
- Parameters:
name- the name of the actor to remove
-
getIIActorCount
public int getIIActorCount()Returns the number of interpreter-interfaced actors in this system.- Returns:
- the count of IIActorRef instances
-
getRoot
Returns the ROOT actor of this system.The ROOT actor is the top-level parent for all user-created actors. Use
getRoot().getNamesOfChildren()to get the names of all top-level actors.- Returns:
- the ROOT actor
- Since:
- 2.12.0
-
getTopLevelActors
Returns a list of all top-level actors (direct children of ROOT).This is a convenience method equivalent to:
getRoot().getNamesOfChildren().stream() .map(this::getIIActor) .collect(Collectors.toList());- Returns:
- list of top-level actor references
- Since:
- 2.12.0
-
getTopLevelActorNames
Returns the names of all top-level actors (direct children of ROOT).- Returns:
- set of top-level actor names
- Since:
- 2.12.0
-
listActorNames
Returns the names of all interpreter-interfaced actors in this system.This method overrides the base class method to return IIActorRef names instead of regular ActorRef names.
- Overrides:
listActorNamesin classActorSystem- Returns:
- a list of actor names
- Since:
- 2.9.0
-
terminateIIActors
public void terminateIIActors()Terminates all interpreter-interfaced actors managed by this system.This method closes all registered IIActorRef instances, releasing their associated resources.
-
resolveActorPath
Resolves an actor path relative to a given actor using Unix-style path notation.Supports the following path formats:
.orthis- self (the actor specified by fromActorName)..- parent actor./*- all children of self../*- all siblings (all children of parent)../sibling- specific sibling by name../web*- siblings whose names start with "web"../*server- siblings whose names end with "server"./child*- children whose names start with "child"
Wildcard patterns:
*- matches all actors in the scopeprefix*- matches actors whose names start with "prefix"*suffix- matches actors whose names end with "suffix"*middle*- matches actors whose names contain "middle"
- Parameters:
fromActorName- the name of the actor from which the path is relativeactorPath- Unix-style path (e.g., ".", "this", "..", "../sibling", "../web*")- Returns:
- list of matching actors (empty list if no matches found)
- Throws:
IllegalArgumentException- if fromActorName does not exist or path is invalid- Since:
- 2.6.0
-