Class ActorContextAdapter<T>
- java.lang.Object
-
- akka.actor.typed.internal.adapter.ActorContextAdapter<T>
-
- All Implemented Interfaces:
ClassicActorContextProvider
,ActorContextImpl<T>
,ActorContext<T>
,ActorContext<T>
,TypedActorContext<T>
public final class ActorContextAdapter<T> extends java.lang.Object implements ActorContextImpl<T>
INTERNAL API. Wrapping anActorContext
as anTypedActorContext
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.actor.typed.internal.ActorContextImpl
ActorContextImpl.LoggingContext, ActorContextImpl.LoggingContext$
-
-
Constructor Summary
Constructors Constructor Description ActorContextAdapter(ActorContext classicContext, ActorAdapter<T> adapter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelReceiveTimeout()
Cancel the sending of receive timeout notifications.scala.Option<ActorRef<scala.runtime.Nothing$>>
child(java.lang.String name)
The named child Actor if it is alive.scala.collection.Iterable<ActorRef<scala.runtime.Nothing$>>
children()
The list of child Actors created by this Actor during its lifetime that are still alive, in no particular order.ActorContext
classicActorContext()
INTERNAL APIActorContext
classicContext()
Behavior<T>
currentBehavior()
INTERNAL APIscala.concurrent.ExecutionContextExecutor
executionContext()
This Actor’s execution context.<U> ActorRef<U>
internalSpawnMessageAdapter(scala.Function1<U,T> f, java.lang.String _name)
INTERNAL API: Needed to make Scala 2.12 compiler happy if spawnMessageAdapter is overloaded for scaladsl/javadsl.void
onUnhandled(T msg)
Made accessible to allow stash to deal with unhandled messages as though they were interpreted by the adapter itself, even though the unstashing occurs inside the behavior stack.T
receiveTimeoutMsg()
void
receiveTimeoutMsg_$eq(T x$1)
<U> Cancellable
scheduleOnce(scala.concurrent.duration.FiniteDuration delay, ActorRef<U> target, U msg)
Schedule the sending of the given message to the given target Actor after the given time period has elapsed.ActorRef<T>
self()
The identity of this Actor, bound to the lifecycle of this Actor instance.void
setReceiveTimeout(scala.concurrent.duration.FiniteDuration d, T msg)
Schedule the sending of a notification in case no other message is received during the given period of time.<U> ActorRef<U>
spawn(Behavior<U> behavior, java.lang.String name, Props props)
Create a child Actor from the givenBehavior
and with the given name.<U> Props
spawn$default$3()
Create a child Actor from the givenBehavior
and with the given name.<U> ActorRef<U>
spawnAnonymous(Behavior<U> behavior, Props props)
Create a child Actor from the givenBehavior
under a randomly chosen name.<U> Props
spawnAnonymous$default$2()
<U> void
stop(ActorRef<U> child)
Force the child Actor under the given name to terminate after it finishes processing its current message.ActorSystem<scala.runtime.Nothing$>
system()
TheActorSystem
to which this Actor belongs.static <U> ActorContext
toClassic(ActorContext<?> context)
static <U> ActorContext
toClassic(ActorContext<?> context)
<U> void
unwatch(ActorRef<U> other)
Revoke the registration established bywatch
.<U> void
watch(ActorRef<U> other)
Register forTerminated
notification once the Actor identified by the givenActorRef
terminates.<U> void
watchWith(ActorRef<U> other, T msg)
Register for termination notification with a custom message once the Actor identified by the givenActorRef
terminates.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface akka.actor.typed.internal.ActorContextImpl
_currentActorThread_$eq, _logging_$eq, _messageAdapters_$eq, _timer_$eq, asJava, ask, ask, asScala, cancelAllTimers, checkCurrentActorThread, clearCurrentActorThread, clearMdc, getChild, getChildren, getExecutionContext, getLog, getSelf, getSystem, hasCustomLoggerName, hasTimer, internalMessageAdapter, log, loggingContext, messageAdapter, messageAdapter, messageAdapterRef_$eq, messageAdapters, pipeToSelf, pipeToSelf, scheduleOnce, setCurrentActorThread, setLoggerName, setLoggerName, setReceiveTimeout, spawn, spawnAnonymous, spawnMessageAdapter, spawnMessageAdapter, timer
-
-
-
-
Constructor Detail
-
ActorContextAdapter
public ActorContextAdapter(ActorContext classicContext, ActorAdapter<T> adapter)
-
-
Method Detail
-
toClassic
public static <U> ActorContext toClassic(ActorContext<?> context)
-
toClassic
public static <U> ActorContext toClassic(ActorContext<?> context)
-
classicContext
public ActorContext classicContext()
-
currentBehavior
public Behavior<T> currentBehavior()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
currentBehavior
in interfaceActorContext<T>
-
self
public final ActorRef<T> self()
Description copied from interface:ActorContext
The identity of this Actor, bound to the lifecycle of this Actor instance. An Actor with the same name that lives before or after this instance will have a differentActorRef
.This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
self
in interfaceActorContext<T>
-
system
public final ActorSystem<scala.runtime.Nothing$> system()
Description copied from interface:ActorContext
TheActorSystem
to which this Actor belongs.This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
system
in interfaceActorContext<T>
-
classicActorContext
public ActorContext classicActorContext()
Description copied from interface:ClassicActorContextProvider
INTERNAL API- Specified by:
classicActorContext
in interfaceClassicActorContextProvider
-
children
public scala.collection.Iterable<ActorRef<scala.runtime.Nothing$>> children()
Description copied from interface:ActorContext
The list of child Actors created by this Actor during its lifetime that are still alive, in no particular order.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
children
in interfaceActorContext<T>
-
child
public scala.Option<ActorRef<scala.runtime.Nothing$>> child(java.lang.String name)
Description copied from interface:ActorContext
The named child Actor if it is alive.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
child
in interfaceActorContext<T>
-
spawnAnonymous
public <U> ActorRef<U> spawnAnonymous(Behavior<U> behavior, Props props)
Description copied from interface:ActorContext
Create a child Actor from the givenBehavior
under a randomly chosen name. It is good practice to name Actors wherever practical.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
spawnAnonymous
in interfaceActorContext<T>
- Specified by:
spawnAnonymous
in interfaceActorContext<T>
-
spawn
public <U> ActorRef<U> spawn(Behavior<U> behavior, java.lang.String name, Props props)
Description copied from interface:ActorContext
Create a child Actor from the givenBehavior
and with the given name.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
spawn
in interfaceActorContext<T>
- Specified by:
spawn
in interfaceActorContext<T>
-
spawnAnonymous$default$2
public <U> Props spawnAnonymous$default$2()
- Specified by:
spawnAnonymous$default$2
in interfaceActorContext<T>
-
spawn$default$3
public <U> Props spawn$default$3()
Description copied from interface:ActorContext
Create a child Actor from the givenBehavior
and with the given name.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
spawn$default$3
in interfaceActorContext<T>
-
stop
public <U> void stop(ActorRef<U> child)
Description copied from interface:ActorContext
Force the child Actor under the given name to terminate after it finishes processing its current message. Nothing happens if the ActorRef is a child that is already stopped.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
stop
in interfaceActorContext<T>
- Specified by:
stop
in interfaceActorContext<T>
-
watch
public <U> void watch(ActorRef<U> other)
Description copied from interface:ActorContext
Register forTerminated
notification once the Actor identified by the givenActorRef
terminates. This message is also sent when the watched actor is on a node that has been removed from the cluster when using Akka Cluster.watch
is idempotent if it is not mixed withwatchWith
.It will fail with an
IllegalStateException
if the same subject was watched before usingwatchWith
. To clear the termination message, unwatch first.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
watch
in interfaceActorContext<T>
- Specified by:
watch
in interfaceActorContext<T>
-
watchWith
public <U> void watchWith(ActorRef<U> other, T msg)
Description copied from interface:ActorContext
Register for termination notification with a custom message once the Actor identified by the givenActorRef
terminates. This message is also sent when the watched actor is on a node that has been removed from the cluster when using Akka Cluster.watchWith
is idempotent if it is called with the samemsg
and not mixed withwatch
.It will fail with an
IllegalStateException
if the same subject was watched before usingwatch
orwatchWith
with another termination message. To change the termination message, unwatch first.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
watchWith
in interfaceActorContext<T>
- Specified by:
watchWith
in interfaceActorContext<T>
-
unwatch
public <U> void unwatch(ActorRef<U> other)
Description copied from interface:ActorContext
Revoke the registration established bywatch
. ATerminated
notification will not subsequently be received for the referenced Actor.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
unwatch
in interfaceActorContext<T>
- Specified by:
unwatch
in interfaceActorContext<T>
-
receiveTimeoutMsg
public T receiveTimeoutMsg()
-
receiveTimeoutMsg_$eq
public void receiveTimeoutMsg_$eq(T x$1)
-
setReceiveTimeout
public void setReceiveTimeout(scala.concurrent.duration.FiniteDuration d, T msg)
Description copied from interface:ActorContext
Schedule the sending of a notification in case no other message is received during the given period of time. The timeout starts anew with each received message. UsecancelReceiveTimeout
to switch off this mechanism.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
setReceiveTimeout
in interfaceActorContext<T>
-
cancelReceiveTimeout
public void cancelReceiveTimeout()
Description copied from interface:ActorContext
Cancel the sending of receive timeout notifications.*Warning*: This method is not thread-safe and must not be accessed from threads other than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
cancelReceiveTimeout
in interfaceActorContext<T>
- Specified by:
cancelReceiveTimeout
in interfaceActorContext<T>
-
executionContext
public scala.concurrent.ExecutionContextExecutor executionContext()
Description copied from interface:ActorContext
This Actor’s execution context. It can be used to run asynchronous tasks likeFuture
operators.This field is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
executionContext
in interfaceActorContext<T>
-
scheduleOnce
public <U> Cancellable scheduleOnce(scala.concurrent.duration.FiniteDuration delay, ActorRef<U> target, U msg)
Description copied from interface:ActorContext
Schedule the sending of the given message to the given target Actor after the given time period has elapsed. The scheduled action can be cancelled by invokingCancellable.cancel()
on the returned handle.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
Future
callbacks.- Specified by:
scheduleOnce
in interfaceActorContext<T>
-
internalSpawnMessageAdapter
public <U> ActorRef<U> internalSpawnMessageAdapter(scala.Function1<U,T> f, java.lang.String _name)
Description copied from interface:ActorContextImpl
INTERNAL API: Needed to make Scala 2.12 compiler happy if spawnMessageAdapter is overloaded for scaladsl/javadsl. Otherwise "ambiguous reference to overloaded definition" because Function is lambda.- Specified by:
internalSpawnMessageAdapter
in interfaceActorContextImpl<T>
-
onUnhandled
public void onUnhandled(T msg)
Made accessible to allow stash to deal with unhandled messages as though they were interpreted by the adapter itself, even though the unstashing occurs inside the behavior stack.- Specified by:
onUnhandled
in interfaceActorContext<T>
-
-