net.ninjacat.drama
Interface ActorSystem

All Known Subinterfaces:
ActorSystemInternal

public interface ActorSystem

Main class of the framework responsible for management of actors.


Method Summary
<T extends Actor>
ActorRef
createActor(Class<T> actorType)
          Creates actor with default name.
<T extends Actor>
ActorRef
createActor(Class<T> actorType, String name)
          Creates actor with supplied name.
<T extends Actor>
ActorRef
createActor(Class<T> actorType, String name, Object... parameters)
          Creates actor with supplied name.
Actor must define a constructor with a list of parameters matching list of this method parameters
 Option<ActorRef> find(String name)
          Searches for an actor by its name
 void stop()
          Stops ActorSystem.
 void stopWithCallback(ActorSystemStopCallback callback)
          Stops ActorSystem.
 

Method Detail

find

Option<ActorRef> find(String name)
Searches for an actor by its name

Parameters:
name - name of the actor to find
Returns:
ActorRef wrapped in Option

createActor

<T extends Actor> ActorRef createActor(Class<T> actorType)
Creates actor with default name.
 

Actor must have default constructor. This actor will not be accessible through find(String) method, so returned reference should be stored and used.

Type Parameters:
T - Class of the actor
Parameters:
actorType - Class of the actor to be created
Returns:
Reference to newly created actor

createActor

<T extends Actor> ActorRef createActor(Class<T> actorType,
                                       String name)
Creates actor with supplied name. Actor must have default constructor

Type Parameters:
T - Class of the actor
Parameters:
actorType - Class of the actor to be created
name - Name of the actor
Returns:
Reference to newly created actor

createActor

<T extends Actor> ActorRef createActor(Class<T> actorType,
                                       String name,
                                       Object... parameters)
Creates actor with supplied name.
Actor must define a constructor with a list of parameters matching list of this method parameters

Type Parameters:
T - Class of the actor
Parameters:
actorType - Class of the actor to be created
name - Name of the actor
parameters - List of parameters to be passed to actor's constructor
Returns:
Reference to newly created actor

stopWithCallback

void stopWithCallback(ActorSystemStopCallback callback)
Stops ActorSystem. Asks all actors to terminate and waits for them. After all actors have terminated will call ActorSystemStopCallback.onStopped() method
Actor system is unusable after this method is called, no new messages should be sent to its actors.

Parameters:
callback - Callback to be called when all actors in the system have terminated

stop

void stop()
Stops ActorSystem. Asks all actors to terminate but don't wait for them.
Actor system is unusable after this method is called, no new messages should be sent to its actors.



Copyright © 2014. All rights reserved.