Class StubbedActorContext<T>

    • Constructor Detail

      • StubbedActorContext

        public StubbedActorContext​(ActorPath path,
                                   scala.Function0<Behavior<T>> currentBehaviorProvider)
      • StubbedActorContext

        public StubbedActorContext​(java.lang.String name,
                                   scala.Function0<Behavior<T>> currentBehaviorProvider)
    • 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 interface ActorContext<T>
        Specified by:
        cancelReceiveTimeout in interface ActorContext<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 interface ActorContext<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 interface ActorContext<T>
        Returns:
        (undocumented)
      • childrenNames

        public scala.collection.Iterable<java.lang.String> childrenNames()
      • clearLog

        public void clearLog()
        Clear the log entries.
      • clearUnhandled

        public void clearUnhandled()
        Clear the list of captured unhandled messages.
      • executionContext

        public scala.concurrent.ExecutionContextExecutor executionContext()
        Description copied from interface: ActorContext
        This Actor&rsquo;s execution context. It can be used to run asynchronous tasks like Future 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 interface ActorContext<T>
        Returns:
        (undocumented)
      • internalSpawnMessageAdapter

        public <U> ActorRef<U> internalSpawnMessageAdapter​(scala.Function1<U,​T> f,
                                                           java.lang.String name)
        INTERNAL API
        Specified by:
        internalSpawnMessageAdapter in interface ActorContextImpl<T>
        Parameters:
        f - (undocumented)
        name - (undocumented)
        Returns:
        (undocumented)
      • log

        public 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 interface ActorContext<T>
        Specified by:
        log in interface ActorContextImpl<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 interface ActorContext<T>
        Parameters:
        msg - (undocumented)
      • 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 invoking Cancellable.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 interface ActorContext<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 different ActorRef.

        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 interface ActorContext<T>
        Returns:
        (undocumented)
      • selfInbox

        public TestInboxImpl<T> selfInbox()
        INTERNAL API
        Returns:
        (undocumented)
      • setLoggerName

        public 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 "akkaSource" 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 interface ActorContext<T>
        Specified by:
        setLoggerName in interface ActorContext<T>
        Specified by:
        setLoggerName in interface ActorContextImpl<T>
        Parameters:
        name - (undocumented)
      • setLoggerName

        public 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 "akkaSource" 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 interface ActorContext<T>
        Specified by:
        setLoggerName in interface ActorContext<T>
        Specified by:
        setLoggerName in interface ActorContextImpl<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. Use cancelReceiveTimeout 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 interface ActorContext<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 given 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 interface ActorContext<T>
        Specified by:
        spawn in interface ActorContext<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 given 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 Future callbacks.

        Specified by:
        spawn$default$3 in interface ActorContext<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 given 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 interface ActorContext<T>
        Specified by:
        spawnAnonymous in interface ActorContext<T>
        Parameters:
        behavior - (undocumented)
        props - (undocumented)
        Returns:
        (undocumented)
      • 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 interface ActorContext<T>
        Specified by:
        stop in interface ActorContext<T>
        Parameters:
        child - (undocumented)
      • system

        public ActorSystemStub system()
        Description copied from interface: ActorContext
        The ActorSystem 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 interface ActorContext<T>
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 by watch. A Terminated 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 interface ActorContext<T>
        Specified by:
        unwatch in interface ActorContext<T>
        Parameters:
        other - (undocumented)
      • watch

        public <U> void watch​(ActorRef<U> other)
        Description copied from interface: ActorContext
        Register for Terminated notification once the Actor identified by the given ActorRef 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 with watchWith.

        It will fail with an IllegalStateException if the same subject was watched before using watchWith. 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 interface ActorContext<T>
        Specified by:
        watch in interface ActorContext<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 given ActorRef 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 same msg and not mixed with watch.

        It will fail with an IllegalStateException if the same subject was watched before using watch or watchWith 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 interface ActorContext<T>
        Specified by:
        watchWith in interface ActorContext<T>
        Parameters:
        other - (undocumented)
        message - (undocumented)