akka.actor.dsl
Interface Creators.Act

All Superinterfaces:
Actor
All Known Subinterfaces:
Creators.ActWithStash
Enclosing interface:
Creators

public static interface Creators.Act
extends Actor

This trait provides a DSL for writing the inner workings of an actor, e.g. for quickly trying things out in the REPL. It makes the following keywords available:

- become mapped to context.become(_, discardOld = true)

- becomeStacked mapped to context.become(_, discardOld = false)

- unbecome mapped to context.unbecome

- setup for implementing preStart()

- whenFailing for implementing preRestart()

- whenRestarted for implementing postRestart()

- teardown for implementing postStop

Using the life-cycle keywords multiple times results in replacing the content of the respective hook.


Nested Class Summary
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Method Summary
 AllForOneStrategy$ AllForOneStrategy()
           
 void become(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> r)
          Replace the behavior at the top of the behavior stack for this actor.
 void becomeStacked(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> r)
          Add the given behavior on top of the behavior stack for this actor.
 SupervisorStrategy.Escalate$ Escalate()
           
 OneForOneStrategy$ OneForOneStrategy()
           
 void postRestart(java.lang.Throwable cause)
          User overridable callback: By default it calls preStart().
 void postStop()
          User overridable callback.
 void preRestart(java.lang.Throwable cause, scala.Option<java.lang.Object> msg)
          User overridable callback: '''By default it disposes of all children and then calls postStop().'''
 void preStart()
          User overridable callback.
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
          Default behavior of the actor is empty, use become to change this.
 SupervisorStrategy.Restart$ Restart()
           
 SupervisorStrategy.Resume$ Resume()
           
 SupervisorStrategy.Stop$ Stop()
           
 void superviseWith(SupervisorStrategy s)
          Set the supervisor strategy of this actor, i.e. how it supervises its children.
 SupervisorStrategy supervisorStrategy()
          User overridable definition the strategy to use for supervising child actors.
 void unbecome()
          Pop the active behavior from the behavior stack of this actor.
 void whenFailing(scala.Function2<java.lang.Throwable,scala.Option<java.lang.Object>,scala.runtime.BoxedUnit> body)
          Replace the preRestart action with the supplied function.
 void whenRestarted(scala.Function1<java.lang.Throwable,scala.runtime.BoxedUnit> body)
          Replace the postRestart action with the supplied function.
 void whenStarting(scala.Function0<scala.runtime.BoxedUnit> body)
          Replace the preStart action with the supplied thunk.
 void whenStopping(scala.Function0<scala.runtime.BoxedUnit> body)
          Replace the postStop action with the supplied thunk.
 
Methods inherited from interface akka.actor.Actor
context, noSender, self, sender, unhandled
 

Method Detail

OneForOneStrategy

OneForOneStrategy$ OneForOneStrategy()
See Also:
OneForOneStrategy

AllForOneStrategy

AllForOneStrategy$ AllForOneStrategy()
See Also:
AllForOneStrategy

Stop

SupervisorStrategy.Stop$ Stop()
See Also:
SupervisorStrategy

Restart

SupervisorStrategy.Restart$ Restart()
See Also:
SupervisorStrategy

Resume

SupervisorStrategy.Resume$ Resume()
See Also:
SupervisorStrategy

Escalate

SupervisorStrategy.Escalate$ Escalate()
See Also:
SupervisorStrategy

becomeStacked

void becomeStacked(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> r)
Add the given behavior on top of the behavior stack for this actor. This stack is cleared upon restart. Use unbecome() to pop an element off this stack.


become

void become(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> r)
Replace the behavior at the top of the behavior stack for this actor. The stack is cleared upon restart. Use unbecome() to pop an element off this stack or becomeStacked() to push a new element on top of it.


unbecome

void unbecome()
Pop the active behavior from the behavior stack of this actor. This stack is cleared upon restart.


superviseWith

void superviseWith(SupervisorStrategy s)
Set the supervisor strategy of this actor, i.e. how it supervises its children.


whenStarting

void whenStarting(scala.Function0<scala.runtime.BoxedUnit> body)
Replace the preStart action with the supplied thunk. Default action is to call super.preStart()


whenFailing

void whenFailing(scala.Function2<java.lang.Throwable,scala.Option<java.lang.Object>,scala.runtime.BoxedUnit> body)
Replace the preRestart action with the supplied function. Default action is to call super.preRestart(), which will kill all children and invoke postStop().


whenRestarted

void whenRestarted(scala.Function1<java.lang.Throwable,scala.runtime.BoxedUnit> body)
Replace the postRestart action with the supplied function. Default action is to call super.postRestart which will call preStart().


whenStopping

void whenStopping(scala.Function0<scala.runtime.BoxedUnit> body)
Replace the postStop action with the supplied thunk. Default action is to call super.postStop.


preStart

void preStart()
Description copied from interface: Actor
User overridable callback.

Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.

Specified by:
preStart in interface Actor

preRestart

void preRestart(java.lang.Throwable cause,
                scala.Option<java.lang.Object> msg)
Description copied from interface: Actor
User overridable callback: '''By default it disposes of all children and then calls postStop().'''

Specified by:
preRestart in interface Actor
Parameters:
cause - the Throwable that caused the restart to happen
msg - optionally the current message the actor processed when failing, if applicable

Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.


postRestart

void postRestart(java.lang.Throwable cause)
Description copied from interface: Actor
User overridable callback: By default it calls preStart().

Specified by:
postRestart in interface Actor
Parameters:
cause - the Throwable that caused the restart to happen

Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.


postStop

void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor

supervisorStrategy

SupervisorStrategy supervisorStrategy()
Description copied from interface: Actor
User overridable definition the strategy to use for supervising child actors.

Specified by:
supervisorStrategy in interface Actor

receive

scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Default behavior of the actor is empty, use become to change this.

Specified by:
receive in interface Actor