Type alias because traits cannot have companion objects.
Type alias because traits cannot have companion objects.
Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler.
Changes the Actor's behavior to become the new 'Receive' (PartialFunction[Any, Unit]) handler. Puts the behavior on top of the hotswap stack. If "discardOld" is true, an unbecome will be issued prior to pushing the new behavior to the stack
Holds RTTI (runtime type information) for the TypedActor, f.
Holds RTTI (runtime type information) for the TypedActor, f.e. current 'sender' reference, the 'senderFuture' reference etc.
This class does not contain static information but is updated by the runtime system at runtime.
You can get a hold of the context using the 'context()' method from the 'TypedActor' base class.
Here is an example of usage (in Java):
class PingImpl extends TypedActor implements Ping { public void hit(int count) { Pong pong = (Pong) context().sender(); pong.hit(count++); } }
Here is an example of usage (in Scala):
class PingImpl extends TypedActor with Ping { def hit(count: Int) = { val pong = context.sender.asInstanceOf[Pong] pong.hit(count += 1) } }
User overridable callback.
User overridable callback.
Is called on the crashed Actor to give it the option of producing the Actor's reincarnation. If it returns None, which is the default, the initially provided actor factory is used.
Warning: Propagating state from a crashed actor carries the risk of proliferating the cause of the error. Consider let-it-crash first.
This method is used to resolve the Future for TypedActor methods that are defined to return a
akka.actor.dispatch.Future
.
This method is used to resolve the Future for TypedActor methods that are defined to return a
akka.actor.dispatch.Future
.
Here is an example:
class MyTypedActorImpl extends TypedActor implements MyTypedActor { public Futuresquare(int x) { return future(x * x); } } MyTypedActor actor = TypedActor.actorOf(MyTypedActor.class, MyTypedActorImpl.class); // This method will return immediately when called, caller should wait on the Future for the result Future future = actor.square(10); future.await(); Integer result = future.get();
Is the actor able to handle the message passed in as arguments?
Is the actor able to handle the message passed in as arguments?
Option[ActorRef] representation of the 'self' ActorRef reference.
Option[ActorRef] representation of the 'self' ActorRef reference.
Mainly for internal use, functions as the implicit sender references when invoking one of the message send functions ('!', '!!' and '!!!').
User overridable callback.
User overridable callback.
Is called right AFTER restart on the newly created Actor to allow reinitialization after an Actor crash.
User overridable callback.
User overridable callback.
Is called when 'actor.stop()' is invoked.
User overridable callback.
User overridable callback.
Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated.
User overridable callback.
User overridable callback.
Is called on a crashed Actor right BEFORE it is restarted to allow clean up of resources before Actor is terminated. Override either the variant with or without the currentMessage argument.
User overridable callback.
User overridable callback.
Is called when an Actor is started by invoking 'actor.start()'.
User overridable callback/setting.
User overridable callback/setting.
Partial function implementing the actor logic. To be implemented by concrete actor class.
Example code:
def receive = { case Ping => println("got a 'Ping' message") self.reply("pong") case OneWay => println("got a 'OneWay' message") case unknown => println("unknown message: " + unknown) }
The 'self' field holds the ActorRef for this actor.
The 'self' field holds the ActorRef for this actor.
Can be used to send messages to itself:
self ! messageHere you also find most of the Actor API.
For example fields like:
self.dispatcher = ... self.trapExit = ... self.faultHandler = ... self.lifeCycle = ... self.sender
Here you also find methods like:
self.reply(..) self.link(..) self.unlink(..) self.start(..) self.stop(..)
Some[ActorRef] representation of the 'self' ActorRef reference.
Some[ActorRef] representation of the 'self' ActorRef reference.
Mainly for internal use, functions as the implicit sender references when invoking the 'forward' function.
Reverts the Actor behavior to the previous one in the hotswap stack.
Reverts the Actor behavior to the previous one in the hotswap stack.
User overridable callback.
User overridable callback.
Is called when a message isn't handled by the current behavior of the actor by default it throws an UnhandledMessageException
'getContext()' is deprecated use 'context()'
TypedActor is a type-safe actor made out of a POJO with interface. Void methods are turned into fire-forget messages. Non-void methods are turned into request-reply messages with the exception of methods returning a 'Future' which will be sent using request-reply-with-future semantics and need to return the result using the 'future(..)' method: 'return future(... future result ...);'. Methods returning akka.japi.Option will block until a timeout expires, if the implementation of the method returns "none", some(null) will be returned, "none" will only be returned when the method didn't respond within the timeout.
Here is an example of usage (in Java):
Here is an example of usage (in Scala):