Adding Java API for per session remote actors, closing ticket #561
This commit is contained in:
parent
aa47e66c5a
commit
ec1d0e4f71
1 changed files with 29 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ import org.jboss.netty.handler.ssl.SslHandler
|
||||||
import scala.collection.mutable.Map
|
import scala.collection.mutable.Map
|
||||||
import scala.reflect.BeanProperty
|
import scala.reflect.BeanProperty
|
||||||
import akka.dispatch. {Future, DefaultCompletableFuture, CompletableFuture}
|
import akka.dispatch. {Future, DefaultCompletableFuture, CompletableFuture}
|
||||||
|
import akka.japi.Creator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this object if you need a single remote server on a specific node.
|
* Use this object if you need a single remote server on a specific node.
|
||||||
|
|
@ -291,6 +292,12 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
*/
|
*/
|
||||||
def registerTypedPerSessionActor(intfClass: Class[_], factory: => AnyRef) : Unit = registerTypedActor(intfClass.getName, factory)
|
def registerTypedPerSessionActor(intfClass: Class[_], factory: => AnyRef) : Unit = registerTypedActor(intfClass.getName, factory)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register typed actor by interface name.
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def registerTypedPerSessionActor(intfClass: Class[_], factory: Creator[AnyRef]) : Unit = registerTypedActor(intfClass.getName, factory)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register remote typed actor by a specific id.
|
* Register remote typed actor by a specific id.
|
||||||
* @param id custom actor id
|
* @param id custom actor id
|
||||||
|
|
@ -301,6 +308,17 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
registerTypedPerSessionActor(id, () => factory, typedActorsFactories)
|
registerTypedPerSessionActor(id, () => factory, typedActorsFactories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register remote typed actor by a specific id.
|
||||||
|
* @param id custom actor id
|
||||||
|
* @param typedActor typed actor to register
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def registerTypedPerSessionActor(id: String, factory: Creator[AnyRef]): Unit = synchronized {
|
||||||
|
log.slf4j.debug("Registering server side typed remote session actor with id [{}]", id)
|
||||||
|
registerTypedPerSessionActor(id, factory.create _, typedActorsFactories)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already.
|
* Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already.
|
||||||
*/
|
*/
|
||||||
|
|
@ -327,6 +345,17 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
registerPerSession(id, () => factory, actorsFactories)
|
registerPerSession(id, () => factory, actorsFactories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Remote Session Actor by a specific 'id' passed as argument.
|
||||||
|
* <p/>
|
||||||
|
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def registerPerSession(id: String, factory: Creator[ActorRef]): Unit = synchronized {
|
||||||
|
log.slf4j.debug("Registering server side remote session actor with id [{}]", id)
|
||||||
|
registerPerSession(id, factory.create _, actorsFactories)
|
||||||
|
}
|
||||||
|
|
||||||
private def register[Key](id: Key, actorRef: ActorRef, registry: ConcurrentHashMap[Key, ActorRef]) {
|
private def register[Key](id: Key, actorRef: ActorRef, registry: ConcurrentHashMap[Key, ActorRef]) {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
registry.put(id, actorRef) //TODO change to putIfAbsent
|
registry.put(id, actorRef) //TODO change to putIfAbsent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue