Permalink
Browse files

Fixed now works

  • Loading branch information...
1 parent e8decaf commit b2c87abed4830e52ffda642a2861379443bd230d Paul Fuller committed Oct 9, 2010
View
Binary file not shown.
@@ -6,10 +6,7 @@ akka {
# These boot classes are loaded (and created) automatically when the Akka Microkernel boots up
# Can be used to bootstrap your application(s)
# Should be the FQN (Fully Qualified Name) of the boot class which needs to have a default constructor
- boot = ["sample.camel.Boot",
- "sample.rest.java.Boot",
- "sample.rest.scala.Boot",
- "sample.security.Boot"]
+ boot = ["samplez.Boot"]
actor {
@@ -66,10 +63,8 @@ akka {
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",
- "sample.security"] # List with all resource packages for your Jersey services
- authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (sample now)
+ resource_packages = ["samplez"] # List with all resource packages for your Jersey services
+ authenticator = "samplez.BasicAuthenticationService" # The authentication service to use. Need to be overridden (sample now)
comet-dispatcher {
#type = "Hawt" # Uncomment if you want to use a different dispatcher than the default one for Comet
@@ -0,0 +1,55 @@
+package samplez
+
+import javax.ws.rs.{GET, Path, Produces}
+import se.scalablesolutions.akka.config.ScalaConfig._
+import se.scalablesolutions.akka.actor.{ActorRegistry, SupervisorFactory, Actor}
+import se.scalablesolutions.akka.actor.Actor._
+import se.scalablesolutions.akka.actor._
+import se.scalablesolutions.akka.config.ScalaConfig._
+import se.scalablesolutions.akka.security.{BasicAuthenticationActor,BasicCredentials, UserInfo}
+
+
+class Boot {
+ val factory = SupervisorFactory(
+ SupervisorConfig(
+ RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
+ Supervise(Actor.actorOf[MyActor], LifeCycle(Permanent)) ::
+ Supervise(Actor.actorOf[BasicAuthenticationService], LifeCycle(Permanent)) :: Nil))
+ factory.newInstance.start
+}
+
+private case object Hello
+
+@Path("/hello")
+class HelloService {
+ @GET
+ @Produces(Array("text/html"))
+ def hello = {
+ val myActor = ActorRegistry.actorFor[MyActor].get
+ (myActor !! Hello).getOrElse("Hyyy")
+
+ }
+}
+
+class MyActor extends Actor {
+ import self._
+
+ def receive = {
+ case Hello => reply(<h1>Hello, World</h1>.toString)
+ }
+}
+
+class BasicAuthenticationService extends BasicAuthenticationActor {
+
+ //Change this to whatever you want
+ override def realm = "test"
+
+ //Dummy method that allows you to log on with whatever username
+ def verify(odc: Option[BasicCredentials]): Option[UserInfo] = odc match {
+ case Some(dc) => userInfo(dc.username)
+ case _ => None
+ }
+
+ //Dummy method that allows you to log on with whatever username with the password "bar"
+ def userInfo(username: String): Option[UserInfo] = Some(UserInfo(username, "bar", "ninja" :: "chef" :: Nil))
+}
@@ -6,11 +6,15 @@
<display-name>Akka-Sample-v0.10</display-name>
+ <listener>
+ <listener-class>se.scalablesolutions.akka.servlet.Initializer</listener-class>
+ </listener>
+
<servlet>
<servlet-name>AkkaServlet</servlet-name>
<servlet-class>se.scalablesolutions.akka.comet.AkkaServlet</servlet-class>
</servlet>
-
+
<servlet-mapping>
<servlet-name>AkkaServlet</servlet-name>
<url-pattern>/*</url-pattern>

0 comments on commit b2c87ab

Please sign in to comment.