akka.actor
Interface ActorRefFactory

All Known Subinterfaces:
ActorContext, UntypedActorContext
All Known Implementing Classes:
ActorSystem, ExtendedActorSystem

public interface ActorRefFactory

Interface implemented by ActorSystem and ActorContext, the only two places from which you can get fresh actors.


Method Summary
 ActorRef actorFor(ActorPath path)
          Look-up an actor by path; if it does not exist, returns a reference to the dead-letter mailbox of the ActorSystem.
 ActorRef actorFor(scala.collection.Iterable<java.lang.String> path)
          Look-up an actor by applying the given path elements, starting from the current context, where ".." signifies the parent of an actor.
 ActorRef actorFor(java.lang.Iterable<java.lang.String> path)
          Java API: Look-up an actor by applying the given path elements, starting from the current context, where ".." signifies the parent of an actor.
 ActorRef actorFor(java.lang.String path)
          Look-up an actor by path represented as string.
 ActorRef actorOf(Props props)
          Create new actor as child of this context and give it an automatically generated name (currently similar to base64-encoded integer count, reversed and with “$” prepended, may change in the future).
 ActorRef actorOf(Props props, java.lang.String name)
          Create new actor as child of this context with the given name, which must not be null, empty or start with “$”.
 ActorSelection actorSelection(ActorPath path)
          Construct an ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally).
 ActorSelection actorSelection(java.lang.String path)
          Construct an ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally).
 scala.concurrent.ExecutionContext dispatcher()
          Returns the default MessageDispatcher associated with this ActorRefFactory
 akka.actor.InternalActorRef guardian()
          Father of all children created by this interface.
 akka.actor.InternalActorRef lookupRoot()
          INTERNAL API
 ActorRefProvider provider()
          INTERNAL API
 void stop(ActorRef actor)
          Stop the actor pointed to by the given ActorRef; this is an asynchronous operation, i.e.
 akka.actor.ActorSystemImpl systemImpl()
          INTERNAL API
 

Method Detail

systemImpl

akka.actor.ActorSystemImpl systemImpl()
INTERNAL API


provider

ActorRefProvider provider()
INTERNAL API


dispatcher

scala.concurrent.ExecutionContext dispatcher()
Returns the default MessageDispatcher associated with this ActorRefFactory


guardian

akka.actor.InternalActorRef guardian()
Father of all children created by this interface.

INTERNAL API


lookupRoot

akka.actor.InternalActorRef lookupRoot()
INTERNAL API


actorOf

ActorRef actorOf(Props props)
Create new actor as child of this context and give it an automatically generated name (currently similar to base64-encoded integer count, reversed and with “$” prepended, may change in the future).

See Props for details on how to obtain a Props object.

Throws:
ConfigurationException - if deployment, dispatcher or mailbox configuration is wrong

actorOf

ActorRef actorOf(Props props,
                 java.lang.String name)
Create new actor as child of this context with the given name, which must not be null, empty or start with “$”. If the given name is already in use, and InvalidActorNameException is thrown.

See Props for details on how to obtain a Props object.

Throws:
InvalidActorNameException - if the given name is invalid or already in use
ConfigurationException - if deployment, dispatcher or mailbox configuration is wrong

actorFor

ActorRef actorFor(ActorPath path)
Look-up an actor by path; if it does not exist, returns a reference to the dead-letter mailbox of the ActorSystem. If the path point to an actor which is not local, no attempt is made during this call to verify that the actor it represents does exist or is alive; use watch(ref) to be notified of the target’s termination, which is also signaled if the queried path cannot be resolved.


actorFor

ActorRef actorFor(java.lang.String path)
Look-up an actor by path represented as string.

Absolute URIs like akka://appname/user/actorA are looked up as described for look-ups by actorOf(ActorPath).

Relative URIs like /service/actorA/childB are looked up relative to the root path of the ActorSystem containing this factory and as described for look-ups by actorOf(Iterable[String]).

Relative URIs like myChild/grandChild or ../myBrother are looked up relative to the current context as described for look-ups by actorOf(Iterable[String])


actorFor

ActorRef actorFor(scala.collection.Iterable<java.lang.String> path)
Look-up an actor by applying the given path elements, starting from the current context, where ".." signifies the parent of an actor.

Example:


 class MyActor extends Actor {
   def receive = {
     case msg =>
       ...
       val target = context.actorFor(Seq("..", "myBrother", "myNephew"))
       ...
   }
 }
 

For maximum performance use a collection with efficient head & tail operations.


actorFor

ActorRef actorFor(java.lang.Iterable<java.lang.String> path)
Java API: Look-up an actor by applying the given path elements, starting from the current context, where ".." signifies the parent of an actor.

Example:


 public class MyActor extends UntypedActor {
   public void onReceive(Object msg) throws Exception {
     ...
     final List<String> path = new ArrayList<String>();
     path.add("..");
     path.add("myBrother");
     path.add("myNephew");
     final ActorRef target = getContext().actorFor(path);
     ...
   }
 }
 

For maximum performance use a collection with efficient head & tail operations.


actorSelection

ActorSelection actorSelection(java.lang.String path)
Construct an ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally). No attempt is made to verify the existence of any part of the supplied path, it is recommended to send a message and gather the replies in order to resolve the matching set of actors.


actorSelection

ActorSelection actorSelection(ActorPath path)
Construct an ActorSelection from the given path, which is parsed for wildcards (these are replaced by regular expressions internally). No attempt is made to verify the existence of any part of the supplied path, it is recommended to send a message and gather the replies in order to resolve the matching set of actors.


stop

void stop(ActorRef actor)
Stop the actor pointed to by the given ActorRef; this is an asynchronous operation, i.e. involves a message send.