Atmosphere almost integrated, ClassLoader issue.
This commit is contained in:
parent
13bc65142e
commit
f7bfb066a5
25 changed files with 173 additions and 82 deletions
|
|
@ -14,7 +14,7 @@ import java.net.URLClassLoader
|
|||
|
||||
import net.lag.configgy.{Config, Configgy, RuntimeEnvironment}
|
||||
|
||||
import kernel.jersey.AkkaServlet
|
||||
import kernel.jersey.{AkkaServlet,AkkaCometServlet}
|
||||
import kernel.nio.RemoteServer
|
||||
import kernel.state.CassandraStorage
|
||||
import kernel.util.Logging
|
||||
|
|
@ -36,7 +36,7 @@ object Kernel extends Logging {
|
|||
val REST_HOSTNAME = kernel.Kernel.config.getString("akka.rest.hostname", "localhost")
|
||||
val REST_URL = "http://" + REST_HOSTNAME
|
||||
val REST_PORT = kernel.Kernel.config.getInt("akka.rest.port", 9998)
|
||||
|
||||
val REST_ROOT = System.getenv("AKKA_HOME") + "/deploy/root/"
|
||||
|
||||
// FIXME add API to shut server down gracefully
|
||||
private var remoteServer: RemoteServer = _
|
||||
|
|
@ -91,8 +91,8 @@ object Kernel extends Logging {
|
|||
|
||||
private[akka] def runApplicationBootClasses = {
|
||||
val HOME = try { System.getenv("AKKA_HOME") } catch { case e: NullPointerException => throw new IllegalStateException("AKKA_HOME system variable needs to be set. Should point to the root of the Akka distribution.") }
|
||||
val CLASSES = HOME + "/kernel/target/classes" // FIXME remove for dist
|
||||
val LIB = HOME + "/lib"
|
||||
//val CLASSES = HOME + "/kernel/target/classes" // FIXME remove for dist
|
||||
//val LIB = HOME + "/lib"
|
||||
val CONFIG = HOME + "/config"
|
||||
val DEPLOY = HOME + "/deploy"
|
||||
val DEPLOY_DIR = new File(DEPLOY)
|
||||
|
|
@ -123,22 +123,25 @@ object Kernel extends Logging {
|
|||
|
||||
private[akka] def startJersey = {
|
||||
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'")
|
||||
|
||||
|
||||
val adapter = new ServletAdapter()
|
||||
//val servlet = org.atmosphere.cpr.AtmosphereServlet
|
||||
//val servlet = new AkkaServlet()
|
||||
//adapter.addInitParameter("bootloader", config.getString("akka.lift.bootloader").getOrElse(null))
|
||||
adapter.addInitParameter("com.sun.jersey.spi.container.ResourceFilters","org.atmosphere.core.AtmosphereFilter")
|
||||
adapter.addInitParameter("com.sun.jersey.config.feature.Redirect", "true")
|
||||
adapter.addInitParameter("com.sun.jersey.config.feature.ImplicitViewables", "true")
|
||||
|
||||
adapter.setServletInstance(new AkkaCometServlet)
|
||||
adapter.setContextPath(uri.getPath)
|
||||
adapter.setRootFolder(REST_ROOT)
|
||||
log.info("REST service root path: [" + adapter.getRootFolder + "] and context path [" + adapter.getContextPath + "] ")
|
||||
|
||||
|
||||
jerseySelectorThread = new SelectorThread
|
||||
jerseySelectorThread.setAlgorithmClassName(classOf[StaticStreamAlgorithm].getName)
|
||||
jerseySelectorThread.setPort(REST_PORT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue