Class StubbedActorContext<T>
- java.lang.Object
-
- akka.actor.testkit.typed.internal.StubbedActorContext<T>
-
- All Implemented Interfaces:
ClassicActorContextProvider
,ActorContextImpl<T>
,ActorContext<T>
,ActorContext<T>
,TypedActorContext<T>
- Direct Known Subclasses:
EffectfulActorContext
public class StubbedActorContext<T> extends java.lang.Object implements ActorContextImpl<T>
INTERNAL API
-
-
Constructor Summary
Constructors Constructor Description StubbedActorContext(ActorPath path, scala.Function0<Behavior<T>> currentBehaviorProvider)
StubbedActorContext(java.lang.String name, scala.Function0<Behavior<T>> currentBehaviorProvider)
-
Method Summary
All 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.<U> TestInboxImpl<U>
childInbox(ActorRef<U> child)
Retrieve the inbox representing the given child actor.<U> scala.Option<TestInboxImpl<U>>
childInbox(java.lang.String name)
Retrieve the inbox representing the child actor with the given name.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.scala.collection.Iterable<java.lang.String>
childrenNames()
<U> BehaviorTestKitImpl<U>
childTestKit(ActorRef<U> child)
Retrieve the BehaviorTestKit for the given child actor.scala.runtime.Nothing$
classicActorContext()
void
clearLog()
Clear the log entries.void
clearUnhandled()
Clear the list of captured unhandled messages.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 APILogger
log()
An actor specific logger.scala.collection.immutable.List<CapturedLogEvent>
logEntries()
The log entries logged through context.log.{debug, info, warn, error} are captured and can be inspected through this method.void
onUnhandled(T msg)
INTERNAL APIActorPath
path()
void
removeChildInbox(ActorRef<scala.runtime.Nothing$> child)
Remove the given inbox from the list of children, for example after having simulated its termination.<U> Cancellable
scheduleOnce(scala.concurrent.duration.FiniteDuration delay, ActorRef<U> target, U message)
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.TestInboxImpl<T>
selfInbox()
INTERNAL APIvoid
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 message)
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)
Do not actually stop the child inbox, only simulate the liveness check.ActorSystemStub
system()
TheActorSystem
to which this Actor belongs.java.lang.String
toString()
scala.collection.immutable.List<T>
unhandledMessages()
Messages that are marked as unhandled.<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 message)
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, 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
-
-
-
-
Method Detail
-
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>
-
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)
-
childInbox
public <U> TestInboxImpl<U> childInbox(ActorRef<U> child)
Retrieve the inbox representing the given child actor. The passed ActorRef must be one that was returned by one of the spawn methods earlier.- Parameters:
child
- (undocumented)- Returns:
- (undocumented)
-
childInbox
public <U> scala.Option<TestInboxImpl<U>> childInbox(java.lang.String name)
Retrieve the inbox representing the child actor with the given name.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
childTestKit
public <U> BehaviorTestKitImpl<U> childTestKit(ActorRef<U> child)
Retrieve the BehaviorTestKit for the given child actor. The passed ActorRef must be one that was returned by one of the spawn methods earlier.- Parameters:
child
- (undocumented)- Returns:
- (undocumented)
-
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)
-
childrenNames
public scala.collection.Iterable<java.lang.String> childrenNames()
-
classicActorContext
public scala.runtime.Nothing$ classicActorContext()
- Specified by:
classicActorContext
in interfaceClassicActorContextProvider
-
clearLog
public void clearLog()
Clear the log entries.
-
clearUnhandled
public void clearUnhandled()
Clear the list of captured unhandled messages.
-
currentBehavior
public Behavior<T> currentBehavior()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
currentBehavior
in interfaceActorContext<T>
- Returns:
- (undocumented)
-
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)
-
internalSpawnMessageAdapter
public <U> ActorRef<U> internalSpawnMessageAdapter(scala.Function1<U,T> f, java.lang.String name)
INTERNAL API- 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)
-
logEntries
public scala.collection.immutable.List<CapturedLogEvent> logEntries()
The log entries logged through context.log.{debug, info, warn, error} are captured and can be inspected through this method.- Returns:
- (undocumented)
-
onUnhandled
public void onUnhandled(T msg)
Description copied from interface:ActorContext
INTERNAL API- Specified by:
onUnhandled
in interfaceActorContext<T>
- Parameters:
msg
- (undocumented)
-
path
public ActorPath path()
-
removeChildInbox
public void removeChildInbox(ActorRef<scala.runtime.Nothing$> child)
Remove the given inbox from the list of children, for example after having simulated its termination.- Parameters:
child
- (undocumented)
-
scheduleOnce
public <U> Cancellable scheduleOnce(scala.concurrent.duration.FiniteDuration delay, ActorRef<U> target, U message)
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)message
- (undocumented)- Returns:
- (undocumented)
-
self
public 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)
-
selfInbox
public TestInboxImpl<T> selfInbox()
INTERNAL API- 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)
-
setReceiveTimeout
public void setReceiveTimeout(scala.concurrent.duration.FiniteDuration d, T message)
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)message
- (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)
-
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)
-
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)
-
spawnAnonymous$default$2
public <U> Props spawnAnonymous$default$2()
- Specified by:
spawnAnonymous$default$2
in interfaceActorContext<T>
-
stop
public <U> void stop(ActorRef<U> child)
Do not actually stop the child inbox, only simulate the liveness check. Removal is asynchronous, explicit removeInbox is needed from outside afterwards.- Specified by:
stop
in interfaceActorContext<T>
- Specified by:
stop
in interfaceActorContext<T>
- Parameters:
child
- (undocumented)
-
system
public ActorSystemStub 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)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
unhandledMessages
public scala.collection.immutable.List<T> unhandledMessages()
Messages that are marked as unhandled.- Returns:
- (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)
-
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 message)
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)message
- (undocumented)
-
-