Added version

This commit is contained in:
Viktor Klang 2009-12-02 21:08:29 +01:00
parent 86ac72ad3b
commit ae0e0e1e0f
2 changed files with 30 additions and 6 deletions

View file

@ -11,16 +11,18 @@ 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.annotation.{Broadcast, Suspend}
import org.atmosphere.util.XSSHtmlFilter
import org.atmosphere.cpr.BroadcastFilter
import org.atmosphere.cpr.Broadcaster
import org.atmosphere.jersey.Broadcastable
class Boot {
val factory = SupervisorFactory(
SupervisorConfig(
RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
RestartStrategy(OneForOne, 3, 100,List(classOf[Exception])),
Supervise(
new SimpleService,
LifeCycle(Permanent)) ::
@ -29,11 +31,33 @@ class Boot {
LifeCycle(Permanent)) ::
Supervise(
new PersistentSimpleService,
LifeCycle(Permanent))
:: Nil))
LifeCycle(Permanent)) ::
Supervise(
new PubSub,
LifeCycle(Permanent)) ::
Nil) )
factory.newInstance.start
}
@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>