Package akka.actor
Class ActorSystemImpl
- java.lang.Object
-
- akka.actor.ActorSystem
-
- akka.actor.ExtendedActorSystem
-
- akka.actor.ActorSystemImpl
-
- All Implemented Interfaces:
ActorRefFactory
,ClassicActorSystemProvider
public class ActorSystemImpl extends ExtendedActorSystem
This is an extension point: by overriding this method, subclasses can control all reflection activities of an actor system.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ActorSystemImpl.TerminationCallbacks<T>
Adds a Runnable that will be executed on ActorSystem termination.-
Nested classes/interfaces inherited from class akka.actor.ActorSystem
ActorSystem.Settings
-
-
Constructor Summary
Constructors Constructor Description ActorSystemImpl(java.lang.String name, com.typesafe.config.Config applicationConfig, java.lang.ClassLoader classLoader, scala.Option<scala.concurrent.ExecutionContext> defaultExecutionContext, scala.Option<Props> guardianProps, ActorSystemSetup setup)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActorPath
$div(java.lang.String actorName)
Construct a path below the application guardian to be used withActorRefFactory.actorSelection(java.lang.String)
.ActorPath
$div(scala.collection.Iterable<java.lang.String> path)
Construct a path below the application guardian to be used withActorRefFactory.actorSelection(java.lang.String)
.void
abort()
This kind of shutdown attempts to bring the system down and release its resources more forcefully than plain shutdown.boolean
aborting()
void
aborting_$eq(boolean x$1)
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 “$” 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 “$”.void
assertInitialized()
Asserts that the ActorSystem has been fully initialized.ActorSystem
classicSystem()
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>
Textension(ExtensionId<T> ext)
Returns the payload that is associated with the provided extension throws an IllegalStateException if it is not registered.java.util.concurrent.CompletionStage<Terminated>
getWhenTerminated()
Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed.LocalActorRef
guardian()
The top-level supervisor of all actors created using system.actorOf(...).scala.Option<Props>
guardianProps()
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 executionscala.concurrent.ExecutionContext
internalCallingThreadExecutionContext()
LoggingAdapter
log()
Convenient logging adapter for logging to theActorSystem.eventStream()
.void
logConfiguration()
Log the configuration.LoggingFilter
logFilter()
Filter of log events that is used by the LoggingAdapter before publishing log events to the eventStreamInternalActorRef
lookupRoot()
INTERNAL APIMailboxes
mailboxes()
Helper object for looking up configured mailbox types.java.lang.String
name()
java.lang.String
printTree()
For debugging: traverse actor hierarchy and make string representation.ActorRefProvider
provider()
INTERNAL API<T extends Extension>
TregisterExtension(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 executionvoid
registerOnTermination(java.lang.Runnable code)
Java API: Register a block of code (callback) to run after {@link ActorSystem.terminate()} has been issued and all actors in this actor system have been stopped.<T> void
registerOnTermination(scala.Function0<T> code)
Register a block of code (callback) to run after {@link ActorSystem.terminate()} 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.ActorSystemImpl
start()
void
stop(ActorRef actor)
Stop the actor pointed to by the givenActorRef
; 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 APIscala.concurrent.Future<Terminated>
terminate()
Terminates this actor system.MonitorableThreadFactory
threadFactory()
A ThreadFactory that can be used if the transport needs to create any Threadsjava.lang.String
toString()
protected java.lang.Thread.UncaughtExceptionHandler
uncaughtExceptionHandler()
scala.concurrent.Future<Terminated>
whenTerminated()
Returns a Future which will be completed after the ActorSystem has been terminated and termination hooks have been executed.-
Methods inherited from class akka.actor.ActorSystem
apply, apply, apply, apply, apply, apply, apply, apply$default$2, apply$default$3, apply$default$4, child, create, create, create, create, create, create, create, descendant, EnvHome, findClassLoader, getDispatcher, getEventStream, getScheduler, 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, scala.Option<Props> guardianProps, ActorSystemSetup setup)
-
-
Method Detail
-
$div
public ActorPath $div(java.lang.String actorName)
Description copied from class:ActorSystem
Construct a path below the application guardian to be used withActorRefFactory.actorSelection(java.lang.String)
.- Specified by:
$div
in classActorSystem
- Parameters:
actorName
- (undocumented)- Returns:
- (undocumented)
-
$div
public ActorPath $div(scala.collection.Iterable<java.lang.String> path)
Description copied from class:ActorSystem
Construct a path below the application guardian to be used withActorRefFactory.actorSelection(java.lang.String)
.- Specified by:
$div
in classActorSystem
- Parameters:
path
- (undocumented)- Returns:
- (undocumented)
-
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.
-
aborting
public boolean aborting()
-
aborting_$eq
public void aborting_$eq(boolean x$1)
-
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 “$”. If the given name is already in use, anInvalidActorNameException
is thrown.See
Props
for details on how to obtain aProps
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 “$” prepended, may change in the future).See
Props
for details on how to obtain aProps
object.- Parameters:
props
- (undocumented)- Returns:
- (undocumented)
-
assertInitialized
public void assertInitialized()
Asserts that the ActorSystem has been fully initialized. Can be used to guard code blocks that might accidentally be run during initialization but require a fully initialized ActorSystem before proceeding.
-
classicSystem
public ActorSystem classicSystem()
-
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)
-
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)
-
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 classActorSystem
- 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 interfaceActorRefFactory
- Specified by:
dispatcher
in classActorSystem
- Returns:
- (undocumented)
-
dispatchers
public Dispatchers dispatchers()
Description copied from class:ActorSystem
Helper object for looking up configured dispatchers.- Specified by:
dispatchers
in classActorSystem
- 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 classExtendedActorSystem
- Returns:
- (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 classActorSystem
- 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 classActorSystem
- Parameters:
ext
- (undocumented)- Returns:
- (undocumented)
-
getWhenTerminated
public java.util.concurrent.CompletionStage<Terminated> getWhenTerminated()
Description copied from class:ActorSystem
Returns a CompletionStage which will be completed after the ActorSystem has been terminated and termination hooks have been executed. If you registered any callback withActorSystem.registerOnTermination(scala.Function0<T>)
, the returned CompletionStage from this method will not complete until all the registered callbacks are finished. Be careful to not schedule any operations on thedispatcher
of this actor system as it will have been shut down before this future completes.- Specified by:
getWhenTerminated
in classActorSystem
- 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 interfaceActorRefFactory
- Specified by:
guardian
in classExtendedActorSystem
- Returns:
- (undocumented)
-
guardianProps
public scala.Option<Props> guardianProps()
-
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 classActorSystem
- Parameters:
ext
- (undocumented)- Returns:
- (undocumented)
-
internalCallingThreadExecutionContext
public scala.concurrent.ExecutionContext internalCallingThreadExecutionContext()
-
log
public LoggingAdapter log()
Description copied from class:ActorSystem
Convenient logging adapter for logging to theActorSystem.eventStream()
.- Specified by:
log
in classActorSystem
- Returns:
- (undocumented)
-
logConfiguration
public void logConfiguration()
Description copied from class:ActorSystem
Log the configuration.- Specified by:
logConfiguration
in classActorSystem
-
logFilter
public LoggingFilter logFilter()
Description copied from class:ExtendedActorSystem
Filter of log events that is used by the LoggingAdapter before publishing log events to the eventStream- Specified by:
logFilter
in classExtendedActorSystem
- Returns:
- (undocumented)
-
lookupRoot
public InternalActorRef lookupRoot()
Description copied from interface:ActorRefFactory
INTERNAL API- Returns:
- (undocumented)
-
mailboxes
public Mailboxes mailboxes()
Description copied from class:ActorSystem
Helper object for looking up configured mailbox types.- Specified by:
mailboxes
in classActorSystem
- Returns:
- (undocumented)
-
name
public java.lang.String name()
- Specified by:
name
in classActorSystem
-
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 classExtendedActorSystem
- Returns:
- (undocumented)
-
provider
public ActorRefProvider provider()
Description copied from interface:ActorRefFactory
INTERNAL API- Specified by:
provider
in interfaceActorRefFactory
- Specified by:
provider
in classExtendedActorSystem
- Returns:
- (undocumented)
-
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 classActorSystem
- Parameters:
ext
- (undocumented)- Returns:
- (undocumented)
-
registerOnTermination
public <T> void registerOnTermination(scala.Function0<T> code)
Description copied from class:ActorSystem
Register a block of code (callback) to run after {@link ActorSystem.terminate()} 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. Note that ActorSystem will not terminate until all the registered callbacks are finished.Throws a RejectedExecutionException if the System has already been terminated or if termination has been initiated.
Scala API
- Specified by:
registerOnTermination
in classActorSystem
- 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 {@link ActorSystem.terminate()} 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. Note that ActorSystem will not terminate until all the registered callbacks are finished.Throws a RejectedExecutionException if the System has already been terminated or if termination has been initiated.
- Specified by:
registerOnTermination
in classActorSystem
- Parameters:
code
- (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 classActorSystem
- 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 classActorSystem
- Returns:
- (undocumented)
-
start
public ActorSystemImpl start()
-
stop
public void stop(ActorRef actor)
Description copied from interface:ActorRefFactory
Stop the actor pointed to by the givenActorRef
; this is an asynchronous operation, i.e. involves a message send. If this method is applied to theself
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)
-
stopScheduler
protected void stopScheduler()
-
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.terminate only after all user actors have terminated.- Specified by:
systemActorOf
in classExtendedActorSystem
- Parameters:
props
- (undocumented)name
- (undocumented)- 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 classExtendedActorSystem
- Returns:
- (undocumented)
-
systemImpl
protected ActorSystemImpl systemImpl()
Description copied from interface:ActorRefFactory
INTERNAL API- Returns:
- (undocumented)
-
terminate
public scala.concurrent.Future<Terminated> terminate()
Description copied from class:ActorSystem
Terminates this actor system. This will stop the guardian actor, which in turn will recursively stop all its child actors, the system guardian (below which the logging actors reside) and then execute all registered termination handlers (seeActorSystem.registerOnTermination(scala.Function0<T>)
). Be careful to not schedule any operations on completion of the returned future using thedispatcher
of this actor system as it will have been shut down before the future completes.- Specified by:
terminate
in classActorSystem
- Returns:
- (undocumented)
-
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 classExtendedActorSystem
- Returns:
- (undocumented)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
uncaughtExceptionHandler
protected java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler()
-
whenTerminated
public scala.concurrent.Future<Terminated> whenTerminated()
Description copied from class:ActorSystem
Returns a Future which will be completed after the ActorSystem has been terminated and termination hooks have been executed. If you registered any callback withActorSystem.registerOnTermination(scala.Function0<T>)
, the returned Future from this method will not complete until all the registered callbacks are finished. Be careful to not schedule any operations on thedispatcher
of this actor system as it will have been shut down before this future completes.- Specified by:
whenTerminated
in classActorSystem
- Returns:
- (undocumented)
-
-