DOC: Removed actor registry. See #1455

This commit is contained in:
Patrik Nordwall 2011-12-12 12:19:20 +01:00
parent 92a0fa7e8e
commit ad0a67c77d
4 changed files with 0 additions and 206 deletions

View file

@ -1,98 +0,0 @@
ActorRegistry (Java)
====================
Module stability: **SOLID**
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
* specific actor class - returns a ``ActorRef[]`` with all actors of this exact class
Actors are automatically registered in the ActorRegistry when they are started and removed when they are stopped. But you can explicitly register and unregister ActorRef's if you need to using the ``register`` and ``unregister`` methods.
Here is a summary of the API for finding actors:
.. code-block:: java
import static akka.actor.Actors.*;
Option<ActorRef> actor = registry().actorFor(uuid);
ActorRef[] actors = registry().actors();
ActorRef[] otherActors = registry().actorsFor(id);
ActorRef[] moreActors = registry().actorsFor(clazz);
You can shut down all Actors in the system by invoking:
.. code-block:: java
registry().shutdownAll();
If you want to know when a new Actor is added to or removed from the registry, you can use the subscription API on the registry. You can register an Actor that should be notified when an event happens in the ActorRegistry:
.. code-block:: java
void addListener(ActorRef listener);
void removeListener(ActorRef listener);
The messages sent to this Actor are:
.. code-block:: java
public class ActorRegistered {
ActorRef getActor();
String getAddress();
}
public class ActorUnregistered {
ActorRef actor();
String getAddress();
}
public class TypedActorRegistered {
ActorRef getActor();
String getAddress();
Object getProxy();
}
public class TypedActorUnregistered {
ActorRef actor();
String getAddress();
Object getProxy();
}
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.TypedActorRegistered;
import akka.actor.TypedActorUnregistered;
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()));
event.actor().actorClassName(), event.actor().getUuid()));
} else if (message instanceof ActorUnregistered) {
// ...
}
}
}
The above actor can be added as listener of registry events:
.. code-block:: java
import static akka.actor.Actors.*;
ActorRef listener = actorOf(RegistryListener.class);
registry().addListener(listener);

View file

@ -8,7 +8,6 @@ Java API
untyped-actors
typed-actors
actor-registry
futures
dataflow
stm

View file

@ -1,106 +0,0 @@
ActorRegistry (Scala)
=====================
Module stability: **SOLID**
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
* parameterized type - returns an ``Array[Actor]`` with all actors that are a subtype of this specific type
Actors are automatically registered in the ActorRegistry when they are started, removed or stopped. You can explicitly register and unregister ActorRef's by using the ``register`` and ``unregister`` methods. The ActorRegistry contains many convenience methods for looking up typed actors.
Here is a summary of the API for finding actors:
.. code-block:: scala
def actors: Array[ActorRef]
def actorFor(uuid: akka.actor.Uuid): Option[ActorRef]
def actorsFor(id : String): Array[ActorRef]
def actorsFor[T <: Actor](implicit manifest: Manifest[T]): Array[ActorRef]
def actorsFor[T <: Actor](clazz: Class[T]): Array[ActorRef]
// finding typed actors
def typedActors: Array[AnyRef]
def typedActorFor(uuid: akka.actor.Uuid): Option[AnyRef]
def typedActorsFor(id: String): Array[AnyRef]
def typedActorsFor[T <: AnyRef](implicit manifest: Manifest[T]): Array[AnyRef]
def typedActorsFor[T <: AnyRef](clazz: Class[T]): Array[AnyRef]
Examples of how to use them:
.. code-block:: scala
val actor = Actor.registry.actorFor(uuid)
val pojo = Actor.registry.typedActorFor(uuid)
.. code-block:: scala
val actors = Actor.registry.actorsFor(classOf[...])
val pojos = Actor.registry.typedActorsFor(classOf[...])
.. code-block:: scala
val actors = Actor.registry.actorsFor(id)
val pojos = Actor.registry.typedActorsFor(id)
.. code-block:: scala
val actors = Actor.registry.actorsFor[MyActorType]
val pojos = Actor.registry.typedActorsFor[MyTypedActorImpl]
The ActorRegistry also has a 'shutdownAll' and 'foreach' methods:
.. code-block:: scala
def foreach(f: (ActorRef) => Unit)
def foreachTypedActor(f: (AnyRef) => Unit)
def shutdownAll()
If you need to know when a new Actor is added or removed from the registry, you can use the subscription API. You can register an Actor that should be notified when an event happens in the ActorRegistry:
.. code-block:: scala
def addListener(listener: ActorRef)
def removeListener(listener: ActorRef)
The messages sent to this Actor are:
.. code-block:: scala
case class ActorRegistered(@BeanProperty address: String,@BeanProperty actor: ActorRef) extends ActorRegistryEvent
case class ActorUnregistered(@BeanProperty address: String, @BeanProperty actor: ActorRef) extends ActorRegistryEvent
case class TypedActorRegistered(@BeanProperty address: String, @BeanProperty actor: ActorRef, @BeanProperty proxy: AnyRef) extends ActorRegistryEvent
case class TypedActorUnregistered(@BeanProperty address: String, @BeanProperty actor: ActorRef, @BeanProperty proxy: AnyRef) extends ActorRegistryEvent
So your listener Actor needs to be able to handle these messages. Example:
.. code-block:: scala
import akka.actor._
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 =>
// ...
}
}
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]
registry.addListener(listener)

View file

@ -8,7 +8,6 @@ Scala API
actors
typed-actors
actor-registry
futures
dataflow
agents