diff --git a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala b/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala index eb2d07340e..f31e10861d 100644 --- a/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala +++ b/akka-samples/akka-sample-rest-scala/src/main/scala/SimpleService.scala @@ -51,14 +51,15 @@ class SimpleService { @GET @Produces(Array("text/html")) def count = { - //Fetch the first actor of type SimpleServiceActor - //Send it the "Tick" message and expect a NdeSeq back - val result = for{a <- actorsFor(classOf[SimpleServiceActor]).headOption - r <- a.!![NodeSeq]("Tick")} yield r - //Return either the resulting NodeSeq or a default one - result getOrElse Error in counter + //Fetch the first actor of type SimpleServiceActor + //Send it the "Tick" message and expect a NodeSeq back + val result = for{a <- actorsFor(classOf[SimpleServiceActor]).headOption + r <- a.!![NodeSeq]("Tick")} yield r + //Return either the resulting NodeSeq or a default one + result getOrElse Error in counter } } + class SimpleServiceActor extends Transactor { private val KEY = "COUNTER" private var hasStartedTicking = false @@ -105,12 +106,12 @@ class PersistentSimpleService { @GET @Produces(Array("text/html")) def count = { - //Fetch the first actor of type PersistentSimpleServiceActor - //Send it the "Tick" message and expect a NdeSeq back - val result = for{a <- actorsFor(classOf[PersistentSimpleServiceActor]).headOption - r <- a.!![NodeSeq]("Tick")} yield r - //Return either the resulting NodeSeq or a default one - result getOrElse Error in counter + //Fetch the first actor of type PersistentSimpleServiceActor + //Send it the "Tick" message and expect a NodeSeq back + val result = for{a <- actorsFor(classOf[PersistentSimpleServiceActor]).headOption + r <- a.!![NodeSeq]("Tick")} yield r + //Return either the resulting NodeSeq or a default one + result getOrElse Error in counter } } @@ -147,13 +148,13 @@ class Chat { @Consumes(Array("application/x-www-form-urlencoded")) @Produces(Array("text/html")) def publishMessage(form: MultivaluedMap[String, String]) = { - val msg = ChatMsg(form.getFirst("name"),form.getFirst("action"),form.getFirst("message")) + val msg = ChatMsg(form.getFirst("name"),form.getFirst("action"),form.getFirst("message")) //Fetch the first actor of type ChatActor - //Send it the "Tick" message and expect a NdeSeq back - val result = for{a <- actorsFor(classOf[ChatActor]).headOption - r <- a.!![String](msg)} yield r - //Return either the resulting String or a default one - result getOrElse "System__error" + //Send it the "Tick" message and expect a NodeSeq back + val result = for{a <- actorsFor(classOf[ChatActor]).headOption + r <- a.!![String](msg)} yield r + //Return either the resulting String or a default one + result getOrElse "System__error" } }