akka.actor
Class Props

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

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

Props is a ActorRef configuration object, that is immutable, so it is thread safe and fully sharable. Used when creating new actors through; ActorSystem.actorOf and ActorContext.actorOf.

In case of providing code which creates the actual Actor instance, that must not return the same instance multiple times.

Examples on Scala API:


  val props = Props[MyActor]
  val props = Props(new MyActor)
  val props = Props(
    creator = ..,
    dispatcher = ..,
    routerConfig = ..
  )
  val props = Props().withCreator(new MyActor)
  val props = Props[MyActor].withRouter(RoundRobinRouter(..))
 

Examples on Java API:


  Props props = new Props();
  Props props = new Props(MyActor.class);
  Props props = new Props(new UntypedActorFactory() {
    public UntypedActor create() {
      return new MyActor();
    }
  });
  Props props = new Props().withCreator(new UntypedActorFactory() { ... });
  Props props = new Props(MyActor.class).withRouter(new RoundRobinRouter(..));
 

See Also:
Serialized Form

Constructor Summary
Props()
          No-args constructor that sets all the default values.
Props(java.lang.Class<? extends Actor> actorClass)
          Java API: create Props from a given Class
Props(scala.Function0<Actor> creator, java.lang.String dispatcher, RouterConfig routerConfig, Deploy deploy)
           
Props(UntypedActorFactory factory)
          Java API: create Props from an UntypedActorFactory
 
Method Summary
static Props apply(java.lang.Class<? extends Actor> actorClass)
          Returns a Props that has default values except for "creator" which will be a function that creates an instance of the supplied class using the default constructor.
static
<T extends Actor>
Props
apply(scala.reflect.ClassTag<T> evidence$1)
          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.
static Props apply(scala.Function0<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.
 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()
           
static Props empty()
          A Props instance whose creator will create an actor that doesn't respond to any message
 RouterConfig routerConfig()
           
 Props withCreator(java.lang.Class<? extends Actor> c)
          Java API: Returns a new Props with the specified creator set.
 Props withCreator(Creator<Actor> c)
          Java API: Returns a new Props with the specified creator set.
 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 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(scala.Function0<Actor> creator,
             java.lang.String dispatcher,
             RouterConfig routerConfig,
             Deploy deploy)

Props

public Props()
No-args constructor that sets all the default values.


Props

public Props(UntypedActorFactory factory)
Java API: create Props from an UntypedActorFactory


Props

public Props(java.lang.Class<? extends Actor> actorClass)
Java API: create Props from a given Class

Method Detail

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)
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.

Scala API.


apply

public static Props apply(java.lang.Class<? extends Actor> actorClass)
Returns a Props that has default values except for "creator" which will be a function that creates an instance of the supplied class using the default constructor.


apply

public static Props apply(scala.Function0<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.

Scala API.


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.


creator

public scala.Function0<Actor> creator()

dispatcher

public java.lang.String dispatcher()

routerConfig

public RouterConfig routerConfig()

deploy

public Deploy deploy()

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)
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)
Java 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.


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.