2009-12-22 19:05:16 +01:00
|
|
|
/**
|
2009-12-27 16:01:53 +01:00
|
|
|
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
2009-12-22 19:05:16 +01:00
|
|
|
*/
|
2010-05-21 20:08:49 +02:00
|
|
|
|
2010-10-26 12:49:25 +02:00
|
|
|
package akka.remote
|
2009-12-22 19:05:16 +01:00
|
|
|
|
2010-10-26 12:49:25 +02:00
|
|
|
import akka.config.Config.config
|
2010-12-14 18:22:46 +01:00
|
|
|
import akka.actor. {ActorRegistry, BootableActorLoaderService}
|
|
|
|
|
import akka.util. {ReflectiveAccess, Bootable, Logging}
|
2009-12-22 19:05:16 +01:00
|
|
|
|
2009-12-26 15:09:44 +01:00
|
|
|
/**
|
|
|
|
|
* This bundle/service is responsible for booting up and shutting down the remote actors facility
|
2010-05-25 15:14:53 +02:00
|
|
|
* <p/>
|
|
|
|
|
* It is used in Kernel
|
2009-12-26 15:09:44 +01:00
|
|
|
*/
|
2009-12-22 19:05:16 +01:00
|
|
|
trait BootableRemoteActorService extends Bootable with Logging {
|
2010-05-25 15:14:53 +02:00
|
|
|
self: BootableActorLoaderService =>
|
2009-12-27 22:56:55 +01:00
|
|
|
|
2009-12-22 19:05:16 +01:00
|
|
|
protected lazy val remoteServerThread = new Thread(new Runnable() {
|
2010-12-14 18:22:46 +01:00
|
|
|
import ReflectiveAccess.RemoteServerModule.{HOSTNAME,PORT}
|
|
|
|
|
def run = ActorRegistry.remote.start(HOSTNAME,PORT,loader = self.applicationLoader)
|
2009-12-22 19:05:16 +01:00
|
|
|
}, "Akka Remote Service")
|
2010-11-24 21:05:12 +01:00
|
|
|
|
2009-12-22 19:05:16 +01:00
|
|
|
def startRemoteService = remoteServerThread.start
|
2010-05-21 20:08:49 +02:00
|
|
|
|
2010-08-10 21:42:27 +02:00
|
|
|
abstract override def onLoad = {
|
2010-11-22 15:32:54 +01:00
|
|
|
if (RemoteServer.isRemotingEnabled) {
|
2010-11-24 13:42:41 +01:00
|
|
|
log.slf4j.info("Initializing Remote Actors Service...")
|
2009-12-26 15:09:44 +01:00
|
|
|
startRemoteService
|
2010-11-24 13:42:41 +01:00
|
|
|
log.slf4j.info("Remote Actors Service initialized")
|
2009-12-26 15:09:44 +01:00
|
|
|
}
|
2010-08-09 19:35:07 +02:00
|
|
|
super.onLoad
|
2009-12-22 19:05:16 +01:00
|
|
|
}
|
2010-03-03 20:06:06 +01:00
|
|
|
|
2009-12-22 19:05:16 +01:00
|
|
|
abstract override def onUnload = {
|
2010-11-24 13:42:41 +01:00
|
|
|
log.slf4j.info("Shutting down Remote Actors Service")
|
2010-03-03 20:06:06 +01:00
|
|
|
RemoteNode.shutdown
|
2010-05-25 15:14:53 +02:00
|
|
|
if (remoteServerThread.isAlive) remoteServerThread.join(1000)
|
2010-11-24 13:42:41 +01:00
|
|
|
log.slf4j.info("Remote Actors Service has been shut down")
|
2010-03-08 10:53:21 +01:00
|
|
|
super.onUnload
|
2009-12-22 19:05:16 +01:00
|
|
|
}
|
2010-03-08 10:53:21 +01:00
|
|
|
}
|