public abstract class Behavior<T>
extends java.lang.Object
ActorRef signature, or it may be a system
Signal that expresses a lifecycle event of either this actor or one of
its child actors.
Behaviors can be formulated in a number of different ways, either by
creating a derived class or by employing factory methods like the ones
in the ScalaDSL$ object.
| Modifier and Type | Class and Description |
|---|---|
static class |
Behavior.emptyBehavior$
INTERNAL API.
|
static class |
Behavior.ignoreBehavior$
INTERNAL API.
|
static class |
Behavior.sameBehavior$
INTERNAL API.
|
static class |
Behavior.stoppedBehavior$
INTERNAL API.
|
static class |
Behavior.unhandledBehavior$
INTERNAL API.
|
| Constructor and Description |
|---|
Behavior() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Behavior<T> |
canonicalize(Behavior<T> behavior,
Behavior<T> current)
Given a possibly special behavior (same or unhandled) and a
“current” behavior (which defines the meaning of encountering a
Same
behavior) this method unwraps the behavior such that the innermost behavior
is returned, i.e. |
static <T> boolean |
isAlive(Behavior<T> behavior) |
static <T> boolean |
isUnhandled(Behavior<T> behavior) |
abstract Behavior<T> |
management(ActorContext<T> ctx,
Signal msg)
Process an incoming
Signal and return the next behavior. |
abstract Behavior<T> |
message(ActorContext<T> ctx,
T msg)
Process an incoming message and return the next behavior.
|
<U extends T> |
narrow()
Narrow the type of this Behavior, which is always a safe operation.
|
static <T> Behavior<T> |
preStart(Behavior<T> behavior,
ActorContext<T> ctx) |
static <T> Behavior<T> |
validateAsInitial(Behavior<T> behavior) |
public static <T> Behavior<T> canonicalize(Behavior<T> behavior, Behavior<T> current)
Same
behavior) this method unwraps the behavior such that the innermost behavior
is returned, i.e. it removes the decorations.behavior - (undocumented)current - (undocumented)public static <T> Behavior<T> preStart(Behavior<T> behavior, ActorContext<T> ctx)
public static <T> boolean isAlive(Behavior<T> behavior)
public static <T> boolean isUnhandled(Behavior<T> behavior)
public abstract Behavior<T> management(ActorContext<T> ctx, Signal msg)
Signal and return the next behavior. This means
that all lifecycle hooks, ReceiveTimeout, Terminated and Failed messages
can initiate a behavior change.
The returned behavior can in addition to normal behaviors be one of the canned special objects:
* returning Stopped will terminate this Behavior
* returning Same designates to reuse the current Behavior
* returning Unhandled keeps the same Behavior and signals that the message was not yet handled
Code calling this method should use Behavior$ canonicalize to replace
the special objects with real Behaviors.
ctx - (undocumented)msg - (undocumented)public abstract Behavior<T> message(ActorContext<T> ctx, T msg)
The returned behavior can in addition to normal behaviors be one of the canned special objects:
* returning Stopped will terminate this Behavior
* returning Same designates to reuse the current Behavior
* returning Unhandled keeps the same Behavior and signals that the message was not yet handled
Code calling this method should use Behavior$ canonicalize to replace
the special objects with real Behaviors.
ctx - (undocumented)msg - (undocumented)