From 1c15e26c18646be4772b1d3ea0892a091acaa2a5 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Mon, 7 Mar 2011 13:49:33 +0100 Subject: [PATCH] Moving most of the Jersey and Jetty deps into MicroKernel (akka-modules), closing #593 --- .../scala/akka/http/DefaultAkkaLoader.scala | 25 ------- .../scala/akka/http/EmbeddedAppServer.scala | 73 ------------------- project/build/AkkaProject.scala | 23 +----- 3 files changed, 3 insertions(+), 118 deletions(-) delete mode 100644 akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala delete mode 100644 akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala diff --git a/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala b/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala deleted file mode 100644 index 35a9918bc1..0000000000 --- a/akka-http/src/main/scala/akka/http/DefaultAkkaLoader.scala +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.http - -import akka.config.Config -import akka.util.{Bootable} -import akka.remote.BootableRemoteActorService -import akka.actor.BootableActorLoaderService -import akka.servlet.AkkaLoader - -class DefaultAkkaLoader extends AkkaLoader { - def boot(): Unit = boot(true, new EmbeddedAppServer with BootableActorLoaderService with BootableRemoteActorService) -} - - -/** - * Can be used to boot Akka - * - * java -cp ... akka.http.Main - */ -object Main extends DefaultAkkaLoader { - def main(args: Array[String]) = boot -} diff --git a/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala b/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala deleted file mode 100644 index 6ca38736f7..0000000000 --- a/akka-http/src/main/scala/akka/http/EmbeddedAppServer.scala +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (C) 2009-2011 Scalable Solutions AB - */ - -package akka.http - -import javax.ws.rs.core.UriBuilder -import javax.servlet.ServletConfig -import java.io.File - -import akka.actor.BootableActorLoaderService -import akka.util.Bootable - -import org.eclipse.jetty.xml.XmlConfiguration -import org.eclipse.jetty.server.{Handler, Server} -import org.eclipse.jetty.server.handler.{HandlerList, HandlerCollection, ContextHandler} -import java.net.URL -import akka.AkkaException - -/** - * Handles the Akka Comet Support (load/unload) - */ -trait EmbeddedAppServer extends Bootable { - self: BootableActorLoaderService => - - import akka.config.Config._ - - val REST_HOSTNAME = config.getString("akka.http.hostname", "localhost") - val REST_PORT = config.getInt("akka.http.port", 9998) - - val isRestEnabled = config.getList("akka.enabled-modules").exists(_ == "http") - - protected var server: Option[Server] = None - - protected def findJettyConfigXML: Option[URL] = - Option(applicationLoader.getOrElse(this.getClass.getClassLoader).getResource("microkernel-server.xml")) orElse - HOME.map(home => new File(home + "/config/microkernel-server.xml").toURI.toURL) - - abstract override def onLoad = { - super.onLoad - if (isRestEnabled) { - - val configuration = new XmlConfiguration(findJettyConfigXML.getOrElse(error("microkernel-server.xml not found!"))) - - System.setProperty("jetty.port", REST_PORT.toString) - System.setProperty("jetty.host", REST_HOSTNAME) - - HOME.foreach( home => System.setProperty("jetty.home", home + "/deploy/root") ) - - server = Option(configuration.configure.asInstanceOf[Server]) map { s => //Set the correct classloader to our contexts - applicationLoader foreach { loader => - //We need to provide the correct classloader to the servlets - def setClassLoader(handlers: Seq[Handler]): Unit = { - handlers foreach { - case c: ContextHandler => c.setClassLoader(loader) - case c: HandlerCollection => setClassLoader(c.getHandlers) - case _ => - } - } - setClassLoader(s.getHandlers) - } - //Start the server - s.start() - s - } - } - } - - abstract override def onUnload = { - super.onUnload - server foreach { _.stop() } - } -} diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index acf07c5ea9..3e1aefef2d 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -135,11 +135,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { lazy val javax_servlet_30 = "org.glassfish" % "javax.servlet" % JAVAX_SERVLET_VERSION % "provided" //CDDL v1 - lazy val jetty = "org.eclipse.jetty" % "jetty-server" % JETTY_VERSION % "compile" //Eclipse license - lazy val jetty_util = "org.eclipse.jetty" % "jetty-util" % JETTY_VERSION % "compile" //Eclipse license - lazy val jetty_xml = "org.eclipse.jetty" % "jetty-xml" % JETTY_VERSION % "compile" //Eclipse license - lazy val jetty_servlet = "org.eclipse.jetty" % "jetty-servlet" % JETTY_VERSION % "compile" //Eclipse license - + lazy val jetty = "org.eclipse.jetty" % "jetty-server" % JETTY_VERSION % "provided" //Eclipse license lazy val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" //ApacheV2 lazy val h2_lzf = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile" //ApacheV2 @@ -147,10 +143,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { lazy val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % JACKSON_VERSION % "compile" //ApacheV2 lazy val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % JACKSON_VERSION % "compile" //ApacheV2 - lazy val jersey = "com.sun.jersey" % "jersey-core" % JERSEY_VERSION % "compile" //CDDL v1 - lazy val jersey_json = "com.sun.jersey" % "jersey-json" % JERSEY_VERSION % "compile" //CDDL v1 - lazy val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile" //CDDL v1 - lazy val jersey_contrib = "com.sun.jersey.contribs" % "jersey-scala" % JERSEY_VERSION % "compile" //CDDL v1 + lazy val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "provided" //CDDL v1 lazy val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" //CDDL v1 @@ -168,8 +161,6 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { lazy val sjson = "net.debasishg" % "sjson_2.8.1" % "0.9.1" % "compile" //ApacheV2 lazy val sjson_test = "net.debasishg" % "sjson_2.8.1" % "0.9.1" % "test" //ApacheV2 - lazy val stax_api = "javax.xml.stream" % "stax-api" % "1.0-2" % "compile" //ApacheV2 - // Test lazy val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" //ApacheV2 @@ -358,16 +349,8 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { val jsr250 = Dependencies.jsr250 val javax_servlet30 = Dependencies.javax_servlet_30 val jetty = Dependencies.jetty - val jetty_util = Dependencies.jetty_util - val jetty_xml = Dependencies.jetty_xml - val jetty_servlet = Dependencies.jetty_servlet - val jackson_core = Dependencies.jackson_core - val jersey = Dependencies.jersey - val jersey_contrib = Dependencies.jersey_contrib - val jersey_json = Dependencies.jersey_json - val jersey_server = Dependencies.jersey_server + val jersey = Dependencies.jersey_server val jsr311 = Dependencies.jsr311 - val stax_api = Dependencies.stax_api // testing val junit = Dependencies.junit