Merge branch 'master' of git@github.com:jboner/akka

This commit is contained in:
Jonas Bonér 2009-12-03 15:59:09 +01:00
commit 730cc9176a
6 changed files with 54 additions and 22 deletions

View file

@ -11,11 +11,12 @@ import se.scalablesolutions.akka.util.Logging
import java.lang.Integer
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.{GET, POST, Path, Produces, WebApplicationException, Consumes}
import javax.ws.rs.{GET, POST, Path, Produces, WebApplicationException, Consumes,PathParam}
import org.atmosphere.core.annotation.{Broadcast, Suspend}
import org.atmosphere.annotation.{Broadcast, Suspend}
import org.atmosphere.util.XSSHtmlFilter
import org.atmosphere.cpr.BroadcastFilter
import org.atmosphere.cpr.{BroadcastFilter,Broadcaster}
import org.atmosphere.jersey.Broadcastable
class Boot {
val factory = SupervisorFactory(
@ -29,6 +30,9 @@ class Boot {
LifeCycle(Permanent)) ::
Supervise(
new PersistentSimpleService,
LifeCycle(Permanent)) ::
Supervise(
new PubSub,
LifeCycle(Permanent))
:: Nil))
factory.newInstance.start
@ -67,6 +71,26 @@ class SimpleService extends Actor {
}
}
@Path("/pubsub/")
class PubSub extends Actor {
case class Msg(topic: String, message: String)
@GET
@Suspend
@Produces(Array("text/plain;charset=ISO-8859-1"))
@Path("/topic/{topic}/")
def subscribe(@PathParam("topic") topic: Broadcaster): Broadcastable = new Broadcastable("", topic)
@GET
@Broadcast
@Path("/topic/{topic}/{message}/")
@Produces(Array("text/plain;charset=ISO-8859-1"))
def say(@PathParam("topic") topic: Broadcaster, @PathParam("message") message: String): Broadcastable = new Broadcastable(message, topic)
override def receive = { case _ => }
}
/**
* Try service out by invoking (multiple times):
* <pre>