akka.actor
Class RepointableActorRef

java.lang.Object
  extended by akka.actor.ActorRef
      extended by akka.actor.InternalActorRef
          extended by akka.actor.ActorRefWithCell
              extended by akka.actor.RepointableActorRef
All Implemented Interfaces:
ActorRefScope, RepointableRef, ScalaActorRef, java.io.Serializable, java.lang.Comparable<ActorRef>
Direct Known Subclasses:
RoutedActorRef

public class RepointableActorRef
extends ActorRefWithCell
implements RepointableRef

This actor ref starts out with some dummy cell (by default just enqueuing messages into vectors protected by ReentrantLock), it must be initialize()&rsquo;d before it can be sent to, and it will be activate()&rsquo;d by its supervisor in response to the Supervise() message, which will replace the contained Cell with a fully functional one, transfer all messages from dummy to real queue and swap out the cell ref.

See Also:
Serialized Form

Constructor Summary
RepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, InternalActorRef supervisor, ActorPath path)
           
 
Method Summary
 scala.collection.immutable.Iterable<ActorRef> children()
           
 MessageDispatcher dispatcher()
           
 InternalActorRef getChild(scala.collection.Iterator<java.lang.String> name)
          Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location.
 InternalActorRef getParent()
          Obtain parent of this ref; used by getChild for ".." paths.
 InternalActorRef getSingleChild(java.lang.String name)
          Method for looking up a single child beneath this actor.
 RepointableActorRef initialize(boolean async)
          Initialize: make a dummy cell which holds just a mailbox, then tell our supervisor that we exist so that he can create the real Cell in handleSupervise().
 boolean isLocal()
          Scope: if this ref points to an actor which resides within the same JVM, i.e.
 boolean isStarted()
           
 boolean isTerminated()
          Returns &ldquo;true&rdquo; if the actor is locally known to be terminated, &ldquo;false&rdquo; if alive or uncertain.
 Cell lookup()
           
 MailboxType mailboxType()
           
 Cell newCell(UnstartedCell old)
          This is called by activate() to obtain the cell which is to replace the unstarted cell.
 ActorPath path()
          Returns the path for this actor (from this actor up to the root actor).
 RepointableActorRef point()
          This method is supposed to be called by the supervisor in handleSupervise() to replace the UnstartedCell with the real one.
 Props props()
           
 ActorRefProvider provider()
          Get a reference to the actor ref provider which created this ref.
 void restart(java.lang.Throwable cause)
           
 void resume(java.lang.Throwable causedByFailure)
           
 void sendSystemMessage(SystemMessage message)
           
 void start()
           
 void stop()
           
 InternalActorRef supervisor()
           
 void suspend()
           
 Cell swapCell(Cell next)
           
 Cell swapLookup(Cell next)
           
 ActorSystemImpl system()
           
 Cell underlying()
           
protected  java.lang.Object writeReplace()
           
 
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
 

Constructor Detail

RepointableActorRef

public RepointableActorRef(ActorSystemImpl system,
                           Props props,
                           MessageDispatcher dispatcher,
                           MailboxType mailboxType,
                           InternalActorRef supervisor,
                           ActorPath path)
Method Detail

system

public ActorSystemImpl system()

props

public Props props()

dispatcher

public MessageDispatcher dispatcher()

mailboxType

public MailboxType mailboxType()

supervisor

public InternalActorRef supervisor()

path

public ActorPath path()
Description copied from class: ActorRef
Returns the path for this actor (from this actor up to the root actor).

Specified by:
path in class ActorRef
Returns:
(undocumented)

underlying

public Cell underlying()
Specified by:
underlying in class ActorRefWithCell

lookup

public Cell lookup()

swapCell

public final Cell swapCell(Cell next)

swapLookup

public final Cell swapLookup(Cell next)

initialize

public RepointableActorRef initialize(boolean async)
Initialize: make a dummy cell which holds just a mailbox, then tell our supervisor that we exist so that he can create the real Cell in handleSupervise().

Call twice on your own peril!

This is protected so that others can have different initialization.

Parameters:
async - (undocumented)
Returns:
(undocumented)

point

public RepointableActorRef point()
This method is supposed to be called by the supervisor in handleSupervise() to replace the UnstartedCell with the real one. It assumes no concurrent modification of the underlying field, though it is safe to send messages at any time.

Returns:
(undocumented)

newCell

public Cell newCell(UnstartedCell old)
This is called by activate() to obtain the cell which is to replace the unstarted cell. The cell must be fully functional.

Parameters:
old - (undocumented)
Returns:
(undocumented)

start

public void start()
Specified by:
start in class InternalActorRef

suspend

public void suspend()
Specified by:
suspend in class InternalActorRef

resume

public void resume(java.lang.Throwable causedByFailure)
Specified by:
resume in class InternalActorRef

stop

public void stop()
Specified by:
stop in class InternalActorRef

restart

public void restart(java.lang.Throwable cause)
Specified by:
restart in class InternalActorRef

isStarted

public boolean isStarted()
Specified by:
isStarted in interface RepointableRef

isTerminated

public boolean isTerminated()
Description copied from class: InternalActorRef
Returns &ldquo;true&rdquo; if the actor is locally known to be terminated, &ldquo;false&rdquo; if alive or uncertain.

Specified by:
isTerminated in class InternalActorRef
Returns:
(undocumented)

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 class InternalActorRef
Returns:
(undocumented)

isLocal

public boolean isLocal()
Description copied from class: InternalActorRef
Scope: if this ref points to an actor which resides within the same JVM, i.e. whose mailbox is directly reachable etc.

Specified by:
isLocal in interface ActorRefScope
Specified by:
isLocal in class InternalActorRef
Returns:
(undocumented)

getParent

public InternalActorRef getParent()
Description copied from class: InternalActorRef
Obtain parent of this ref; used by getChild for ".." paths.

Specified by:
getParent in class InternalActorRef
Returns:
(undocumented)

getChild

public InternalActorRef getChild(scala.collection.Iterator<java.lang.String> name)
Description copied from class: InternalActorRef
Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location. This method shall return the end result, i.e. not only the next step in the look-up; this will typically involve recursive invocation. A path element of ".." signifies the parent, a trailing "" element must be disregarded. If the requested path does not exist, return Nobody.

Specified by:
getChild in class InternalActorRef
Parameters:
name - (undocumented)
Returns:
(undocumented)

getSingleChild

public InternalActorRef getSingleChild(java.lang.String name)
Method for looking up a single child beneath this actor. It is racy if called from the outside.

Specified by:
getSingleChild in class ActorRefWithCell
Parameters:
name - (undocumented)
Returns:
(undocumented)

children

public scala.collection.immutable.Iterable<ActorRef> children()
Specified by:
children in class ActorRefWithCell

sendSystemMessage

public void sendSystemMessage(SystemMessage message)
Specified by:
sendSystemMessage in class InternalActorRef

writeReplace

protected java.lang.Object writeReplace()