akka.actor
Class Props

java.lang.Object
  extended by akka.actor.Props
All Implemented Interfaces:
java.io.Serializable, scala.Equals, scala.Product

public final class Props
extends java.lang.Object
implements scala.Product, scala.Serializable

Props is a configuration object using in creating an Actor; it is immutable, so it is thread-safe and fully shareable.

Examples on Scala API:


  val props = Props.empty
  val props = Props[MyActor]
  val props = Props(classOf[MyActor], arg1, arg2)

  val otherProps = props.withDispatcher("dispatcher-id")
  val otherProps = props.withDeploy(<deployment info>)
 

Examples on Java API:


  final Props props = Props.empty();
  final Props props = Props.create(MyActor.class, arg1, arg2);

  final Props otherProps = props.withDispatcher("dispatcher-id");
  final Props otherProps = props.withDeploy(<deployment info>);
 

See Also:
Serialized Form

Constructor Summary
Props(Deploy deploy, java.lang.Class<?> clazz, scala.collection.immutable.Seq<java.lang.Object> args)
           
 
Method Summary
 java.lang.Class<? extends Actor> actorClass()
          Obtain an upper-bound approximation of the actor class which is going to be created by these Props.
static Props apply(java.lang.Class<?> clazz, scala.collection.Seq<java.lang.Object> args)
          Scala API: create a Props given a class and its constructor arguments.
static
<T extends Actor>
Props
apply(scala.reflect.ClassTag<T> evidence$1)
          Scala API: Returns a Props that has default values except for "creator" which will be a function that creates an instance of the supplied type using the default constructor.
static
<T extends Actor>
Props
apply(scala.Function0<T> creator, scala.reflect.ClassTag<T> evidence$2)
          Scala API: Returns a Props that has default values except for "creator" which will be a function that creates an instance using the supplied thunk.
 scala.collection.immutable.Seq<java.lang.Object> args()
           
 java.lang.Object clazz()
           
static Props create(java.lang.Class<?> clazz, java.lang.Object... args)
          Java API: create a Props given a class and its constructor arguments.
static Props create(java.lang.Class<?> clazz, scala.collection.Seq<java.lang.Object> args)
          Java API: create a Props given a class and its constructor arguments.
static
<T extends Actor>
Props
create(java.lang.Class<T> actorClass, Creator<T> creator)
          Create new Props from the given Creator with the type set to the given actorClass.
static
<T extends Actor>
Props
create(Creator<T> creator)
          Create new Props from the given Creator.
static scala.Function0<Actor> defaultCreator()
          The defaultCreator, simply throws an UnsupportedOperationException when applied, which is used when creating a Props
static Deploy defaultDeploy()
          The default Deploy instance which is used when creating a Props
static RouterConfig defaultRoutedProps()
          The defaultRoutedProps is NoRouter which is used when creating a Props
 Deploy deploy()
           
 java.lang.String dispatcher()
          Convenience method for extracting the dispatcher information from the contained Deploy instance.
static Props empty()
          A Props instance whose creator will create an actor that doesn't respond to any message
 java.lang.String mailbox()
          Convenience method for extracting the mailbox information from the contained Deploy instance.
 RouterConfig routerConfig()
          Convenience method for extracting the router configuration from the contained Deploy instance.
 Props withDeploy(Deploy d)
          Returns a new Props with the specified deployment configuration.
 Props withDispatcher(java.lang.String d)
          Returns a new Props with the specified dispatcher set.
 Props withMailbox(java.lang.String m)
          Returns a new Props with the specified mailbox set.
 Props withRouter(RouterConfig r)
          Returns a new Props with the specified router config set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface scala.Product
productArity, productElement, productIterator, productPrefix
 
Methods inherited from interface scala.Equals
canEqual, equals
 

Constructor Detail

Props

public Props(Deploy deploy,
             java.lang.Class<?> clazz,
             scala.collection.immutable.Seq<java.lang.Object> args)
Method Detail

create

public static Props create(java.lang.Class<?> clazz,
                           java.lang.Object... args)
Java API: create a Props given a class and its constructor arguments.


defaultCreator

public static final scala.Function0<Actor> defaultCreator()
The defaultCreator, simply throws an UnsupportedOperationException when applied, which is used when creating a Props


defaultRoutedProps

public static final RouterConfig defaultRoutedProps()
The defaultRoutedProps is NoRouter which is used when creating a Props


defaultDeploy

public static final Deploy defaultDeploy()
The default Deploy instance which is used when creating a Props


empty

public static final Props empty()
A Props instance whose creator will create an actor that doesn't respond to any message


apply

public static <T extends Actor> Props apply(scala.reflect.ClassTag<T> evidence$1)
Scala API: Returns a Props that has default values except for "creator" which will be a function that creates an instance of the supplied type using the default constructor.


apply

public static <T extends Actor> Props apply(scala.Function0<T> creator,
                                            scala.reflect.ClassTag<T> evidence$2)
Scala API: Returns a Props that has default values except for "creator" which will be a function that creates an instance using the supplied thunk.

CAVEAT: Required mailbox type cannot be detected when using anonymous mixin composition when creating the instance. For example, the following will not detect the need for DequeBasedMessageQueueSemantics as defined in Stash:


 'Props(new Actor with Stash { ... })
 
Instead you must create a named class that mixin the trait, e.g. class MyActor extends Actor with Stash.


apply

public static Props apply(java.lang.Class<?> clazz,
                          scala.collection.Seq<java.lang.Object> args)
Scala API: create a Props given a class and its constructor arguments.


create

public static Props create(java.lang.Class<?> clazz,
                           scala.collection.Seq<java.lang.Object> args)
Java API: create a Props given a class and its constructor arguments.


create

public static <T extends Actor> Props create(Creator<T> creator)
Create new Props from the given Creator.

You can not use a Java 8 lambda with this method since the generated classes don't carry enough type information.

Use the Props.create(actorClass, creator) instead.


create

public static <T extends Actor> Props create(java.lang.Class<T> actorClass,
                                             Creator<T> creator)
Create new Props from the given Creator with the type set to the given actorClass.


deploy

public Deploy deploy()

clazz

public java.lang.Object clazz()

args

public scala.collection.immutable.Seq<java.lang.Object> args()

dispatcher

public java.lang.String dispatcher()
Convenience method for extracting the dispatcher information from the contained Deploy instance.


mailbox

public java.lang.String mailbox()
Convenience method for extracting the mailbox information from the contained Deploy instance.


routerConfig

public RouterConfig routerConfig()
Convenience method for extracting the router configuration from the contained Deploy instance.


withDispatcher

public Props withDispatcher(java.lang.String d)
Returns a new Props with the specified dispatcher set.


withMailbox

public Props withMailbox(java.lang.String m)
Returns a new Props with the specified mailbox set.


withRouter

public Props withRouter(RouterConfig r)
Returns a new Props with the specified router config set.


withDeploy

public Props withDeploy(Deploy d)
Returns a new Props with the specified deployment configuration.


actorClass

public java.lang.Class<? extends Actor> actorClass()
Obtain an upper-bound approximation of the actor class which is going to be created by these Props. In other words, the actor factory method will produce an instance of this class or a subclass thereof. This is used by the actor system to select special dispatchers or mailboxes in case dependencies are encoded in the actor type.