Interface ActorContextImpl<T>
-
- All Superinterfaces:
ActorContext<T>
,ActorContext<T>
,ClassicActorContextProvider
,TypedActorContext<T>
public interface ActorContextImpl<T> extends TypedActorContext<T>, ActorContext<T>, ActorContext<T>
INTERNAL API
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ActorContextImpl.LoggingContext
static class
ActorContextImpl.LoggingContext$
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
_currentActorThread_$eq(<any> x$1)
void
_logging_$eq(<any> x$1)
void
_messageAdapters_$eq(scala.collection.immutable.List<scala.Tuple2<java.lang.Class<?>,scala.Function1<java.lang.Object,T>>> x$1)
void
_timer_$eq(<any> x$1)
ActorContext<T>
asJava()
Get thejavadsl
of thisActorContext
.<Req,Res>
voidask(java.lang.Class<Res> resClass, RecipientRef<Req> target, java.time.Duration responseTimeout, Function<ActorRef<Res>,Req> createRequest, Function2<Res,java.lang.Throwable,T> applyToResponse)
Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.<Req,Res>
voidask(RecipientRef<Req> target, scala.Function1<ActorRef<Res>,Req> createRequest, scala.Function1<scala.util.Try<Res>,T> mapResponse, Timeout responseTimeout, scala.reflect.ClassTag<Res> classTag)
Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.<Req,Res>
voidaskWithStatus(java.lang.Class<Res> resClass, RecipientRef<Req> target, java.time.Duration responseTimeout, Function<ActorRef<StatusReply<Res>>,Req> createRequest, Function2<Res,java.lang.Throwable,T> applyToResponse)
The same asActorContext.<Req,Res>ask(java.lang.Class<Res>,org.apache.pekko.actor.typed.RecipientRef<Req>,java.time.Duration,org.apache.pekko.japi.function.Function<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,org.apache.pekko.japi.function.Function2<Res,java.lang.Throwable,T>)
but only for requests that result in a response of typepekko.pattern.StatusReply
.<Req,Res>
voidaskWithStatus(RecipientRef<Req> target, scala.Function1<ActorRef<StatusReply<Res>>,Req> createRequest, scala.Function1<scala.util.Try<Res>,T> mapResponse, Timeout responseTimeout, scala.reflect.ClassTag<Res> classTag)
The same asActorContext.<Req,Res>ask(org.apache.pekko.actor.typed.RecipientRef<Req>,scala.Function1<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,scala.Function1<scala.util.Try<Res>,T>,org.apache.pekko.util.Timeout,scala.reflect.ClassTag<Res>)
but only for requests that result in a response of typepekko.pattern.StatusReply
.ActorContext<T>
asScala()
Get thescaladsl
of thisActorContext
.void
cancelAllTimers()
INTERNAL APIvoid
checkCurrentActorThread()
INTERNAL APIvoid
clearCurrentActorThread()
INTERNAL APIvoid
clearMdc()
INTERNAL APIBehavior<T>
delegate(Behavior<T> delegator, T msg)
Delegate message and signal's execution by givenpekko.actor.typed.Behavior
usingBehavior.interpretMessage
orBehavior.interpretSignal
java.util.Optional<ActorRef<java.lang.Void>>
getChild(java.lang.String name)
The named child Actor if it is alive.java.util.List<ActorRef<java.lang.Void>>
getChildren()
The list of child Actors created by this Actor during its lifetime that are still alive, in no particular order.scala.concurrent.ExecutionContextExecutor
getExecutionContext()
This Actor’s execution context.org.slf4j.Logger
getLog()
An actor specific logger.ActorRef<T>
getSelf()
The identity of this Actor, bound to the lifecycle of this Actor instance.ActorSystem<java.lang.Void>
getSystem()
TheActorSystem
to which this Actor belongs.boolean
hasCustomLoggerName()
boolean
hasTimer()
INTERNAL API<U> ActorRef<U>
internalMessageAdapter(java.lang.Class<U> messageClass, scala.Function1<U,T> f)
<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.org.slf4j.Logger
log()
An actor specific logger.ActorContextImpl.LoggingContext
loggingContext()
<U> ActorRef<U>
messageAdapter(java.lang.Class<U> messageClass, Function<U,T> f)
Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.<U> ActorRef<U>
messageAdapter(scala.Function1<U,T> f, scala.reflect.ClassTag<U> evidence$1)
Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.void
messageAdapterRef_$eq(<any> x$1)
scala.collection.immutable.List<scala.Tuple2<java.lang.Class<?>,scala.Function1<java.lang.Object,T>>>
messageAdapters()
INTERNAL APITimerSchedulerCrossDslSupport<T>
mkTimer()
<Value> void
pipeToSelf(java.util.concurrent.CompletionStage<Value> future, Function2<Value,java.lang.Throwable,T> applyToResult)
Sends the result of the givenCompletionStage
to this Actor (“self
”), after adapted it with the given function.<Value> void
pipeToSelf(scala.concurrent.Future<Value> future, scala.Function1<scala.util.Try<Value>,T> mapResult)
Sends the result of the givenFuture
to this Actor (“self
”), after adapted it with the given function.<U> Cancellable
scheduleOnce(java.time.Duration 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.void
setCurrentActorThread()
INTERNAL APIvoid
setLoggerName(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 name as logger name.void
setLoggerName(java.lang.String name)
Replace the current logger (or initialize a new logger if the logger was not touched before) with one that has ghe given name as logger name.void
setReceiveTimeout(java.time.Duration duration, 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)
Create a child Actor from the givenpekko.actor.typed.Behavior
and with the given name.<U> ActorRef<U>
spawnAnonymous(Behavior<U> behavior)
Create a child Actor from the givenpekko.actor.typed.Behavior
under a randomly chosen name.<U> ActorRef<U>
spawnMessageAdapter(scala.Function1<U,T> f)
INTERNAL API: SeespawnMessageAdapter
with name parameter<U> ActorRef<U>
spawnMessageAdapter(scala.Function1<U,T> f, java.lang.String name)
INTERNAL API: It is currently internal because it's too easy to create resource leaks by spawning adapters without stopping them.TimerSchedulerCrossDslSupport<T>
timer()
-
Methods inherited from interface org.apache.pekko.actor.typed.javadsl.ActorContext
cancelReceiveTimeout, spawn, spawnAnonymous, stop, unwatch, watch, watchWith
-
Methods inherited from interface org.apache.pekko.actor.typed.scaladsl.ActorContext
cancelReceiveTimeout, child, children, currentBehavior, executionContext, onUnhandled, scheduleOnce, self, setReceiveTimeout, spawn, spawn$default$3, spawnAnonymous, spawnAnonymous$default$2, stop, system, unwatch, watch, watchWith
-
Methods inherited from interface org.apache.pekko.actor.ClassicActorContextProvider
classicActorContext
-
-
-
-
Method Detail
-
_logging_$eq
void _logging_$eq(<any> x$1)
-
messageAdapterRef_$eq
void messageAdapterRef_$eq(<any> x$1)
-
_messageAdapters_$eq
void _messageAdapters_$eq(scala.collection.immutable.List<scala.Tuple2<java.lang.Class<?>,scala.Function1<java.lang.Object,T>>> x$1)
-
_timer_$eq
void _timer_$eq(<any> x$1)
-
_currentActorThread_$eq
void _currentActorThread_$eq(<any> x$1)
-
timer
TimerSchedulerCrossDslSupport<T> timer()
-
mkTimer
TimerSchedulerCrossDslSupport<T> mkTimer()
-
hasTimer
boolean hasTimer()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
hasTimer
in interfaceActorContext<T>
-
cancelAllTimers
void cancelAllTimers()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
cancelAllTimers
in interfaceActorContext<T>
-
asJava
ActorContext<T> asJava()
Description copied from interface:TypedActorContext
Get thejavadsl
of thisActorContext
.- Specified by:
asJava
in interfaceActorContext<T>
- Specified by:
asJava
in interfaceTypedActorContext<T>
-
asScala
ActorContext<T> asScala()
Description copied from interface:TypedActorContext
Get thescaladsl
of thisActorContext
.- Specified by:
asScala
in interfaceActorContext<T>
- Specified by:
asScala
in interfaceTypedActorContext<T>
-
getChild
java.util.Optional<ActorRef<java.lang.Void>> getChild(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
CompletionStage
callbacks.- Specified by:
getChild
in interfaceActorContext<T>
-
getChildren
java.util.List<ActorRef<java.lang.Void>> getChildren()
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
CompletionStage
callbacks.- Specified by:
getChildren
in interfaceActorContext<T>
-
getExecutionContext
scala.concurrent.ExecutionContextExecutor getExecutionContext()
Description copied from interface:ActorContext
This Actor’s execution context. It can be used to run asynchronous tasks likeFuture
combinators.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
getExecutionContext
in interfaceActorContext<T>
-
getSelf
ActorRef<T> getSelf()
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 method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
getSelf
in interfaceActorContext<T>
-
getSystem
ActorSystem<java.lang.Void> getSystem()
Description copied from interface:ActorContext
TheActorSystem
to which this Actor belongs.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
getSystem
in interfaceActorContext<T>
-
loggingContext
ActorContextImpl.LoggingContext loggingContext()
-
log
org.slf4j.Logger log()
Description copied from interface:ActorContext
An actor specific logger.The logger name will be 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 changed with
setLoggerName
.*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>
-
getLog
org.slf4j.Logger getLog()
Description copied from interface:ActorContext
An actor specific logger.The logger name will be 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 changed with
setLoggerName
.*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:
getLog
in interfaceActorContext<T>
-
setLoggerName
void setLoggerName(java.lang.String name)
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 name as logger name. Logger source MDC entry "pekkoSource" will be the 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:
setLoggerName
in interfaceActorContext<T>
- Specified by:
setLoggerName
in interfaceActorContext<T>
-
setLoggerName
void setLoggerName(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 name as logger name. Logger source MDC entry "pekkoSource" will be the 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:
setLoggerName
in interfaceActorContext<T>
- Specified by:
setLoggerName
in interfaceActorContext<T>
-
hasCustomLoggerName
boolean hasCustomLoggerName()
-
clearMdc
void clearMdc()
Description copied from interface:ActorContext
INTERNAL API- Specified by:
clearMdc
in interfaceActorContext<T>
-
setReceiveTimeout
void setReceiveTimeout(java.time.Duration duration, 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
CompletionStage
callbacks.- Specified by:
setReceiveTimeout
in interfaceActorContext<T>
-
scheduleOnce
<U> Cancellable scheduleOnce(java.time.Duration 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 invokingpekko.actor.Cancellable#cancel
on the returned handle.For scheduling messages to the actor itself, use
Behaviors.withTimers
This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
scheduleOnce
in interfaceActorContext<T>
-
spawn
<U> ActorRef<U> spawn(Behavior<U> behavior, java.lang.String name)
Description copied from interface:ActorContext
Create a child Actor from the givenpekko.actor.typed.Behavior
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>
-
spawnAnonymous
<U> ActorRef<U> spawnAnonymous(Behavior<U> behavior)
Description copied from interface:ActorContext
Create a child Actor from the givenpekko.actor.typed.Behavior
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>
-
delegate
Behavior<T> delegate(Behavior<T> delegator, T msg)
Description copied from interface:ActorContext
Delegate message and signal's execution by givenpekko.actor.typed.Behavior
usingBehavior.interpretMessage
orBehavior.interpretSignal
note: if given
pekko.actor.typed.Behavior
resultingBehaviors.same
that will cause context switching to the given behavior and if result isBehaviors.unhandled
that will trigger thepekko.actor.typed.scaladsl.ActorContext.onUnhandled
then switching to the given behavior.- Specified by:
delegate
in interfaceActorContext<T>
- Specified by:
delegate
in interfaceActorContext<T>
-
ask
<Req,Res> void ask(RecipientRef<Req> target, scala.Function1<ActorRef<Res>,Req> createRequest, scala.Function1<scala.util.Try<Res>,T> mapResponse, Timeout responseTimeout, scala.reflect.ClassTag<Res> classTag)
Description copied from interface:ActorContext
Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.The interaction has a timeout (to avoid a resource leak). If the timeout hits without any response it will be passed as a
Failure(
TimeoutException
)
to themapResponse
function (this is the only "normal" way aFailure
is passed to the function).For other messaging patterns with other actors, see
ActorContext.messageAdapter(scala.Function1<U, T>, scala.reflect.ClassTag<U>)
.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:
ask
in interfaceActorContext<T>
createRequest
- A function that creates a message for the other actor, containing the providedActorRef[Res]
that the other actor can send a message back through.mapResponse
- Transforms the response from thetarget
into a message this actor understands. Should be a pure function but is executed inside the actor when the response arrives so can safely touch the actor internals. If this function throws an exception it is just as if the normal message receiving logic would throw.
-
askWithStatus
<Req,Res> void askWithStatus(RecipientRef<Req> target, scala.Function1<ActorRef<StatusReply<Res>>,Req> createRequest, scala.Function1<scala.util.Try<Res>,T> mapResponse, Timeout responseTimeout, scala.reflect.ClassTag<Res> classTag)
Description copied from interface:ActorContext
The same asActorContext.<Req,Res>ask(org.apache.pekko.actor.typed.RecipientRef<Req>,scala.Function1<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,scala.Function1<scala.util.Try<Res>,T>,org.apache.pekko.util.Timeout,scala.reflect.ClassTag<Res>)
but only for requests that result in a response of typepekko.pattern.StatusReply
. If the response is apekko.pattern.StatusReply.Success
the returned future is completed successfully with the wrapped response. If the status response is apekko.pattern.StatusReply.Error
the returned future will be failed with the exception in the error (normally apekko.pattern.StatusReply.ErrorMessage
).- Specified by:
askWithStatus
in interfaceActorContext<T>
-
ask
<Req,Res> void ask(java.lang.Class<Res> resClass, RecipientRef<Req> target, java.time.Duration responseTimeout, Function<ActorRef<Res>,Req> createRequest, Function2<Res,java.lang.Throwable,T> applyToResponse)
Description copied from interface:ActorContext
Perform a single request-response message interaction with another actor, and transform the messages back to the protocol of this actor.The interaction has a timeout (to avoid a resource leak). If the timeout hits without any response it will be passed as an
TimeoutException
to theapplyToResponse
function.For other messaging patterns with other actors, see
ActorContext.messageAdapter(java.lang.Class<U>, org.apache.pekko.japi.function.Function<U, T>)
.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
ask
in interfaceActorContext<T>
createRequest
- A function that creates a message for the other actor, containing the providedActorRef[Res]
that the other actor can send a message back through.applyToResponse
- Transforms the response from thetarget
into a message this actor understands. Will be invoked with either the response message or an AskTimeoutException failed or potentially another exception if the remote actor is classic and sent apekko.actor.Status.Failure
as response. The returned message of typeT
is then fed into this actor as a message. Should be a pure function but is executed inside the actor when the response arrives so can safely touch the actor internals. If this function throws an exception it is just as if the normal message receiving logic would throw.
-
askWithStatus
<Req,Res> void askWithStatus(java.lang.Class<Res> resClass, RecipientRef<Req> target, java.time.Duration responseTimeout, Function<ActorRef<StatusReply<Res>>,Req> createRequest, Function2<Res,java.lang.Throwable,T> applyToResponse)
Description copied from interface:ActorContext
The same asActorContext.<Req,Res>ask(java.lang.Class<Res>,org.apache.pekko.actor.typed.RecipientRef<Req>,java.time.Duration,org.apache.pekko.japi.function.Function<org.apache.pekko.actor.typed.ActorRef<Res>,Req>,org.apache.pekko.japi.function.Function2<Res,java.lang.Throwable,T>)
but only for requests that result in a response of typepekko.pattern.StatusReply
. If the response is apekko.pattern.StatusReply#success
the returned future is completed successfully with the wrapped response. If the status response is apekko.pattern.StatusReply#error
the returned future will be failed with the exception in the error (normally apekko.pattern.StatusReply.ErrorMessage
).- Specified by:
askWithStatus
in interfaceActorContext<T>
-
pipeToSelf
<Value> void pipeToSelf(scala.concurrent.Future<Value> future, scala.Function1<scala.util.Try<Value>,T> mapResult)
Description copied from interface:ActorContext
Sends the result of the givenFuture
to this Actor (“self
”), after adapted it with the given function.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:
pipeToSelf
in interfaceActorContext<T>
-
pipeToSelf
<Value> void pipeToSelf(java.util.concurrent.CompletionStage<Value> future, Function2<Value,java.lang.Throwable,T> applyToResult)
Description copied from interface:ActorContext
Sends the result of the givenCompletionStage
to this Actor (“self
”), after adapted it with the given function.This method is thread-safe and can be called from other threads than the ordinary actor message processing thread, such as
CompletionStage
callbacks.- Specified by:
pipeToSelf
in interfaceActorContext<T>
-
spawnMessageAdapter
<U> ActorRef<U> spawnMessageAdapter(scala.Function1<U,T> f, java.lang.String name)
Description copied from interface:ActorContext
INTERNAL API: It is currently internal because it's too easy to create resource leaks by spawning adapters without stopping them.messageAdapter
is the public API.Create a "lightweight" child actor that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor. You are strongly advised to cache these ActorRefs or to stop them when no longer needed.
The name of the child actor will be composed of a unique identifier starting with a dollar sign to which the given
name
argument is appended, with an inserted hyphen between these two parts. Therefore the givenname
argument does not need to be unique within the scope of the parent actor.The function is applied inside the "parent" actor and can safely access state of the "parent".
- Specified by:
spawnMessageAdapter
in interfaceActorContext<T>
-
spawnMessageAdapter
<U> ActorRef<U> spawnMessageAdapter(scala.Function1<U,T> f)
Description copied from interface:ActorContext
INTERNAL API: SeespawnMessageAdapter
with name parameter- Specified by:
spawnMessageAdapter
in interfaceActorContext<T>
-
internalSpawnMessageAdapter
<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. Otherwise "ambiguous reference to overloaded definition" because Function is lambda.
-
messageAdapter
<U> ActorRef<U> messageAdapter(scala.Function1<U,T> f, scala.reflect.ClassTag<U> evidence$1)
Description copied from interface:ActorContext
Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.You can register several message adapters for different message classes. It's only possible to have one message adapter per message class to make sure that the number of adapters are not growing unbounded if registered repeatedly. That also means that a registered adapter will replace an existing adapter for the same message class.
A message adapter will be used if the message class matches the given class or is a subclass thereof. The registered adapters are tried in reverse order of their registration order, i.e. the last registered first.
A message adapter (and the returned
ActorRef
) has the same lifecycle as this actor. It's recommended to register the adapters in a top levelBehaviors.setup
or constructor ofAbstractBehavior
but it's possible to register them later also if needed. Message adapters don't have to be stopped since they consume no resources other than an entry in an internalMap
and the number of adapters are bounded since it's only possible to have one per message class. * The function is running in this actor and can safely access state of it.*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:
messageAdapter
in interfaceActorContext<T>
-
messageAdapter
<U> ActorRef<U> messageAdapter(java.lang.Class<U> messageClass, Function<U,T> f)
Description copied from interface:ActorContext
Create a message adapter that will convert or wrap messages such that other Actor’s protocols can be ingested by this Actor.You can register several message adapters for different message classes. It's only possible to have one message adapter per message class to make sure that the number of adapters are not growing unbounded if registered repeatedly. That also means that a registered adapter will replace an existing adapter for the same message class.
A message adapter will be used if the message class matches the given class or is a subclass thereof. The registered adapters are tried in reverse order of their registration order, i.e. the last registered first.
A message adapter (and the returned
ActorRef
) has the same lifecycle as this actor. It's recommended to register the adapters in a top levelBehaviors.setup
or constructor ofAbstractBehavior
but it's possible to register them later also if needed. Message adapters don't have to be stopped since they consume no resources other than an entry in an internalMap
and the number of adapters are bounded since it's only possible to have one per message class.The function is running in this actor and can safely access state of it.
*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:
messageAdapter
in interfaceActorContext<T>
-
internalMessageAdapter
<U> ActorRef<U> internalMessageAdapter(java.lang.Class<U> messageClass, scala.Function1<U,T> f)
-
messageAdapters
scala.collection.immutable.List<scala.Tuple2<java.lang.Class<?>,scala.Function1<java.lang.Object,T>>> messageAdapters()
INTERNAL API
-
setCurrentActorThread
void setCurrentActorThread()
INTERNAL API- Specified by:
setCurrentActorThread
in interfaceActorContext<T>
-
clearCurrentActorThread
void clearCurrentActorThread()
INTERNAL API- Specified by:
clearCurrentActorThread
in interfaceActorContext<T>
-
checkCurrentActorThread
void checkCurrentActorThread()
INTERNAL API- Specified by:
checkCurrentActorThread
in interfaceActorContext<T>
-
-