diff --git a/bin/start-akka-server.sh b/bin/start-akka-server.sh index 929353fe8a..5eb5b8278d 100755 --- a/bin/start-akka-server.sh +++ b/bin/start-akka-server.sh @@ -50,11 +50,14 @@ CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jersey-core-1.0.3.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jersey-json-1.0.3.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jersey-server-1.0.3.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jersey-scala-1.1.2-ea-SNAPSHOT.jar +CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jersey-lift-1.1.2-ea-SNAPSHOT.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/JSAP-2.1.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jsr250-api-1.0.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/jsr311-api-1.0.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/libfb303.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/libthrift.jar +CLASSPATH=$CLASSPATH:$BASE_DIR/lib/lift-webkit-1.1-M3.jar +CLASSPATH=$CLASSPATH:$BASE_DIR/lib/lift-util-1.1-M3.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/log4j-1.2.15.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/lucene-core-2.2.0.jar CLASSPATH=$CLASSPATH:$BASE_DIR/lib/netty-3.1.0.CR1.jar diff --git a/config/web.xml b/config/web.xml index f49e728729..831543f358 100644 --- a/config/web.xml +++ b/config/web.xml @@ -6,5 +6,5 @@ Akka Servlet /* - + diff --git a/deploy/akka-samples-java-0.5.jar b/deploy/akka-samples-java-0.5.jar index ba656cdbed..e0fecd9427 100644 Binary files a/deploy/akka-samples-java-0.5.jar and b/deploy/akka-samples-java-0.5.jar differ diff --git a/deploy/akka-samples-scala-0.5.jar b/deploy/akka-samples-scala-0.5.jar index faf5c4e9c3..a5bc4b3c6f 100644 Binary files a/deploy/akka-samples-scala-0.5.jar and b/deploy/akka-samples-scala-0.5.jar differ diff --git a/kernel/pom.xml b/kernel/pom.xml index c220730b7e..4692cf98a1 100644 --- a/kernel/pom.xml +++ b/kernel/pom.xml @@ -130,6 +130,11 @@ jersey-scala 1.1.2-ea-SNAPSHOT + + com.sun.jersey.contribs + jersey-lift + 1.1.2-ea-SNAPSHOT + diff --git a/kernel/src/main/scala/Kernel.scala b/kernel/src/main/scala/Kernel.scala index 9ca5a249c8..a20292181f 100644 --- a/kernel/src/main/scala/Kernel.scala +++ b/kernel/src/main/scala/Kernel.scala @@ -125,9 +125,17 @@ object Kernel extends Logging { val uri = UriBuilder.fromUri(REST_URL).port(REST_PORT).build() val adapter = new ServletAdapter val servlet = new AkkaServlet + + adapter.addInitParameter("bootloader", config.getString("akka.lift.bootloader").getOrElse(null)) + adapter.addInitParameter("com.sun.jersey.config.feature.Redirect", "true") + adapter.addInitParameter("com.sun.jersey.config.feature.ImplicitViewables", "true") adapter.setServletInstance(servlet) adapter.setContextPath(uri.getPath) + //TODO add initialization of Lift (LiftFilter needs initialization) + + log.debug("REST service context path: [" + uri.getPath + "]") + val scheme = uri.getScheme if (!scheme.equalsIgnoreCase("http")) throw new IllegalArgumentException("The URI scheme, of the URI " + REST_URL + ", must be equal (ignoring case) to 'http'") @@ -136,6 +144,7 @@ object Kernel extends Logging { jerseySelectorThread.setPort(REST_PORT) jerseySelectorThread.setAdapter(adapter) jerseySelectorThread.listen + log.info("REST service started successfully. Listening to port [" + REST_PORT + "]") } diff --git a/kernel/src/main/scala/jersey/AkkaServlet.scala b/kernel/src/main/scala/jersey/AkkaServlet.scala index efb9e0a960..1d51949e25 100644 --- a/kernel/src/main/scala/jersey/AkkaServlet.scala +++ b/kernel/src/main/scala/jersey/AkkaServlet.scala @@ -10,12 +10,13 @@ import config.ConfiguratorRepository import com.sun.jersey.api.core.{DefaultResourceConfig, ResourceConfig} import com.sun.jersey.spi.container.servlet.ServletContainer import com.sun.jersey.spi.container.WebApplication - import java.util.HashSet -class AkkaServlet extends ServletContainer { +class AkkaServlet extends ServletContainer{ override def initiate(rc: ResourceConfig, wa: WebApplication) = { + // super.initiate(rc, wa) + Kernel.boot // will boot if not already booted by 'main' val configurators = ConfiguratorRepository.getConfiguratorsFor(getServletContext); val set = new HashSet[Class[_]] @@ -26,6 +27,6 @@ class AkkaServlet extends ServletContainer { wa.initiate( new DefaultResourceConfig(set), - new ActorComponentProviderFactory(configurators)); + new ActorComponentProviderFactory(configurators)) } } \ No newline at end of file diff --git a/lib/akka-kernel-0.5.jar b/lib/akka-kernel-0.5.jar index c1306e3952..f21c05cd8a 100644 Binary files a/lib/akka-kernel-0.5.jar and b/lib/akka-kernel-0.5.jar differ diff --git a/lib/akka-util-java-0.5.jar b/lib/akka-util-java-0.5.jar index 55c89e12bc..02ce908044 100644 Binary files a/lib/akka-util-java-0.5.jar and b/lib/akka-util-java-0.5.jar differ diff --git a/lib/jersey-lift-1.1.2-ea-SNAPSHOT.jar b/lib/jersey-lift-1.1.2-ea-SNAPSHOT.jar new file mode 100644 index 0000000000..72403fe793 Binary files /dev/null and b/lib/jersey-lift-1.1.2-ea-SNAPSHOT.jar differ diff --git a/lib/lift-util-1.1-M3.jar b/lib/lift-util-1.1-M3.jar new file mode 100644 index 0000000000..a37eca8b18 Binary files /dev/null and b/lib/lift-util-1.1-M3.jar differ diff --git a/lib/lift-webkit-1.1-M3.jar b/lib/lift-webkit-1.1-M3.jar new file mode 100644 index 0000000000..28da5b281b Binary files /dev/null and b/lib/lift-webkit-1.1-M3.jar differ diff --git a/samples-scala/src/main/scala/SimpleService.scala b/samples-scala/src/main/scala/SimpleService.scala index 6c7b27278d..56734a6025 100644 --- a/samples-scala/src/main/scala/SimpleService.scala +++ b/samples-scala/src/main/scala/SimpleService.scala @@ -1,10 +1,13 @@ package sample.scala -import javax.ws.rs.{Path, GET, Produces} +import javax.ws.rs.{Path, GET, Produces,QueryParam,DefaultValue} import se.scalablesolutions.akka.kernel.state.{TransactionalState, TransactionalMap, CassandraStorageConfig} import se.scalablesolutions.akka.kernel.actor.{Supervisor, SupervisorFactory, Actor, StartSupervisor} import se.scalablesolutions.akka.kernel.config.ScalaConfig._ +import _root_.scala.xml.{NodeSeq} +import se.scalablesolutions.akka.kernel.util.{Logging} + class Boot { object factory extends SupervisorFactory { override def getSupervisorConfig: SupervisorConfig = { @@ -38,22 +41,33 @@ class SimpleService extends Actor { private val storage = TransactionalState.newPersistentMap(CassandraStorageConfig()) @GET - @Produces(Array("application/xml")) - def count = (this !! Tick).getOrElse(Error in counter) + @Produces(Array("text/html")) + def count(@DefaultValue("unknown") @QueryParam("who") who : String) = { + log.info(who) + + (this !! Tick).getOrElse(view(Error in counter)) + } override def receive: PartialFunction[Any, Unit] = { 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(view(Tick: {counter + 1})) } else { storage.put(KEY, new Integer(0)) hasStartedTicking = true - reply(Tick: 0) + reply(view(Tick: 0)) } } override protected def postRestart(reason: AnyRef, config: Option[AnyRef]) = { println("Restarting due to: " + reason.asInstanceOf[Exception].getMessage) } + + def view(data : NodeSeq) : NodeSeq = { data } +} + +class Howdy +{ + def greet =

Hello mommy

} \ No newline at end of file