cleanup docs

This commit is contained in:
Derek Williams 2011-04-11 06:28:53 -06:00
parent 1e28baaada
commit 7df734320e
2 changed files with 41 additions and 35 deletions

View file

@ -7,6 +7,7 @@ ActorRegistry: Finding Actors
-----------------------------
Actors can be looked up using the 'akka.actor.Actors.registry()' object. Through this registry you can look up actors by:
* uuid com.eaio.uuid.UUID this uses the uuid field in the Actor class, returns the actor reference for the actor with specified uuid, if one exists, otherwise None
* id string this uses the id field in the Actor class, which can be set by the user (default is the class name), returns all actor references to actors with specified id
* parameterized type - returns a 'ActorRef[]' with all actors that are a subtype of this specific type
@ -51,27 +52,29 @@ The messages sent to this Actor are:
So your listener Actor needs to be able to handle these two messages. Example:
.. code-block:: java
import akka.actor.ActorRegistered;
import akka.actor.ActorUnregistered;
import akka.actor.UntypedActor;
import akka.event.EventHandler;
public class RegistryListener extends UntypedActor {
public void onReceive(Object message) throws Exception {
if (message instanceof ActorRegistered) {
ActorRegistered event = (ActorRegistered) message;
EventHandler.info(this, String.format("Actor registered: %s - %s",
event.actor().actorClassName(), event.actor().getUuid()));
} else if (message instanceof ActorUnregistered) {
// ...
import akka.actor.ActorRegistered;
import akka.actor.ActorUnregistered;
import akka.actor.UntypedActor;
import akka.event.EventHandler;
public class RegistryListener extends UntypedActor {
public void onReceive(Object message) throws Exception {
if (message instanceof ActorRegistered) {
ActorRegistered event = (ActorRegistered) message;
EventHandler.info(this, String.format("Actor registered: %s - %s",
event.actor().actorClassName(), event.actor().getUuid()));
} else if (message instanceof ActorUnregistered) {
// ...
}
}
}
}
.. code-block:: java
The above actor can be added as listener of registry events:
.. code-block:: java
import static akka.actor.Actors.*;
import static akka.actor.Actors.*;
ActorRef listener = actorOf(RegistryListener.class).start();
registry().addListener(listener);
.. code-block:: java

View file

@ -7,6 +7,7 @@ ActorRegistry: Finding Actors
-----------------------------
Actors can be looked up by using the **akka.actor.Actor.registry: akka.actor.ActorRegistry**. Lookups for actors through this registry can be done by:
* uuid akka.actor.Uuid this uses the **uuid** field in the Actor class, returns the actor reference for the actor with specified uuid, if one exists, otherwise None
* id string this uses the **id** field in the Actor class, which can be set by the user (default is the class name), returns all actor references to actors with specified id
* specific actor class - returns an '**Array[Actor]**' with all actors of this exact class
@ -78,27 +79,29 @@ The messages sent to this Actor are:
So your listener Actor needs to be able to handle these two messages. Example:
.. code-block:: scala
import akka.actor.Actor
import akka.actor.ActorRegistered;
import akka.actor.ActorUnregistered;
import akka.actor.UntypedActor;
import akka.event.EventHandler;
class RegistryListener extends Actor {
def receive = {
case event: ActorRegistered =>
EventHandler.info(this, "Actor registered: %s - %s".format(
import akka.actor.Actor
import akka.actor.ActorRegistered;
import akka.actor.ActorUnregistered;
import akka.actor.UntypedActor;
import akka.event.EventHandler;
class RegistryListener extends Actor {
def receive = {
case event: ActorRegistered =>
EventHandler.info(this, "Actor registered: %s - %s".format(
event.actor.actorClassName, event.actor.uuid))
case event: ActorUnregistered =>
// ...
case event: ActorUnregistered =>
// ...
}
}
}
.. code-block:: scala
The above actor can be added as listener of registry events:
.. code-block:: scala
import akka.actor._
import akka.actor.Actor._
val listener = actorOf[RegistryListener].start
registry.addListener(listener)
The above actor can be added as listener of registry events:
.. code-block:: scala
import akka.actor._
import akka.actor.Actor._
val listener = actorOf[RegistryListener].start
registry.addListener(listener)