akka.actor
Class AbstractActor

java.lang.Object
  extended by akka.actor.AbstractActor
All Implemented Interfaces:
Actor
Direct Known Subclasses:
AbstractActorWithStash, AbstractActorWithUnboundedStash, AbstractActorWithUnrestrictedStash, AbstractEventsourcedProcessor, AbstractLoggingActor, AbstractProcessor, AbstractView

public abstract class AbstractActor
extends java.lang.Object
implements Actor

Java API: compatible with lambda expressions

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.


Nested Class Summary
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
AbstractActor()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, noSender, postRestart, postStop, preRestart, preStart, self, sender, supervisorStrategy, unhandled
 

Constructor Detail

AbstractActor

public AbstractActor()
Method Detail

emptyBehavior

public static final Actor.emptyBehavior$ emptyBehavior()
emptyBehavior is a Receive-expression that matches no messages at all, ever.


receive

protected void receive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive)
Set up the initial receive behavior of the Actor.

Parameters:
receive - The receive behavior.

getContext

public AbstractActorContext getContext()
Returns this AbstractActor's AbstractActorContext The AbstractActorContext is not thread safe so do not expose it outside of the AbstractActor.


receive

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface: Actor
This defines the initial actor behavior, it must return a partial function with the actor logic.

Specified by:
receive in interface Actor