refactored remote event handler and added deregistration of it on remote shutdown

This commit is contained in:
Jonas Bonér 2011-03-24 12:48:40 +01:00
parent cb0f14a2c0
commit 6449fa940f
3 changed files with 22 additions and 17 deletions

View file

@ -5,14 +5,15 @@
package akka.remoteinterface
import akka.japi.Creator
import java.net.InetSocketAddress
import akka.actor._
import akka.util._
import akka.dispatch.CompletableFuture
import akka.config.Config.{config, TIME_UNIT}
import java.util.concurrent.ConcurrentHashMap
import akka.AkkaException
import reflect.BeanProperty
import scala.reflect.BeanProperty
import java.net.InetSocketAddress
import java.util.concurrent.ConcurrentHashMap
trait RemoteModule {
val UUID_PREFIX = "uuid:"
@ -20,7 +21,6 @@ trait RemoteModule {
def optimizeLocalScoped_?(): Boolean //Apply optimizations for remote operations in local scope
protected[akka] def notifyListeners(message: => Any): Unit
private[akka] def actors: ConcurrentHashMap[String, ActorRef]
private[akka] def actorsByUuid: ConcurrentHashMap[String, ActorRef]
private[akka] def actorsFactories: ConcurrentHashMap[String, () => ActorRef]
@ -28,7 +28,6 @@ trait RemoteModule {
private[akka] def typedActorsByUuid: ConcurrentHashMap[String, AnyRef]
private[akka] def typedActorsFactories: ConcurrentHashMap[String, () => AnyRef]
/** Lookup methods **/
private[akka] def findActorById(id: String) : ActorRef = actors.get(id)
@ -126,13 +125,21 @@ case class UnparsableException private[akka] (originalClassName: String,
abstract class RemoteSupport extends ListenerManagement with RemoteServerModule with RemoteClientModule {
lazy val eventHandler: ActorRef = {
val handler = Actor.actorOf[RemoteEventHandler].start
// add the remote client and server listener that pipes the events to the event handler system
addListener(handler)
handler
}
def shutdown {
removeListener(eventHandler)
this.shutdownClientModule
this.shutdownServerModule
clear
}
/**
* Creates a Client-managed ActorRef out of the Actor of the specified Class.
* If the supplied host and port is identical of the configured local node, it will be a local actor