public abstract class AbstractActor extends java.lang.Object implements Actor
Actor base class that should be extended to create Java actors that use lambdas.
Example:public class MyActor extends AbstractActor { int count = 0; public MyActor() { receive(ReceiveBuilder. match(Double.class, d -> { sender().tell(d.isNaN() ? 0 : d, self()); }). match(Integer.class, i -> { sender().tell(i * 10, self()); }). match(String.class, s -> s.startsWith("foo"), s -> { sender().tell(s.toUpperCase(), self()); }).build() ); } }
This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.
Actor.emptyBehavior$, Actor.ignoringBehavior$
Constructor and Description |
---|
AbstractActor() |
Modifier and Type | Method and Description |
---|---|
protected abstract static void |
akka$actor$Actor$_setter_$context_$eq(ActorContext x$1) |
protected abstract static void |
akka$actor$Actor$_setter_$self_$eq(ActorRef x$1) |
protected static void |
aroundPostRestart(java.lang.Throwable reason) |
protected static void |
aroundPostStop() |
protected static void |
aroundPreRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
protected static void |
aroundPreStart() |
protected static void |
aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
java.lang.Object msg) |
ActorContext |
context()
Stores the context for this actor, including self, and sender.
|
static Actor.emptyBehavior$ |
emptyBehavior()
emptyBehavior is a Receive-expression that matches no messages at all, ever.
|
AbstractActorContext |
getContext()
Returns this AbstractActor's AbstractActorContext
The AbstractActorContext is not thread safe so do not expose it outside of the
AbstractActor.
|
static void |
postRestart(java.lang.Throwable reason) |
static void |
postStop() |
static void |
preRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
static void |
preStart() |
scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive()
This defines the initial actor behavior, it must return a partial function
with the actor logic.
|
protected void |
receive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive)
Set up the initial receive behavior of the Actor.
|
ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
static ActorRef |
sender() |
static SupervisorStrategy |
supervisorStrategy() |
static void |
unhandled(java.lang.Object message) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, postStop, preRestart, preStart, sender, supervisorStrategy, unhandled
public static final Actor.emptyBehavior$ emptyBehavior()
public static final ActorRef sender()
protected static void aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive, java.lang.Object msg)
protected static void aroundPreStart()
protected static void aroundPostStop()
protected static void aroundPreRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message)
protected static void aroundPostRestart(java.lang.Throwable reason)
public static SupervisorStrategy supervisorStrategy()
public static void preStart() throws java.lang.Exception
java.lang.Exception
public static void postStop() throws java.lang.Exception
java.lang.Exception
public static void preRestart(java.lang.Throwable reason, scala.Option<java.lang.Object> message) throws java.lang.Exception
java.lang.Exception
public static void postRestart(java.lang.Throwable reason) throws java.lang.Exception
java.lang.Exception
public static void unhandled(java.lang.Object message)
protected abstract static void akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
protected abstract static void akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
public ActorContext context()
Actor
forward
.
WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
ActorContext
is the Scala API. getContext
returns a
UntypedActorContext
, which is the Java API of the actor
context.
public final ActorRef self()
Actor
self ! message
protected void receive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive) throws IllegalActorStateException
receive
- The receive behavior.IllegalActorStateException
public AbstractActorContext getContext()