Package akka.actor

Class ActorSelection

  • All Implemented Interfaces:
    java.io.Serializable, scala.Serializable

    public abstract class ActorSelection
    extends java.lang.Object
    implements scala.Serializable
    An ActorSelection is a logical view of a section of an ActorSystem's tree of Actors, allowing for broadcasting of messages to that section.
    See Also:
    Serialized Form
    • Constructor Detail

      • ActorSelection

        public ActorSelection()
    • Method Detail

      • apply

        public static ActorSelection apply​(ActorRef anchorRef,
                                           java.lang.String path)
        Construct an ActorSelection from the given string representing a path relative to the given target. This operation has to create all the matching magic, so it is preferable to cache its result if the intention is to send messages frequently.
        Parameters:
        anchorRef - (undocumented)
        path - (undocumented)
        Returns:
        (undocumented)
      • apply

        public static ActorSelection apply​(ActorRef anchorRef,
                                           scala.collection.Iterable<java.lang.String> elements)
        Construct an ActorSelection from the given string representing a path relative to the given target. This operation has to create all the matching magic, so it is preferable to cache its result if the intention is to send messages frequently.
        Parameters:
        anchorRef - (undocumented)
        elements - (undocumented)
        Returns:
        (undocumented)
      • deliverSelection

        public static void deliverSelection​(InternalActorRef anchor,
                                            ActorRef sender,
                                            ActorSelectionMessage sel)
        INTERNAL API The receive logic for ActorSelectionMessage. The idea is to recursively descend as far as possible with local refs and hand over to that &ldquo;foreign&rdquo; child when we encounter it.
        Parameters:
        anchor - (undocumented)
        sender - (undocumented)
        sel - (undocumented)
      • anchor

        protected abstract ActorRef anchor()
      • tell

        public void tell​(java.lang.Object msg,
                         ActorRef sender)
        Sends the specified message to this ActorSelection, i.e. fire-and-forget semantics, including the sender reference if possible.

        Pass ActorRef.noSender() or null as sender if there is nobody to reply to

        Parameters:
        msg - (undocumented)
        sender - (undocumented)
      • forward

        public void forward​(java.lang.Object message,
                            ActorContext context)
        Forwards the message and passes the original sender actor as the sender.

        Works, no matter whether originally sent with tell/'!' or ask/'?'.

        Parameters:
        message - (undocumented)
        context - (undocumented)
      • resolveOne

        public scala.concurrent.Future<ActorRef> resolveOne​(Timeout timeout)
        Resolve the ActorRef matching this selection. The result is returned as a Future that is completed with the ActorRef if such an actor exists. It is completed with failure ActorNotFound if no such actor exists or the identification didn't complete within the supplied timeout.

        Under the hood it talks to the actor to verify its existence and acquire its ActorRef.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • resolveOne

        public scala.concurrent.Future<ActorRef> resolveOne​(scala.concurrent.duration.FiniteDuration timeout)
        Resolve the ActorRef matching this selection. The result is returned as a Future that is completed with the ActorRef if such an actor exists. It is completed with failure ActorNotFound if no such actor exists or the identification didn't complete within the supplied timeout.

        Under the hood it talks to the actor to verify its existence and acquire its ActorRef.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • resolveOneCS

        public java.util.concurrent.CompletionStage<ActorRef> resolveOneCS​(scala.concurrent.duration.FiniteDuration timeout)
        Deprecated.
        Use the overloaded method resolveOne which accepts java.time.Duration instead. Since 2.5.20.
        Java API for resolveOne(akka.util.Timeout)

        Resolve the ActorRef matching this selection. The result is returned as a CompletionStage that is completed with the ActorRef if such an actor exists. It is completed with failure ActorNotFound if no such actor exists or the identification didn't complete within the supplied timeout.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • resolveOneCS

        public java.util.concurrent.CompletionStage<ActorRef> resolveOneCS​(java.time.Duration timeout)
        Deprecated.
        Use the overloaded method resolveOne which accepts java.time.Duration instead. Since 2.5.20.
        Java API for resolveOne(akka.util.Timeout)

        Resolve the ActorRef matching this selection. The result is returned as a CompletionStage that is completed with the ActorRef if such an actor exists. It is completed with failure ActorNotFound if no such actor exists or the identification didn't complete within the supplied timeout.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • resolveOne

        public java.util.concurrent.CompletionStage<ActorRef> resolveOne​(java.time.Duration timeout)
        Java API for resolveOne(akka.util.Timeout)

        Resolve the ActorRef matching this selection. The result is returned as a CompletionStage that is completed with the ActorRef if such an actor exists. It is completed with failure ActorNotFound if no such actor exists or the identification didn't complete within the supplied timeout.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • anchorPath

        public ActorPath anchorPath()
        The ActorPath of the anchor actor.
        Returns:
        (undocumented)
      • pathString

        public java.lang.String pathString()
        String representation of the path elements, starting with "/" and separated with "/".
        Returns:
        (undocumented)
      • toSerializationFormat

        public java.lang.String toSerializationFormat()
        String representation of the actor selection suitable for storage and recreation. The output is similar to the URI fragment returned by ActorPath.toSerializationFormat().
        Returns:
        URI fragment
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object