akka.actor
Class ActorSystemImpl

java.lang.Object
  extended by akka.actor.ActorSystem
      extended by akka.actor.ExtendedActorSystem
          extended by akka.actor.ActorSystemImpl
All Implemented Interfaces:
ActorRefFactory

public class ActorSystemImpl
extends ExtendedActorSystem


Nested Class Summary
 class ActorSystemImpl.TerminationCallbacks
           
 
Nested classes/interfaces inherited from class akka.actor.ActorSystem
ActorSystem.Settings
 
Constructor Summary
ActorSystemImpl(java.lang.String name, com.typesafe.config.Config applicationConfig, java.lang.ClassLoader classLoader, scala.Option<scala.concurrent.ExecutionContext> defaultExecutionContext)
           
 
Method Summary
 void abort()
          This kind of shutdown attempts to bring the system down and release its resources more forcefully than plain shutdown.
 boolean aborting()
           
 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 &ldquo;$&rdquo; 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 &ldquo;$&rdquo;.
 void awaitTermination()
          Block current thread until the system has been shutdown.
 void awaitTermination(scala.concurrent.duration.Duration timeout)
          Block current thread until the system has been shutdown, or the specified timeout has elapsed.
protected  DynamicAccess createDynamicAccess()
          This is an extension point: by overriding this method, subclasses can control all reflection activities of an actor system.
protected  Scheduler createScheduler()
          Create the scheduler service.
 ActorRef deadLetters()
          Actor reference where messages are re-routed to which were addressed to stopped or non-existing actors.
 scala.concurrent.ExecutionContextExecutor dispatcher()
          Default dispatcher as configured.
 Dispatchers dispatchers()
          Helper object for looking up configured dispatchers.
 DynamicAccess dynamicAccess()
          ClassLoader wrapper which is used for reflective accesses internally.
 EventStream eventStream()
          Main event bus of this actor system, used for example for logging.
<T extends Extension>
T
extension(ExtensionId<T> ext)
          Returns the payload that is associated with the provided extension throws an IllegalStateException if it is not registered.
 LocalActorRef guardian()
          The top-level supervisor of all actors created using system.actorOf(...).
 boolean hasExtension(ExtensionId<? extends Extension> ext)
          Returns whether the specified extension is already registered, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution
 scala.concurrent.ExecutionContext internalCallingThreadExecutionContext()
           
 boolean isTerminated()
          Query the termination status: if it returns true, all callbacks have run and the ActorSystem has been fully stopped, i.e.
 LoggingAdapter log()
          Convenient logging adapter for logging to the ActorSystem.eventStream.
 void logConfiguration()
          Log the configuration.
 InternalActorRef lookupRoot()
          INTERNAL API
 Mailboxes mailboxes()
          Helper object for looking up configured mailbox types.
 java.lang.String name()
          The name of this actor system, used to distinguish multiple ones within the same JVM & class loader.
 java.lang.String printTree()
          For debugging: traverse actor hierarchy and make string representation.
 ActorRefProvider provider()
          The ActorRefProvider is the only entity which creates all actor references within this actor system.
<T extends Extension>
T
registerExtension(ExtensionId<T> ext)
          Registers the provided extension and creates its payload, if this extension isn't already registered This method has putIfAbsent-semantics, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution
<T> void
registerOnTermination(scala.Function0<T> code)
          Register a block of code (callback) to run after ActorSystem.shutdown has been issued and all actors in this actor system have been stopped.
 void registerOnTermination(java.lang.Runnable code)
          Java API: Register a block of code (callback) to run after ActorSystem.shutdown has been issued and all actors in this actor system have been stopped.
 Scheduler scheduler()
          Light-weight scheduler for running asynchronous tasks after some deadline in the future.
 ActorSystem.Settings settings()
          The core settings extracted from the supplied configuration.
 void shutdown()
          Stop this actor system.
 ActorSystemImpl start()
           
 void stop(ActorRef actor)
          Stop the actor pointed to by the given ActorRef; this is an asynchronous operation, i.e.
protected  void stopScheduler()
           
 ActorRef systemActorOf(Props props, java.lang.String name)
          Create an actor in the "/system" namespace.
 LocalActorRef systemGuardian()
          The top-level supervisor of all system-internal services like logging.
protected  ActorSystemImpl systemImpl()
          INTERNAL API
 scala.concurrent.Future<scala.runtime.BoxedUnit> terminationFuture()
           
 MonitorableThreadFactory threadFactory()
          A ThreadFactory that can be used if the transport needs to create any Threads
 java.lang.String toString()
           
protected  java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler()
           
 
Methods inherited from class akka.actor.ActorSystem
apply, apply, apply, apply, apply, child, create, create, create, create, create, descendant, EnvHome, findClassLoader, GlobalHome, startTime, SystemHome, uptime, Version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface akka.actor.ActorRefFactory
actorFor, actorFor, actorFor, actorFor, actorSelection, actorSelection
 

Constructor Detail

ActorSystemImpl

public ActorSystemImpl(java.lang.String name,
                       com.typesafe.config.Config applicationConfig,
                       java.lang.ClassLoader classLoader,
                       scala.Option<scala.concurrent.ExecutionContext> defaultExecutionContext)
Method Detail

name

public java.lang.String name()
Description copied from class: ActorSystem
The name of this actor system, used to distinguish multiple ones within the same JVM & class loader.

Specified by:
name in class ActorSystem
Returns:
(undocumented)

settings

public final ActorSystem.Settings settings()
Description copied from class: ActorSystem
The core settings extracted from the supplied configuration.

Specified by:
settings in class ActorSystem
Returns:
(undocumented)

uncaughtExceptionHandler

protected java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler()

threadFactory

public final MonitorableThreadFactory threadFactory()
Description copied from class: ExtendedActorSystem
A ThreadFactory that can be used if the transport needs to create any Threads

Specified by:
threadFactory in class ExtendedActorSystem
Returns:
(undocumented)

createDynamicAccess

protected DynamicAccess createDynamicAccess()
This is an extension point: by overriding this method, subclasses can control all reflection activities of an actor system.

Returns:
(undocumented)

dynamicAccess

public DynamicAccess dynamicAccess()
Description copied from class: ExtendedActorSystem
ClassLoader wrapper which is used for reflective accesses internally. This is set to use the context class loader, if one is set, or the class loader which loaded the ActorSystem implementation. The context class loader is also set on all threads created by the ActorSystem, if one was set during creation.

Specified by:
dynamicAccess in class ExtendedActorSystem
Returns:
(undocumented)

logConfiguration

public void logConfiguration()
Description copied from class: ActorSystem
Log the configuration.

Specified by:
logConfiguration in class ActorSystem

systemImpl

protected ActorSystemImpl systemImpl()
Description copied from interface: ActorRefFactory
INTERNAL API

Returns:
(undocumented)

systemActorOf

public ActorRef systemActorOf(Props props,
                              java.lang.String name)
Description copied from class: ExtendedActorSystem
Create an actor in the "/system" namespace. This actor will be shut down during system shutdown only after all user actors have terminated.

Specified by:
systemActorOf in class ExtendedActorSystem
Parameters:
props - (undocumented)
name - (undocumented)
Returns:
(undocumented)

actorOf

public ActorRef actorOf(Props props,
                        java.lang.String name)
Description copied from interface: ActorRefFactory
Create new actor as child of this context with the given name, which must not be null, empty or start with &ldquo;$&rdquo;. If the given name is already in use, an InvalidActorNameException is thrown.

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

Parameters:
props - (undocumented)
name - (undocumented)
Returns:
(undocumented)

actorOf

public ActorRef actorOf(Props props)
Description copied from interface: ActorRefFactory
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 &ldquo;$&rdquo; prepended, may change in the future).

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

Parameters:
props - (undocumented)
Returns:
(undocumented)

stop

public void stop(ActorRef actor)
Description copied from interface: ActorRefFactory
Stop the actor pointed to by the given ActorRef; this is an asynchronous operation, i.e. involves a message send. If this method is applied to the self reference from inside an Actor then that Actor is guaranteed to not process any further messages after this call; please note that the processing of the current message will continue, this method does not immediately terminate this actor.

Parameters:
actor - (undocumented)

eventStream

public EventStream eventStream()
Description copied from class: ActorSystem
Main event bus of this actor system, used for example for logging.

Specified by:
eventStream in class ActorSystem
Returns:
(undocumented)

log

public LoggingAdapter log()
Description copied from class: ActorSystem
Convenient logging adapter for logging to the ActorSystem.eventStream.

Specified by:
log in class ActorSystem
Returns:
(undocumented)

scheduler

public Scheduler scheduler()
Description copied from class: ActorSystem
Light-weight scheduler for running asynchronous tasks after some deadline in the future. Not terribly precise but cheap.

Specified by:
scheduler in class ActorSystem
Returns:
(undocumented)

provider

public ActorRefProvider provider()
Description copied from class: ExtendedActorSystem
The ActorRefProvider is the only entity which creates all actor references within this actor system.

Specified by:
provider in interface ActorRefFactory
Specified by:
provider in class ExtendedActorSystem
Returns:
(undocumented)

deadLetters

public ActorRef deadLetters()
Description copied from class: ActorSystem
Actor reference where messages are re-routed to which were addressed to stopped or non-existing actors. Delivery to this actor is done on a best effort basis and hence not strictly guaranteed.

Specified by:
deadLetters in class ActorSystem
Returns:
(undocumented)

mailboxes

public Mailboxes mailboxes()
Description copied from class: ActorSystem
Helper object for looking up configured mailbox types.

Specified by:
mailboxes in class ActorSystem
Returns:
(undocumented)

dispatchers

public Dispatchers dispatchers()
Description copied from class: ActorSystem
Helper object for looking up configured dispatchers.

Specified by:
dispatchers in class ActorSystem
Returns:
(undocumented)

dispatcher

public scala.concurrent.ExecutionContextExecutor dispatcher()
Description copied from class: ActorSystem
Default dispatcher as configured. This dispatcher is used for all actors in the actor system which do not have a different dispatcher configured explicitly. Importing this member will place the default MessageDispatcher in scope.

Specified by:
dispatcher in interface ActorRefFactory
Specified by:
dispatcher in class ActorSystem
Returns:
(undocumented)

internalCallingThreadExecutionContext

public scala.concurrent.ExecutionContext internalCallingThreadExecutionContext()

terminationFuture

public scala.concurrent.Future<scala.runtime.BoxedUnit> terminationFuture()

lookupRoot

public InternalActorRef lookupRoot()
Description copied from interface: ActorRefFactory
INTERNAL API

Returns:
(undocumented)

guardian

public LocalActorRef guardian()
Description copied from class: ExtendedActorSystem
The top-level supervisor of all actors created using system.actorOf(...).

Specified by:
guardian in interface ActorRefFactory
Specified by:
guardian in class ExtendedActorSystem
Returns:
(undocumented)

systemGuardian

public LocalActorRef systemGuardian()
Description copied from class: ExtendedActorSystem
The top-level supervisor of all system-internal services like logging.

Specified by:
systemGuardian in class ExtendedActorSystem
Returns:
(undocumented)

start

public ActorSystemImpl start()

registerOnTermination

public <T> void registerOnTermination(scala.Function0<T> code)
Description copied from class: ActorSystem
Register a block of code (callback) to run after ActorSystem.shutdown has been issued and all actors in this actor system have been stopped. Multiple code blocks may be registered by calling this method multiple times. The callbacks will be run sequentially in reverse order of registration, i.e. last registration is run first.

Specified by:
registerOnTermination in class ActorSystem
Parameters:
code - (undocumented)

registerOnTermination

public void registerOnTermination(java.lang.Runnable code)
Description copied from class: ActorSystem
Java API: Register a block of code (callback) to run after ActorSystem.shutdown has been issued and all actors in this actor system have been stopped. Multiple code blocks may be registered by calling this method multiple times. The callbacks will be run sequentially in reverse order of registration, i.e. last registration is run first.

Specified by:
registerOnTermination in class ActorSystem
Parameters:
code - (undocumented)

awaitTermination

public void awaitTermination(scala.concurrent.duration.Duration timeout)
Description copied from class: ActorSystem
Block current thread until the system has been shutdown, or the specified timeout has elapsed. This will block until after all on termination callbacks have been run.

Specified by:
awaitTermination in class ActorSystem
Parameters:
timeout - (undocumented)

awaitTermination

public void awaitTermination()
Description copied from class: ActorSystem
Block current thread until the system has been shutdown. This will block until after all on termination callbacks have been run.

Specified by:
awaitTermination in class ActorSystem

isTerminated

public boolean isTerminated()
Description copied from class: ActorSystem
Query the termination status: if it returns true, all callbacks have run and the ActorSystem has been fully stopped, i.e. awaitTermination(0 seconds) would return normally. If this method returns false, the status is actually unknown, since it might have changed since you queried it.

Specified by:
isTerminated in class ActorSystem
Returns:
(undocumented)

shutdown

public void shutdown()
Description copied from class: ActorSystem
Stop this actor system. This will stop the guardian actor, which in turn will recursively stop all its child actors, then the system guardian (below which the logging actors reside) and the execute all registered termination handlers (see ActorSystem.registerOnTermination).

Specified by:
shutdown in class ActorSystem

aborting

public boolean aborting()

abort

public void abort()
This kind of shutdown attempts to bring the system down and release its resources more forcefully than plain shutdown. For example it will not wait for remote-deployed child actors to terminate before terminating their parents.


createScheduler

protected Scheduler createScheduler()
Create the scheduler service. This one needs one special behavior: if Closeable, it MUST execute all outstanding tasks upon .close() in order to properly shutdown all dispatchers.

Furthermore, this timer service MUST throw IllegalStateException if it cannot schedule a task. Once scheduled, the task MUST be executed. If executed upon close(), the task may execute before its timeout.

Returns:
(undocumented)

stopScheduler

protected void stopScheduler()

registerExtension

public final <T extends Extension> T registerExtension(ExtensionId<T> ext)
Description copied from class: ActorSystem
Registers the provided extension and creates its payload, if this extension isn't already registered This method has putIfAbsent-semantics, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution

Specified by:
registerExtension in class ActorSystem
Parameters:
ext - (undocumented)
Returns:
(undocumented)

extension

public <T extends Extension> T extension(ExtensionId<T> ext)
Description copied from class: ActorSystem
Returns the payload that is associated with the provided extension throws an IllegalStateException if it is not registered. This method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution

Specified by:
extension in class ActorSystem
Parameters:
ext - (undocumented)
Returns:
(undocumented)

hasExtension

public boolean hasExtension(ExtensionId<? extends Extension> ext)
Description copied from class: ActorSystem
Returns whether the specified extension is already registered, this method can potentially block, waiting for the initialization of the payload, if is in the process of registration from another Thread of execution

Specified by:
hasExtension in class ActorSystem
Parameters:
ext - (undocumented)
Returns:
(undocumented)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

printTree

public java.lang.String printTree()
Description copied from class: ExtendedActorSystem
For debugging: traverse actor hierarchy and make string representation. Careful, this may OOM on large actor systems, and it is only meant for helping debugging in case something already went terminally wrong.

Specified by:
printTree in class ExtendedActorSystem
Returns:
(undocumented)