diff --git a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala b/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala
index 680aabd718..4fd5a8a63d 100644
--- a/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala
+++ b/akka-samples/akka-sample-security/src/main/scala/SimpleService.scala
@@ -10,6 +10,7 @@ import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.util.Logging
import se.scalablesolutions.akka.security.{BasicAuthenticationActor,BasicCredentials,SpnegoAuthenticationActor,DigestAuthenticationActor, UserInfo}
import se.scalablesolutions.akka.stm.TransactionalState
+import se.scalablesolutions.akka.actor.ActorRegistry.actorsFor
class Boot {
val factory = SupervisorFactory(
@@ -90,12 +91,7 @@ import javax.annotation.security.{RolesAllowed, DenyAll, PermitAll}
import javax.ws.rs.{GET, Path, Produces}
@Path("/secureticker")
-class SecureTickActor extends Transactor with Logging {
-
- case object Tick
- private val KEY = "COUNTER"
- private var hasStartedTicking = false
- private lazy val storage = TransactionalState.newMap[String, Integer]
+class SecureTickService {
/**
* allow access for any user to "/secureticker/public"
@@ -123,15 +119,25 @@ class SecureTickActor extends Transactor with Logging {
@DenyAll
def paranoiaTick = tick
- def tick = (self !! Tick) match {
- case (Some(counter)) => (Tick:
- {counter}
- )
- case _ => (Error in counter)
+ def tick = {
+ //Fetch the first actor of type PersistentSimpleServiceActor
+ //Send it the "Tick" message and expect a NdeSeq back
+ val result = for{a <- actorsFor(classOf[SecureTickActor]).headOption
+ r <- a.!} yield r
+ //Return either the resulting NodeSeq or a default one
+ result match {
+ case (Some(counter)) => (Tick: {counter})
+ case _ => (Error in counter)
+ }
}
+}
+class SecureTickActor extends Transactor with Logging {
+ private val KEY = "COUNTER"
+ private var hasStartedTicking = false
+ private lazy val storage = TransactionalState.newMap[String, Integer]
def receive = {
- case Tick => if (hasStartedTicking) {
+ case "Tick" => if (hasStartedTicking) {
val counter = storage.get(KEY).get.intValue
storage.put(KEY, counter + 1)
self.reply(new Integer(counter + 1))
diff --git a/config/akka-reference.conf b/config/akka-reference.conf
index 447b4b30c9..2d8b8dc43e 100644
--- a/config/akka-reference.conf
+++ b/config/akka-reference.conf
@@ -54,7 +54,7 @@
hostname = "localhost"
port = 9998
filters = ["se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use
- resource_packages = ["sample.rest.scala","sample.rest.java"] # List with all resource packages for your Jersey services
+ resource_packages = ["sample.rest.scala","sample.rest.java","sample.security"] # List with all resource packages for your Jersey services
authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (uses sample now)
#IF you are using a KerberosAuthenticationActor