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()
          Deprecated. use Props.create(clazz, args ...) instead
Props(java.lang.Class<? extends Actor> actorClass)
          Deprecated. use Props.create(clazz) instead; deprecated since it duplicates another API
Props(Deploy deploy, java.lang.Class<?> clazz, scala.collection.immutable.Seq<java.lang.Object> args)
           
Props(UntypedActorFactory factory)
          Deprecated. use Props.create(clazz, args ...) instead; this method has been deprecated because it encourages creating Props which contain non-serializable inner classes, making them also non-serializable
 
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 Props apply(Creator<? extends Actor> creator)
          Returns a Props that has default values except for "creator" which will be a function that creates an instance using the supplied thunk.
protected static Props apply(scala.Function0<Actor> creator)
          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.
static Props apply(scala.Function0<Actor> creator, java.lang.String dispatcher, RouterConfig routerConfig, Deploy deploy)
          The deprecated legacy 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(Creator<T> creator)
          Create new Props from the given Creator.
 scala.Function0<Actor> 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.
static scala.Option<scala.Tuple4<scala.Function0<Actor>,java.lang.String,RouterConfig,Deploy>> unapply(Props p, int dummy)
          The deprecated legacy extractor.
 Props withCreator(java.lang.Class<? extends Actor> c)
          Deprecated. use Props.create(clazz) instead; deprecated since it duplicates another API
 Props withCreator(Creator<Actor> c)
          Deprecated. use Props.create(clazz, args ...) instead; this method has been deprecated because it encourages creating Props which contain non-serializable inner classes, making them also non-serializable
 Props withCreator(scala.Function0<Actor> c)
          Scala API: Returns a new Props with the specified creator set.
 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)

Props

public Props()
Deprecated. use Props.create(clazz, args ...) instead

No-args constructor that sets all the default values.


Props

public Props(UntypedActorFactory factory)
Deprecated. use Props.create(clazz, args ...) instead; this method has been deprecated because it encourages creating Props which contain non-serializable inner classes, making them also non-serializable

Java API: create Props from an UntypedActorFactory


Props

public Props(java.lang.Class<? extends Actor> actorClass)
Deprecated. use Props.create(clazz) instead; deprecated since it duplicates another API

Java API: create Props from a given Class

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

protected static Props apply(scala.Function0<Actor> creator)
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.


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(Creator<? extends Actor> creator)
Returns a Props that has default values except for "creator" which will be a function that creates an instance using the supplied thunk.


apply

public static Props apply(scala.Function0<Actor> creator,
                          java.lang.String dispatcher,
                          RouterConfig routerConfig,
                          Deploy deploy)
The deprecated legacy constructor.


unapply

public static scala.Option<scala.Tuple4<scala.Function0<Actor>,java.lang.String,RouterConfig,Deploy>> unapply(Props p,
                                                                                                              int dummy)
The deprecated legacy extractor.


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.


deploy

public Deploy deploy()

clazz

public java.lang.Object clazz()

args

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

creator

public scala.Function0<Actor> creator()

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.


withCreator

public Props withCreator(scala.Function0<Actor> c)
Scala API: Returns a new Props with the specified creator set.

The creator must not return the same instance multiple times.


withCreator

public Props withCreator(Creator<Actor> c)
Deprecated. use Props.create(clazz, args ...) instead; this method has been deprecated because it encourages creating Props which contain non-serializable inner classes, making them also non-serializable

Java API: Returns a new Props with the specified creator set.

The creator must not return the same instance multiple times.


withCreator

public Props withCreator(java.lang.Class<? extends Actor> c)
Deprecated. use Props.create(clazz) instead; deprecated since it duplicates another API

Returns a new Props with the specified creator set.


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.