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>
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.
-
-
Constructor Summary
Constructors Constructor Description ActorContextAdapter(ActorContext untypedContext, 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()
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.Logger
log()
An actor specific logger.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
setLoggerClass(java.lang.Class<?> clazz)
Replace the current logger (or initialize a new logger if the logger was not touched before) with one that has ghe given class as logging class.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)
ActorContext
untypedContext()
<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
_messageAdapters_$eq, _timer_$eq, asJava, ask, ask, asScala, cancelAllTimers, getChild, getChildren, getExecutionContext, getLog, getSelf, getSystem, hasTimer, internalMessageAdapter, messageAdapter, messageAdapter, messageAdapterRef_$eq, messageAdapters, pipeToSelf, pipeToSelf, scheduleOnce, setReceiveTimeout, spawn, spawnAnonymous, spawnMessageAdapter, spawnMessageAdapter, timer
-
-
-
-
Constructor Detail
-
ActorContextAdapter
public ActorContextAdapter(ActorContext untypedContext, ActorAdapter<T> adapter)
-
-
Method Detail
-
toClassic
public static <U> ActorContext toClassic(ActorContext<?> context)
-
toClassic
public static <U> ActorContext toClassic(ActorContext<?> context)
-
untypedContext
public ActorContext untypedContext()
-
currentBehavior
public Behavior<T> currentBehavior()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
currentBehavior
in interfaceActorContext<T>
- Returns:
- (undocumented)
-
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>
- Returns:
- (undocumented)
-
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>
- Returns:
- (undocumented)
-
classicActorContext
public ActorContext classicActorContext()
- 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>
- Returns:
- (undocumented)
-
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>
- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
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>
- Parameters:
behavior
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
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>
- Parameters:
behavior
- (undocumented)name
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
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>
- Returns:
- (undocumented)
-
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>
- Parameters:
child
- (undocumented)
-
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 or has been marked unreachable when using akka-remote directly.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>
- Parameters:
other
- (undocumented)
-
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 or has been marked unreachable when using akka-remote directly.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>
- Parameters:
other
- (undocumented)msg
- (undocumented)
-
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>
- Parameters:
other
- (undocumented)
-
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>
- Parameters:
d
- (undocumented)msg
- (undocumented)
-
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>
- Returns:
- (undocumented)
-
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>
- Parameters:
delay
- (undocumented)target
- (undocumented)msg
- (undocumented)- Returns:
- (undocumented)
-
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>
- Parameters:
f
- (undocumented)_name
- (undocumented)- Returns:
- (undocumented)
-
log
public Logger log()
Description copied from interface:ActorContext
An actor specific logger.The logger will have the actor path as
logSource
and will an estimated source class for the actor which is calculated when the logger is first used (the logger is lazily created upon first use). If this yields the wrong class or another class is preferred this can be achieved throughLogger.withLoggerClass
orsetLoggerClass
.*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:
log
in interfaceActorContext<T>
- Returns:
- (undocumented)
-
setLoggerClass
public void setLoggerClass(java.lang.Class<?> clazz)
Description copied from interface:ActorContext
Replace the current logger (or initialize a new logger if the logger was not touched before) with one that has ghe given class as logging class. Logger source will be actor path.*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:
setLoggerClass
in interfaceActorContext<T>
- Specified by:
setLoggerClass
in interfaceActorContext<T>
- Parameters:
clazz
- (undocumented)
-
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>
- Parameters:
msg
- (undocumented)
-
-