public abstract class ActorSystem extends java.lang.Object implements ActorRefFactory
There are several possibilities for creating actors (see Props
for details on props
):
// Java or Scala
system.actorOf(props, "name")
system.actorOf(props)
// Scala
system.actorOf(Props[MyActor], "name")
system.actorOf(Props(classOf[MyActor], arg1, arg2), "name")
// Java
system.actorOf(Props.create(MyActor.class), "name");
system.actorOf(Props.create(MyActor.class, arg1, arg2), "name");
Where no name is given explicitly, one will be automatically generated.
Important Notice:
This class is not meant to be extended by user code. If you want to
actually roll your own Akka, it will probably be better to look into
extending ExtendedActorSystem
instead, but beware that you
are completely on your own in that case!
Modifier and Type | Class and Description |
---|---|
static class |
ActorSystem.Settings
Settings are the overall ActorSystem Settings which also provides a convenient access to the Config object.
|
Constructor and Description |
---|
ActorSystem() |
Modifier and Type | Method and Description |
---|---|
static ActorSystem |
apply()
Creates a new ActorSystem with the name "default",
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
apply(java.lang.String name)
Creates a new ActorSystem with the specified name,
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
apply(java.lang.String name,
com.typesafe.config.Config config)
Creates a new ActorSystem with the specified name, and the specified Config, then
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
apply(java.lang.String name,
com.typesafe.config.Config config,
java.lang.ClassLoader classLoader)
Creates a new ActorSystem with the specified name, the specified Config, and specified ClassLoader
|
static ActorSystem |
apply(java.lang.String name,
scala.Option<com.typesafe.config.Config> config,
scala.Option<java.lang.ClassLoader> classLoader,
scala.Option<scala.concurrent.ExecutionContext> defaultExecutionContext)
Creates a new ActorSystem with the specified name,
the specified ClassLoader if given, otherwise obtains the current ClassLoader by first inspecting the current
threads' getContextClassLoader, then tries to walk the stack to find the callers class loader, then
falls back to the ClassLoader associated with the ActorSystem class.
|
abstract void |
awaitTermination()
Block current thread until the system has been shutdown.
|
abstract void |
awaitTermination(scala.concurrent.duration.Duration timeout)
Block current thread until the system has been shutdown, or the specified
timeout has elapsed.
|
ActorPath |
child(java.lang.String child)
Java API: Create a new child actor path.
|
static ActorSystem |
create()
Creates a new ActorSystem with the name "default",
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
create(java.lang.String name)
Creates a new ActorSystem with the specified name,
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
create(java.lang.String name,
com.typesafe.config.Config config)
Creates a new ActorSystem with the specified name, and the specified Config, then
obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader,
then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader
associated with the ActorSystem class.
|
static ActorSystem |
create(java.lang.String name,
com.typesafe.config.Config config,
java.lang.ClassLoader classLoader)
Creates a new ActorSystem with the specified name, the specified Config, and specified ClassLoader
|
static ActorSystem |
create(java.lang.String name,
com.typesafe.config.Config config,
java.lang.ClassLoader classLoader,
scala.concurrent.ExecutionContext defaultExecutionContext)
Creates a new ActorSystem with the specified name, the specified Config, the specified ClassLoader,
and the specified ExecutionContext.
|
abstract ActorRef |
deadLetters()
Actor reference where messages are re-routed to which were addressed to
stopped or non-existing actors.
|
ActorPath |
descendant(java.lang.Iterable<java.lang.String> names)
Java API: Recursively create a descendant’s path by appending all child names.
|
abstract scala.concurrent.ExecutionContextExecutor |
dispatcher()
Default dispatcher as configured.
|
abstract akka.dispatch.Dispatchers |
dispatchers()
Helper object for looking up configured dispatchers.
|
static scala.Option<java.lang.String> |
EnvHome() |
abstract akka.event.EventStream |
eventStream()
Main event bus of this actor system, used for example for logging.
|
abstract <T extends Extension> |
extension(ExtensionId<T> ext)
Returns the payload that is associated with the provided extension
throws an IllegalStateException if it is not registered.
|
static scala.Option<java.lang.String> |
GlobalHome() |
abstract 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
|
abstract boolean |
isTerminated()
Query the termination status: if it returns true, all callbacks have run
and the ActorSystem has been fully stopped, i.e.
|
abstract akka.event.LoggingAdapter |
log()
Convenient logging adapter for logging to the
ActorSystem.eventStream . |
abstract void |
logConfiguration()
Log the configuration.
|
abstract akka.dispatch.Mailboxes |
mailboxes()
Helper object for looking up configured mailbox types.
|
abstract java.lang.String |
name()
The name of this actor system, used to distinguish multiple ones within
the same JVM & class loader.
|
abstract <T extends Extension> |
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
|
abstract <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.
|
abstract 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.
|
abstract Scheduler |
scheduler()
Light-weight scheduler for running asynchronous tasks after some deadline
in the future.
|
abstract ActorSystem.Settings |
settings()
The core settings extracted from the supplied configuration.
|
abstract void |
shutdown()
Stop this actor system.
|
long |
startTime()
Start-up time in milliseconds since the epoch.
|
static scala.Option<java.lang.String> |
SystemHome() |
long |
uptime()
Up-time of this actor system in seconds.
|
static java.lang.String |
Version() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
actorFor, actorFor, actorFor, actorFor, actorOf, actorOf, actorSelection, actorSelection, guardian, lookupRoot, provider, stop, systemImpl
public static java.lang.String Version()
public static scala.Option<java.lang.String> EnvHome()
public static scala.Option<java.lang.String> SystemHome()
public static scala.Option<java.lang.String> GlobalHome()
public static ActorSystem create()
public static ActorSystem create(java.lang.String name)
public static ActorSystem create(java.lang.String name, com.typesafe.config.Config config)
public static ActorSystem create(java.lang.String name, com.typesafe.config.Config config, java.lang.ClassLoader classLoader)
public static ActorSystem create(java.lang.String name, com.typesafe.config.Config config, java.lang.ClassLoader classLoader, scala.concurrent.ExecutionContext defaultExecutionContext)
null
is passed in for the Config, ClassLoader and/or ExecutionContext parameters, the respective default value
will be used. If no Config is given, the default reference config will be obtained from the ClassLoader.
If no ClassLoader is given, it obtains the current ClassLoader by first inspecting the current
threads' getContextClassLoader, then tries to walk the stack to find the callers class loader, then
falls back to the ClassLoader associated with the ActorSystem class. If no ExecutionContext is given, the
system will fallback to the executor configured under "akka.actor.default-dispatcher.default-executor.fallback".
Note that the given ExecutionContext will be used by all dispatchers that have been configured with
executor = "default-executor", including those that have not defined the executor setting and thereby fallback
to the default of "default-dispatcher.executor".
public static ActorSystem apply()
public static ActorSystem apply(java.lang.String name)
public static ActorSystem apply(java.lang.String name, com.typesafe.config.Config config)
public static ActorSystem apply(java.lang.String name, com.typesafe.config.Config config, java.lang.ClassLoader classLoader)
public static ActorSystem apply(java.lang.String name, scala.Option<com.typesafe.config.Config> config, scala.Option<java.lang.ClassLoader> classLoader, scala.Option<scala.concurrent.ExecutionContext> defaultExecutionContext)
public abstract java.lang.String name()
public abstract ActorSystem.Settings settings()
public abstract void logConfiguration()
public ActorPath child(java.lang.String child)
public ActorPath descendant(java.lang.Iterable<java.lang.String> names)
public long startTime()
public long uptime()
public abstract akka.event.EventStream eventStream()
public abstract akka.event.LoggingAdapter log()
ActorSystem.eventStream
.public abstract ActorRef deadLetters()
public abstract Scheduler scheduler()
public abstract akka.dispatch.Dispatchers dispatchers()
public abstract scala.concurrent.ExecutionContextExecutor dispatcher()
dispatcher
in interface ActorRefFactory
public abstract akka.dispatch.Mailboxes mailboxes()
public abstract <T> void registerOnTermination(scala.Function0<T> code)
a
- RejectedExecutionException if the System has already shut down or if shutdown has been initiated.
Scala API
public abstract void registerOnTermination(java.lang.Runnable code)
a
- RejectedExecutionException if the System has already shut down or if shutdown has been initiated.public abstract void awaitTermination(scala.concurrent.duration.Duration timeout)
TimeoutException
- in case of timeoutpublic abstract void awaitTermination()
public abstract void shutdown()
ActorSystem.registerOnTermination
).public abstract boolean isTerminated()
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.public abstract <T extends Extension> T registerExtension(ExtensionId<T> ext)
public abstract <T extends Extension> T extension(ExtensionId<T> ext)
public abstract boolean hasExtension(ExtensionId<? extends Extension> ext)