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$| Constructor and Description |
|---|
AbstractActor() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, postStop, preRestart, preStart, self, sender, supervisorStrategy, unhandledpublic static final Actor.emptyBehavior$ emptyBehavior()
protected void receive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive)
receive - The receive behavior.public AbstractActorContext getContext()