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 ActorRef |
actorFor(ActorPath path) |
static ActorRef |
actorFor(scala.collection.Iterable<java.lang.String> path) |
static ActorRef |
actorFor(java.lang.Iterable<java.lang.String> path) |
static ActorRef |
actorFor(java.lang.String path) |
abstract static ActorRef |
actorOf(Props props) |
abstract static ActorRef |
actorOf(Props props,
java.lang.String name) |
static ActorSelection |
actorSelection(ActorPath path) |
static ActorSelection |
actorSelection(java.lang.String path) |
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,
ActorSystemSetup setup)
Scala API: Creates a new actor system with the specified name and settings
The core actor system settings are defined in
BootstrapSetup |
static ActorSystem |
apply(java.lang.String name,
BootstrapSetup bootstrapSetup)
Scala API: Shortcut for creating an actor system with custom bootstrap settings.
|
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()
Deprecated.
Use Await.result(whenTerminated, Duration.Inf) instead. Since 2.4.
|
abstract void |
awaitTermination(scala.concurrent.duration.Duration timeout)
Deprecated.
Use Await.result(whenTerminated, timeout) instead. Since 2.4.
|
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,
ActorSystemSetup setups)
Java API: Creates a new actor system with the specified name and settings
The core actor system settings are defined in
BootstrapSetup |
static ActorSystem |
create(java.lang.String name,
BootstrapSetup bootstrapSetup)
Java API: Shortcut for creating an actor system with custom bootstrap settings.
|
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 Dispatchers |
dispatchers()
Helper object for looking up configured dispatchers.
|
static scala.Option<java.lang.String> |
EnvHome() |
abstract 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 java.lang.ClassLoader |
findClassLoader() |
static scala.Option<java.lang.String> |
GlobalHome() |
protected abstract static InternalActorRef |
guardian() |
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()
Deprecated.
Use the whenTerminated method instead. Since 2.4.
|
abstract LoggingAdapter |
log()
Convenient logging adapter for logging to the
eventStream() . |
abstract void |
logConfiguration()
Log the configuration.
|
protected abstract static InternalActorRef |
lookupRoot() |
abstract 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.
|
protected abstract static ActorRefProvider |
provider() |
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()
Deprecated.
Use the terminate() method instead. Since 2.4.
|
long |
startTime()
Start-up time in milliseconds since the epoch.
|
abstract static void |
stop(ActorRef actor) |
static scala.Option<java.lang.String> |
SystemHome() |
protected abstract static ActorSystemImpl |
systemImpl() |
abstract scala.concurrent.Future<Terminated> |
terminate()
Terminates this actor system.
|
long |
uptime()
Up-time of this actor system in seconds.
|
static java.lang.String |
Version() |
abstract scala.concurrent.Future<Terminated> |
whenTerminated()
Returns a Future which will be completed after the ActorSystem has been terminated
and termination hooks have been executed.
|
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)
name
- (undocumented)public static ActorSystem create(java.lang.String name, ActorSystemSetup setups)
BootstrapSetup
name
- (undocumented)setups
- (undocumented)public static ActorSystem create(java.lang.String name, BootstrapSetup bootstrapSetup)
ActorSystem.create(name, ActorSystemSetup.create(bootstrapSettings))
name
- (undocumented)bootstrapSetup
- (undocumented)public static ActorSystem create(java.lang.String name, com.typesafe.config.Config config)
name
- (undocumented)config
- (undocumented)public static ActorSystem create(java.lang.String name, com.typesafe.config.Config config, java.lang.ClassLoader classLoader)
name
- (undocumented)config
- (undocumented)classLoader
- (undocumented)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".
name
- (undocumented)config
- (undocumented)classLoader
- (undocumented)defaultExecutionContext
- (undocumented)public static ActorSystem apply()
public static ActorSystem apply(java.lang.String name)
name
- (undocumented)public static ActorSystem apply(java.lang.String name, ActorSystemSetup setup)
BootstrapSetup
name
- (undocumented)setup
- (undocumented)public static ActorSystem apply(java.lang.String name, BootstrapSetup bootstrapSetup)
ActorSystem(name, ActorSystemSetup(bootstrapSetup))
name
- (undocumented)bootstrapSetup
- (undocumented)public static ActorSystem apply(java.lang.String name, com.typesafe.config.Config config)
name
- (undocumented)config
- (undocumented)public static ActorSystem apply(java.lang.String name, com.typesafe.config.Config config, java.lang.ClassLoader classLoader)
name
- (undocumented)config
- (undocumented)classLoader
- (undocumented)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)
name
- (undocumented)config
- (undocumented)classLoader
- (undocumented)defaultExecutionContext
- (undocumented)public static java.lang.ClassLoader findClassLoader()
protected abstract static ActorSystemImpl systemImpl()
protected abstract static ActorRefProvider provider()
protected abstract static InternalActorRef guardian()
protected abstract static InternalActorRef lookupRoot()
public static ActorRef actorFor(java.lang.String path)
public static ActorRef actorFor(scala.collection.Iterable<java.lang.String> path)
public static ActorRef actorFor(java.lang.Iterable<java.lang.String> path)
public static ActorSelection actorSelection(java.lang.String path)
public static ActorSelection actorSelection(ActorPath path)
public abstract static void stop(ActorRef actor)
public abstract java.lang.String name()
public abstract ActorSystem.Settings settings()
public abstract void logConfiguration()
public ActorPath child(java.lang.String child)
child
- (undocumented)public ActorPath descendant(java.lang.Iterable<java.lang.String> names)
names
- (undocumented)public long startTime()
public long uptime()
public abstract EventStream eventStream()
public abstract LoggingAdapter log()
eventStream()
.public abstract ActorRef deadLetters()
public abstract Scheduler scheduler()
public abstract Dispatchers dispatchers()
public abstract scala.concurrent.ExecutionContextExecutor dispatcher()
dispatcher
in interface ActorRefFactory
public abstract Mailboxes mailboxes()
public abstract <T> void registerOnTermination(scala.Function0<T> code)
Throws a RejectedExecutionException if the System has already shut down or if shutdown has been initiated.
Scala API
code
- (undocumented)public abstract void registerOnTermination(java.lang.Runnable code)
Throws a RejectedExecutionException if the System has already shut down or if shutdown has been initiated.
code
- (undocumented)public abstract void awaitTermination(scala.concurrent.duration.Duration timeout)
Throws TimeoutException in case of timeout.
timeout
- (undocumented)public abstract void awaitTermination()
public abstract void shutdown()
registerOnTermination(scala.Function0<T>)
).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 scala.concurrent.Future<Terminated> terminate()
registerOnTermination(scala.Function0<T>)
).
Be careful to not schedule any operations on completion of the returned future
using the dispatcher
of this actor system as it will have been shut down before the
future completes.public abstract scala.concurrent.Future<Terminated> whenTerminated()
dispatcher
of this actor system as it will have been shut down before this
future completes.public abstract <T extends Extension> T registerExtension(ExtensionId<T> ext)
ext
- (undocumented)public abstract <T extends Extension> T extension(ExtensionId<T> ext)
ext
- (undocumented)public abstract boolean hasExtension(ExtensionId<? extends Extension> ext)
ext
- (undocumented)