public class Supervisor extends Behavior
SupervisorActor
.Modifier and Type | Class and Description |
---|---|
static class |
Supervisor.ChildMode
Determines whether a child (supervised) actor should be restarted if the supervisor's
restart strategy
states that it should be restarted. |
static class |
Supervisor.ChildSpec
Describes a child actor's configuration in a supervisor
|
Constructor and Description |
---|
Supervisor(ActorRef<Object> actor)
|
Modifier and Type | Method and Description |
---|---|
<T extends ActorRef<M>,M> |
addChild(Supervisor.ChildSpec spec)
Adds a new child actor to the supervisor.
|
<T extends ActorRef<M>,M> |
getChild(Object id)
Retrieves a child actor by its
id
This method does not block when called from within the Supervisor's context, so, in particular, it may be called by
an actor constructor, constructed by the supervisor. |
List<? extends ActorRef<?>> |
getChildren()
Retrieves the children actor references as an immutable list.
|
boolean |
removeChild(ActorRef<?> actor,
boolean terminate)
Removes a child actor from the supervisor.
|
boolean |
removeChild(Object id,
boolean terminate)
Removes a child actor from the supervisor.
|
String |
toString() |
getImpl, isInActor
public Supervisor(ActorRef<Object> actor)
actor
is known to be a ServerActor
, creates a new Server
interface to it.
Normally, you don't use this constructor, but the Supervisor
instance returned by SupervisorActor.spawn()
.actor
- a ServerActor
public final <T extends ActorRef<M>,M> T addChild(Supervisor.ChildSpec spec) throws SuspendExecution, InterruptedException
spec
- the child's spec
.InterruptedException
SuspendExecution
public final <T extends ActorRef<M>,M> T getChild(Object id) throws SuspendExecution, InterruptedException
id
This method does not block when called from within the Supervisor's context, so, in particular, it may be called by
an actor constructor, constructed by the supervisor.id
- the child's id
in the supervisor.null
if the child was not foundSuspendExecution
InterruptedException
public final List<? extends ActorRef<?>> getChildren() throws SuspendExecution, InterruptedException
ActorRef
s.SuspendExecution
InterruptedException
public final boolean removeChild(Object id, boolean terminate) throws SuspendExecution, InterruptedException
id
- the child's id
in the supervisor.terminate
- whether or not the supervisor should terminate the actortrue
if the actor has been successfully removed from the supervisor; false
if the child was not found.InterruptedException
SuspendExecution
public boolean removeChild(ActorRef<?> actor, boolean terminate) throws SuspendExecution, InterruptedException
actor
- the child actorterminate
- whether or not the supervisor should terminate the actortrue
if the actor has been successfully removed from the supervisor; false
if the child was not found.InterruptedException
SuspendExecution