From 28037666d592556bb0a017d58bce563f4599ad1f Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Fri, 19 Nov 2010 11:53:51 -0600 Subject: [PATCH] Cleaned up some semicolons Test now compiles (but does not pass) --- .../src/main/scala/remote/RemoteServer.scala | 28 ++++++++-------- ...erverInitiatedRemoteSessionActorSpec.scala | 33 ++++++++++--------- ...InitiatedRemoteTypedSessionActorSpec.scala | 18 +++++----- 3 files changed, 40 insertions(+), 39 deletions(-) diff --git a/akka-remote/src/main/scala/remote/RemoteServer.scala b/akka-remote/src/main/scala/remote/RemoteServer.scala index 7ec32c7c80..c129506ad3 100644 --- a/akka-remote/src/main/scala/remote/RemoteServer.scala +++ b/akka-remote/src/main/scala/remote/RemoteServer.scala @@ -335,19 +335,19 @@ class RemoteServer extends Logging with ListenerManagement { private def registerPerSession[Key](id: Key, factory: () => ActorRef, registry: ConcurrentHashMap[Key,() => ActorRef]) { if (_isRunning) { - registry.putIfAbsent(id, factory); + registry.putIfAbsent(id, factory) } } private def registerTypedActor[Key](id: Key, typedActor: AnyRef, registry: ConcurrentHashMap[Key, AnyRef]) { if (_isRunning) { - registry.putIfAbsent(id, typedActor); + registry.putIfAbsent(id, typedActor) } } private def registerTypedPerSessionActor[Key](id: Key, factory: () => AnyRef, registry: ConcurrentHashMap[Key,() => AnyRef]) { if (_isRunning) { - registry.putIfAbsent(id, factory); + registry.putIfAbsent(id, factory) } } @@ -493,8 +493,8 @@ class RemoteServerHandler( val AW_PROXY_PREFIX = "$$ProxiedByAW".intern val CHANNEL_INIT = "channel-init".intern - val sessionActors = new ChannelLocal[ConcurrentHashMap[String, ActorRef]](); - val typedSessionActors = new ChannelLocal[ConcurrentHashMap[String, AnyRef]](); + val sessionActors = new ChannelLocal[ConcurrentHashMap[String, ActorRef]]() + val typedSessionActors = new ChannelLocal[ConcurrentHashMap[String, AnyRef]]() applicationLoader.foreach(MessageSerializer.setClassLoader(_)) @@ -506,8 +506,8 @@ class RemoteServerHandler( override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val clientAddress = getClientAddress(ctx) - sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]()); - typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]()); + sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]()) + typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]()) log.debug("Remote client [%s] connected to [%s]", clientAddress, server.name) if (RemoteServer.SECURE) { val sslHandler: SslHandler = ctx.getPipeline.get(classOf[SslHandler]) @@ -759,7 +759,7 @@ class RemoteServerHandler( private def createSessionActor(actorInfo: ActorInfoProtocol, channel: Channel): ActorRef = { val uuid = actorInfo.getUuid val id = actorInfo.getId - val sessionActorRefOrNull = findSessionActor(id, channel); + val sessionActorRefOrNull = findSessionActor(id, channel) if (sessionActorRefOrNull ne null) sessionActorRefOrNull else @@ -767,9 +767,9 @@ class RemoteServerHandler( // we dont have it in the session either, see if we have a factory for it val actorFactoryOrNull = findActorFactory(id) if (actorFactoryOrNull ne null) { - val actorRef = actorFactoryOrNull(); + val actorRef = actorFactoryOrNull() actorRef.uuid = uuidFrom(uuid.getHigh,uuid.getLow) - sessionActors.get(channel).put(id, actorRef); + sessionActors.get(channel).put(id, actorRef) actorRef } else @@ -827,7 +827,7 @@ class RemoteServerHandler( else { // the actor has not been registered globally. See if we have it in the session - val sessionActorRefOrNull = createSessionActor(actorInfo, channel); + val sessionActorRefOrNull = createSessionActor(actorInfo, channel) if (sessionActorRefOrNull ne null) { println("giving session actor") sessionActorRefOrNull @@ -845,14 +845,14 @@ class RemoteServerHandler( */ private def createTypedSessionActor(actorInfo: ActorInfoProtocol, channel: Channel):AnyRef ={ val id = actorInfo.getId - val sessionActorRefOrNull = findTypedSessionActor(id, channel); + val sessionActorRefOrNull = findTypedSessionActor(id, channel) if (sessionActorRefOrNull ne null) sessionActorRefOrNull else { val actorFactoryOrNull = findTypedActorFactory(id) if (actorFactoryOrNull ne null) { - val newInstance = actorFactoryOrNull(); - typedSessionActors.get(channel).put(id, newInstance); + val newInstance = actorFactoryOrNull() + typedSessionActors.get(channel).put(id, newInstance) newInstance } else diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala index e1f1db4c9e..dab1f83437 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteSessionActorSpec.scala @@ -14,6 +14,7 @@ import java.util.concurrent.TimeUnit import akka.remote.{RemoteServer, RemoteClient} import akka.actor._ +import akka.actor.Actor._ import RemoteTypedActorLog._ object ServerInitiatedRemoteSessionActorSpec { @@ -21,27 +22,27 @@ object ServerInitiatedRemoteSessionActorSpec { val PORT = 9990 var server: RemoteServer = null - case class Login(user:String); - case class GetUser(); - case class DoSomethingFunny(); + case class Login(user:String) + case class GetUser() + case class DoSomethingFunny() - val instantiatedSessionActors= Set[ActorRef](); + var instantiatedSessionActors= Set[ActorRef]() class RemoteStatefullSessionActorSpec extends Actor { - var user : String= "anonymous"; + var user : String= "anonymous" override def preStart = { - instantiatedSessionActors += self; + instantiatedSessionActors += self } override def postStop = { - instantiatedSessionActors -= self; + instantiatedSessionActors -= self } def receive = { case Login(user) => - this.user = user; + this.user = user case GetUser() => self.reply(this.user) case DoSomethingFunny() => @@ -56,7 +57,7 @@ class ServerInitiatedRemoteSessionActorSpec extends FlatSpec with ShouldMatchers with BeforeAndAfterEach { - import ServerInitiatedRemoteTypedActorSpec._ + import ServerInitiatedRemoteSessionActorSpec._ private val unit = TimeUnit.MILLISECONDS @@ -65,7 +66,7 @@ class ServerInitiatedRemoteSessionActorSpec extends server = new RemoteServer() server.start(HOSTNAME, PORT) - server.registerTypedPerSessionActor("untyped-session-actor-service", actorOf[RemoteStatefullSessionActorSpec]) + server.registerPerSession("untyped-session-actor-service", actorOf[RemoteStatefullSessionActorSpec]) Thread.sleep(1000) } @@ -107,7 +108,7 @@ class ServerInitiatedRemoteSessionActorSpec extends HOSTNAME, PORT) // since this is a new session, the server should reset the state - val default2 = session2 !! GetUser(); + val default2 = session2 !! GetUser() default2.get.asInstanceOf[String] should equal ("anonymous") session2.stop() @@ -125,11 +126,11 @@ class ServerInitiatedRemoteSessionActorSpec extends val default1 = session1 !! GetUser() default1.get.asInstanceOf[String] should equal ("anonymous") - instantiatedSessionActors.size should have size (1) + instantiatedSessionActors should have size (1) RemoteClient.shutdownAll Thread.sleep(1000) - instantiatedSessionActors.size should have size (0); + instantiatedSessionActors should have size (0) } @@ -141,18 +142,18 @@ class ServerInitiatedRemoteSessionActorSpec extends HOSTNAME, PORT) - session1 ! DoSomethingFunny(); + session1 ! DoSomethingFunny() session1.stop() RemoteClient.shutdownAll Thread.sleep(1000) - instantiatedSessionActors.size should have size (0); + instantiatedSessionActors should have size (0) } it should "be able to unregister" in { - server.registerPerSession("my-service-1", actorOf[RemoteActorSpecActorUnidirectional]) + server.registerPerSession("my-service-1", actorOf[RemoteStatefullSessionActorSpec]) server.actorsFactories.get("my-service-1") should not be (null) server.unregisterPerSession("my-service-1") server.actorsFactories.get("my-service-1") should be (null) diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala index 575d82ca96..2e82afc6ba 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteTypedSessionActorSpec.scala @@ -58,15 +58,15 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends val session1 = RemoteClient.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, HOSTNAME, PORT) - session1.getUser() should equal ("anonymous"); - session1.login("session[1]"); - session1.getUser() should equal ("session[1]"); + session1.getUser() should equal ("anonymous") + session1.login("session[1]") + session1.getUser() should equal ("session[1]") RemoteClient.shutdownAll val session2 = RemoteClient.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, HOSTNAME, PORT) - session2.getUser() should equal ("anonymous"); + session2.getUser() should equal ("anonymous") RemoteClient.shutdownAll @@ -76,12 +76,12 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends val session1 = RemoteClient.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, HOSTNAME, PORT) - session1.getUser() should equal ("anonymous"); + session1.getUser() should equal ("anonymous") - RemoteTypedSessionActorImpl.getInstances() should have size (1); + RemoteTypedSessionActorImpl.getInstances() should have size (1) RemoteClient.shutdownAll Thread.sleep(1000) - RemoteTypedSessionActorImpl.getInstances() should have size (0); + RemoteTypedSessionActorImpl.getInstances() should have size (0) } @@ -89,11 +89,11 @@ class ServerInitiatedRemoteTypedSessionActorSpec extends val session1 = RemoteClient.typedActorFor(classOf[RemoteTypedSessionActor], "typed-session-actor-service", 5000L, HOSTNAME, PORT) - session1.doSomethingFunny(); + session1.doSomethingFunny() RemoteClient.shutdownAll Thread.sleep(1000) - RemoteTypedSessionActorImpl.getInstances() should have size (0); + RemoteTypedSessionActorImpl.getInstances() should have size (0) }