diff --git a/akka.iws b/akka.iws index 29fb8867b0..0d0368ea74 100644 --- a/akka.iws +++ b/akka.iws @@ -6,17 +6,27 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -139,15 +149,6 @@ - - - - - - - - - @@ -157,28 +158,10 @@ - + - - - - - - - - - - - - - - - - - - - + @@ -242,7 +225,6 @@ @@ -323,76 +306,6 @@ - - - - - - - @@ -2121,6 +2109,13 @@ + + + + + + + @@ -2149,30 +2144,30 @@ - + - + - + - + - + - + - + diff --git a/bin/start-akka-server.sh b/bin/start-akka-server.sh index c84827dc9b..04814b7b11 100755 --- a/bin/start-akka-server.sh +++ b/bin/start-akka-server.sh @@ -25,10 +25,10 @@ CLASSPATH=$CLASSPATH:$LIB_DIR/antlr-3.1.3.jar CLASSPATH=$CLASSPATH:$LIB_DIR/aopalliance-1.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/asm-3.1.jar CLASSPATH=$CLASSPATH:$LIB_DIR/aspectwerkz-nodeps-jdk5-2.1.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-core-0.3-SNAPSHOT.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-compat-0.3-SNAPSHOT.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-portable-runtime-0.3-SNAPSHOT.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-core-0.3.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-portable-runtime-0.3.jar CLASSPATH=$CLASSPATH:$LIB_DIR/camel-core-2.0-SNAPSHOT.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/atmosphere-compat-0.3.jar CLASSPATH=$CLASSPATH:$LIB_DIR/cassandra-0.4.0-dev.jar CLASSPATH=$CLASSPATH:$LIB_DIR/cglib-2.2.jar CLASSPATH=$CLASSPATH:$LIB_DIR/commons-cli-1.1.jar @@ -48,17 +48,15 @@ CLASSPATH=$CLASSPATH:$LIB_DIR/high-scale-lib.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jackson-core-asl-1.1.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jackson-mapper-asl-1.1.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-client-1.1.1-ea.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-core-1.1.1.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-json-1.1.1.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-server-1.1.1.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-core-1.1.1-ea.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-json-1.1.1-ea.jar +CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-server-1.1.1-ea.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jersey-scala-1.1.2-ea-SNAPSHOT.jar CLASSPATH=$CLASSPATH:$LIB_DIR/JSAP-2.1.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jsr250-api-1.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/jsr311-api-1.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/libfb303.jar CLASSPATH=$CLASSPATH:$LIB_DIR/libthrift.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/lift-webkit-1.1-M3.jar -CLASSPATH=$CLASSPATH:$LIB_DIR/lift-util-1.1-M3.jar CLASSPATH=$CLASSPATH:$LIB_DIR/log4j-1.2.15.jar CLASSPATH=$CLASSPATH:$LIB_DIR/lucene-core-2.2.0.jar CLASSPATH=$CLASSPATH:$LIB_DIR/netty-3.1.0.CR1.jar diff --git a/deploy/root/page.html b/deploy/root/page.html index ea13c3f710..b6d3f5f2d5 100644 --- a/deploy/root/page.html +++ b/deploy/root/page.html @@ -1,10 +1,64 @@ -blah - -
- - - - -
- \ No newline at end of file + + Push Services Demo + + + + +
+
+
+
+
+ + + + +
+
+
+ + + \ No newline at end of file diff --git a/kernel/pom.xml b/kernel/pom.xml index 0401adbe65..974d7f2c0b 100644 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -122,63 +122,46 @@ - - - com.sun.grizzly - grizzly-comet-webserver - - 1.8.6.3 - - - com.sun.jersey - jersey-server - 1.0.3 - - - com.sun.jersey - jersey-json - 1.0.3 - - - javax.ws.rs - jsr311-api - 1.0 - - - com.sun.jersey.contribs - jersey-scala - 1.1.2-ea-SNAPSHOT - - - - - org.atmosphere - atmosphere-core - 0.3-SNAPSHOT - - - org.atmosphere - atmosphere-portable-runtime - 0.3-SNAPSHOT - - - org.atmosphere - atmosphere-compat - 0.3-SNAPSHOT - - + + com.sun.grizzly + grizzly-comet-webserver + 1.8.6.3 + + + com.sun.jersey + jersey-server + 1.1.1-ea + + + com.sun.jersey + jersey-json + 1.1.1-ea + + + javax.ws.rs + jsr311-api + 1.0 + + + com.sun.jersey.contribs + jersey-scala + 1.1.2-ea-SNAPSHOT + + + org.atmosphere + atmosphere-core + 0.3 + + + org.atmosphere + atmosphere-portable-runtime + 0.3 + + + org.atmosphere + atmosphere-compat + 0.3 + diff --git a/kernel/src/main/scala/jersey/AkkaServlet.scala b/kernel/src/main/scala/jersey/AkkaServlet.scala index 2fb07e7b9f..de3c89dea5 100644 --- a/kernel/src/main/scala/jersey/AkkaServlet.scala +++ b/kernel/src/main/scala/jersey/AkkaServlet.scala @@ -25,6 +25,9 @@ import java.io.InputStream import scala.collection.jcl.Conversions._ +/** + * @author Jonas Bonér + */ class AkkaServlet extends ServletContainer with AtmosphereServletProcessor with Logging { override def initiate(rc: ResourceConfig, wa: WebApplication) = { @@ -32,7 +35,8 @@ class AkkaServlet extends ServletContainer with AtmosphereServletProcessor with val configurators = ConfiguratorRepository.getConfiguratorsFor(getServletContext) rc.getClasses.addAll(configurators.flatMap(_.getComponentInterfaces)) - rc.getProperties.put("com.sun.jersey.spi.container.ResourceFilters", "org.atmosphere.core.AtmosphereFilter") + log.info("Starting AkkaServlet with ResourceFilters: " + rc.getProperty("com.sun.jersey.spi.container.ResourceFilters")); + rc.getProperties.put("com.sun.jersey.spi.container.ResourceFilters","org.atmosphere.core.AtmosphereFilter") //rc.getFeatures.put("com.sun.jersey.config.feature.Redirect", true) //rc.getFeatures.put("com.sun.jersey.config.feature.ImplicitViewables",true) @@ -61,13 +65,33 @@ class AkkaServlet extends ServletContainer with AtmosphereServletProcessor with event } - override def onEvent(event: AtmosphereEvent[HttpServletRequest, HttpServletResponse]): AtmosphereEvent[_, _] = { - //log.info("onEvent: " + event.getMessage) - event.getRequest.setAttribute(ReflectorServletProcessor.ATMOSPHERE_EVENT, event) - event.getRequest.setAttribute(ReflectorServletProcessor.ATMOSPHERE_HANDLER, this) - service(event.getRequest, event.getResponse) - event - } + //Borrowed from AbstractReflectorAtmosphereHandler + override def onMessage(event: AtmosphereEvent[HttpServletRequest,HttpServletResponse]): AtmosphereEvent[_,_] = { + var isUsingStream = false + try { + event.getResponse.getWriter + } catch { + case e: IllegalStateException => isUsingStream = true + } + + val data = if (event.getMessage ne null) event.getMessage.toString else null + + if (isUsingStream){ + if (data != null) event.getResponse.getOutputStream.write(data.getBytes) + event.getResponse.getOutputStream.flush + } else { + event.getResponse.getWriter.write(data) + event.getResponse.getWriter.flush + } + event + } + + override def onEvent(event: AtmosphereEvent[HttpServletRequest,HttpServletResponse]): AtmosphereEvent[_,_] = { + event.getRequest.setAttribute(ReflectorServletProcessor.ATMOSPHERE_EVENT, event) + event.getRequest.setAttribute(ReflectorServletProcessor.ATMOSPHERE_HANDLER, this) + service(event.getRequest, event.getResponse) + event + } } class AkkaCometServlet extends org.atmosphere.cpr.AtmosphereServlet { diff --git a/lib/atmosphere-compat-0.3-SNAPSHOT.jar b/lib/atmosphere-compat-0.3-SNAPSHOT.jar deleted file mode 100644 index 7125488274..0000000000 Binary files a/lib/atmosphere-compat-0.3-SNAPSHOT.jar and /dev/null differ diff --git a/lib/atmosphere-core-0.3-SNAPSHOT.jar b/lib/atmosphere-core-0.3.jar~HEAD similarity index 74% rename from lib/atmosphere-core-0.3-SNAPSHOT.jar rename to lib/atmosphere-core-0.3.jar~HEAD index 6876b9e845..aef71c00ba 100644 Binary files a/lib/atmosphere-core-0.3-SNAPSHOT.jar and b/lib/atmosphere-core-0.3.jar~HEAD differ diff --git a/lib/atmosphere-portable-runtime-0.3-SNAPSHOT.jar b/lib/atmosphere-portable-runtime-0.3.jar~HEAD similarity index 77% rename from lib/atmosphere-portable-runtime-0.3-SNAPSHOT.jar rename to lib/atmosphere-portable-runtime-0.3.jar~HEAD index c12212705a..19875c8c51 100644 Binary files a/lib/atmosphere-portable-runtime-0.3-SNAPSHOT.jar and b/lib/atmosphere-portable-runtime-0.3.jar~HEAD differ diff --git a/lib/jersey-client-1.1.1-ea.jar b/lib/jersey-client-1.1.1-ea.jar old mode 100644 new mode 100755 diff --git a/lib/jersey-core-1.1.1-ea.jar b/lib/jersey-core-1.1.1-ea.jar old mode 100644 new mode 100755 diff --git a/lib/jersey-server-1.1.1-ea.jar b/lib/jersey-server-1.1.1-ea.jar old mode 100644 new mode 100755 diff --git a/samples-java/src/main/java/sample/java/SimpleService.java b/samples-java/src/main/java/sample/java/SimpleService.java index 55b14938e3..4e108040ff 100644 --- a/samples-java/src/main/java/sample/java/SimpleService.java +++ b/samples-java/src/main/java/sample/java/SimpleService.java @@ -1,3 +1,7 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + package sample.java; import javax.ws.rs.Path; diff --git a/samples-scala/src/main/scala/SimpleService.scala b/samples-scala/src/main/scala/SimpleService.scala index 1210385562..fbb8a4ba6a 100644 --- a/samples-scala/src/main/scala/SimpleService.scala +++ b/samples-scala/src/main/scala/SimpleService.scala @@ -1,13 +1,16 @@ +/** + * Copyright (C) 2009 Scalable Solutions. + */ + package sample.scala import javax.ws.rs.{GET, POST, Path, Produces, WebApplicationException, Consumes} -import se.scalablesolutions.akka.kernel.state.{TransactionalState, TransactionalMap, CassandraStorageConfig} -import se.scalablesolutions.akka.kernel.actor.{Supervisor, SupervisorFactory, Actor, StartSupervisor} +import se.scalablesolutions.akka.kernel.state.{TransactionalState, CassandraStorageConfig} +import se.scalablesolutions.akka.kernel.actor.{SupervisorFactory, Actor} import se.scalablesolutions.akka.kernel.config.ScalaConfig._ import javax.ws.rs.core.MultivaluedMap -import _root_.scala.xml.{NodeSeq} import se.scalablesolutions.akka.kernel.util.{Logging} import org.atmosphere.core.annotation.{Broadcast, BroadcastFilter => FilterBroadcast, Suspend} import org.atmosphere.util.{XSSHtmlFilter} @@ -20,8 +23,11 @@ class Boot { SupervisorConfig( RestartStrategy(OneForOne, 3, 100), Supervise( - new Chat, - LifeCycle(Permanent, 100)) + new SimpleService, + LifeCycle(Permanent, 100)) :: + Supervise( + new Chat, + LifeCycle(Permanent, 100)) :: Nil) } } @@ -53,7 +59,7 @@ class SimpleService extends Actor { case Tick => if (hasStartedTicking) { val counter = storage.get(KEY).get.asInstanceOf[Integer].intValue storage.put(KEY, new Integer(counter + 1)) - reply(Tick:{ counter + 1 }) + reply(Tick:{counter + 1}) } else { storage.put(KEY, new Integer(0)) hasStartedTicking = true @@ -75,11 +81,14 @@ class Chat extends Actor with Logging { "servers to send data to the client without having any need " + "for the client to request it. -->\n" + @Suspend + @GET + @Produces(Array("text/html")) + @FilterBroadcast(Array(classOf[XSSHtmlFilter], classOf[JsonpFilter])) + def suspend() = + override def receive: PartialFunction[Any, Unit] = { case Chat(who, what, msg) => { - - //log.info("Chat(" + who + ", " + what + ", " + msg + ")") - what match { case "login" => reply("System Message__" + who + " has joined.") case "post" => reply("" + who + "__" + msg) @@ -99,9 +108,6 @@ class Chat extends Actor with Logging { class JsonpFilter extends BroadcastFilter[String] with Logging { - val BEGIN_SCRIPT_TAG = "\n" - def filter(m: String) = { var name = m var message = "" @@ -111,9 +117,6 @@ class JsonpFilter extends BroadcastFilter[String] with Logging { message = m.substring(m.indexOf("__") + 2) } - (BEGIN_SCRIPT_TAG + "window.parent.app.update({ name: \"" - + name + "\", message: \"" - + message + "\" });\n" - + END_SCRIPT_TAG) + ("\n") } } \ No newline at end of file