Class FunctionRef
- java.lang.Object
-
- akka.actor.ActorRef
-
- akka.actor.InternalActorRef
-
- akka.actor.FunctionRef
-
- All Implemented Interfaces:
ActorRefScope
,LocalRef
,MinimalActorRef
,ScalaActorRef
,java.io.Serializable
,java.lang.Comparable<ActorRef>
public final class FunctionRef extends InternalActorRef implements MinimalActorRef
INTERNAL APIThis kind of ActorRef passes all received messages to the given function for performing a non-blocking side-effect. The intended use is to transform the message before sending to the real target actor. Such references can be created by calling
ActorCell.addFunctionRef
and must be deregistered when no longer needed by callingActorCell.removeFunctionRef
. FunctionRefs do not count towards the live children of an actor, they do not receive the Terminate command and do not prevent the parent from terminating. FunctionRef is properly registered for remote lookup and ActorSelection.It can both be watched by other actors and also
watch(akka.actor.ActorRef)
other actors. When watching other actors and upon receiving the Terminated message,unwatch(akka.actor.ActorRef)
must be called to avoid a resource leak, which is different from an ordinary actor.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FunctionRef(ActorPath path, ActorRefProvider provider, ActorSystem system, scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit> f)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
$bang(java.lang.Object message, ActorRef sender)
Scala API: Sends a one-way asynchronous message.ActorRef
$bang$default$2(java.lang.Object message)
static scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit>
deadLetterMessageHandler(ActorSystem system)
boolean
isTerminated()
INTERNAL APIboolean
isWatching(ActorRef actorRef)
Query whether this FunctionRef is currently watching the given Actor.ActorPath
path()
Returns the path for this actor (from this actor up to the root actor).ActorRefProvider
provider()
Get a reference to the actor ref provider which created this ref.void
sendSystemMessage(SystemMessage message)
protected void
sendTerminated()
void
stop()
void
unwatch(ActorRef actorRef)
Have this FunctionRef unwatch the given Actor.void
watch(ActorRef actorRef)
Have this FunctionRef watch the given Actor.-
Methods inherited from class akka.actor.InternalActorRef
getChild, getParent, isLocal, isTemporaryRef, restart, resume, start, suspend
-
Methods inherited from class akka.actor.ActorRef
compareTo, equals, forward, hashCode, noSender, tell, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface akka.actor.MinimalActorRef
getChild, getParent, restart, resume, start, suspend, writeReplace
-
-
-
-
Constructor Detail
-
FunctionRef
public FunctionRef(ActorPath path, ActorRefProvider provider, ActorSystem system, scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit> f)
-
-
Method Detail
-
deadLetterMessageHandler
public static scala.Function2<ActorRef,java.lang.Object,scala.runtime.BoxedUnit> deadLetterMessageHandler(ActorSystem system)
-
path
public ActorPath path()
Description copied from class:ActorRef
Returns the path for this actor (from this actor up to the root actor).
-
provider
public ActorRefProvider provider()
Description copied from class:InternalActorRef
Get a reference to the actor ref provider which created this ref.- Specified by:
provider
in classInternalActorRef
-
$bang
public void $bang(java.lang.Object message, ActorRef sender)
Description copied from class:ActorRef
Scala API: Sends a one-way asynchronous message. E.g. fire-and-forget semantics.If invoked from within an actor then the actor reference is implicitly passed on as the implicit 'sender' argument.
This actor 'sender' reference is then available in the receiving actor in the 'sender()' member variable, if invoked from within an Actor. If not then no sender is available.
actor ! message
- Specified by:
$bang
in interfaceMinimalActorRef
- Specified by:
$bang
in interfaceScalaActorRef
- Specified by:
$bang
in classActorRef
-
sendSystemMessage
public void sendSystemMessage(SystemMessage message)
- Specified by:
sendSystemMessage
in interfaceMinimalActorRef
- Specified by:
sendSystemMessage
in classInternalActorRef
-
isTerminated
public boolean isTerminated()
INTERNAL API- Specified by:
isTerminated
in interfaceMinimalActorRef
- Specified by:
isTerminated
in classInternalActorRef
-
sendTerminated
protected void sendTerminated()
-
stop
public void stop()
- Specified by:
stop
in interfaceMinimalActorRef
- Specified by:
stop
in classInternalActorRef
-
watch
public void watch(ActorRef actorRef)
Have this FunctionRef watch the given Actor.Upon receiving the Terminated message,
unwatch
must be called to avoid resource leak, which is different from an ordinary actor.
-
unwatch
public void unwatch(ActorRef actorRef)
Have this FunctionRef unwatch the given Actor.Upon receiving the Terminated message,
unwatch
must be called to avoid resource leak, which is different from an ordinary actor.
-
isWatching
public boolean isWatching(ActorRef actorRef)
Query whether this FunctionRef is currently watching the given Actor.
-
$bang$default$2
public ActorRef $bang$default$2(java.lang.Object message)
- Specified by:
$bang$default$2
in interfaceMinimalActorRef
- Specified by:
$bang$default$2
in interfaceScalaActorRef
- Overrides:
$bang$default$2
in classActorRef
-
-