cleanup docs
This commit is contained in:
parent
1e28baaada
commit
7df734320e
2 changed files with 41 additions and 35 deletions
|
|
@ -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:
|
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
|
* 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
|
* 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
|
* parameterized type - returns a 'ActorRef[]' with all actors that are a subtype of this specific type
|
||||||
|
|
@ -51,12 +52,13 @@ The messages sent to this Actor are:
|
||||||
So your listener Actor needs to be able to handle these two messages. Example:
|
So your listener Actor needs to be able to handle these two messages. Example:
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
import akka.actor.ActorRegistered;
|
|
||||||
import akka.actor.ActorUnregistered;
|
|
||||||
import akka.actor.UntypedActor;
|
|
||||||
import akka.event.EventHandler;
|
|
||||||
|
|
||||||
public class RegistryListener extends UntypedActor {
|
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 {
|
public void onReceive(Object message) throws Exception {
|
||||||
if (message instanceof ActorRegistered) {
|
if (message instanceof ActorRegistered) {
|
||||||
ActorRegistered event = (ActorRegistered) message;
|
ActorRegistered event = (ActorRegistered) message;
|
||||||
|
|
@ -66,12 +68,13 @@ public class RegistryListener extends UntypedActor {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.. code-block:: java
|
|
||||||
The above actor can be added as listener of registry events:
|
The above actor can be added as listener of registry events:
|
||||||
|
|
||||||
.. code-block:: java
|
.. code-block:: java
|
||||||
import static akka.actor.Actors.*;
|
|
||||||
|
import static akka.actor.Actors.*;
|
||||||
|
|
||||||
ActorRef listener = actorOf(RegistryListener.class).start();
|
ActorRef listener = actorOf(RegistryListener.class).start();
|
||||||
registry().addListener(listener);
|
registry().addListener(listener);
|
||||||
.. code-block:: java
|
|
||||||
|
|
|
||||||
|
|
@ -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:
|
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
|
* 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
|
* 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
|
* specific actor class - returns an '**Array[Actor]**' with all actors of this exact class
|
||||||
|
|
@ -78,13 +79,14 @@ The messages sent to this Actor are:
|
||||||
So your listener Actor needs to be able to handle these two messages. Example:
|
So your listener Actor needs to be able to handle these two messages. Example:
|
||||||
|
|
||||||
.. code-block:: scala
|
.. 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 {
|
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 = {
|
def receive = {
|
||||||
case event: ActorRegistered =>
|
case event: ActorRegistered =>
|
||||||
EventHandler.info(this, "Actor registered: %s - %s".format(
|
EventHandler.info(this, "Actor registered: %s - %s".format(
|
||||||
|
|
@ -92,13 +94,14 @@ class RegistryListener extends Actor {
|
||||||
case event: ActorUnregistered =>
|
case event: ActorUnregistered =>
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.. code-block:: scala
|
|
||||||
The above actor can be added as listener of registry events:
|
The above actor can be added as listener of registry events:
|
||||||
|
|
||||||
.. code-block:: scala
|
.. code-block:: scala
|
||||||
import akka.actor._
|
|
||||||
import akka.actor.Actor._
|
import akka.actor._
|
||||||
|
import akka.actor.Actor._
|
||||||
|
|
||||||
val listener = actorOf[RegistryListener].start
|
val listener = actorOf[RegistryListener].start
|
||||||
registry.addListener(listener)
|
registry.addListener(listener)
|
||||||
.. code-block:: scala
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue