Adding AkkaRestServlet that will provide the same functionality as the AkkaServlet - Atmosphere

This commit is contained in:
Viktor Klang 2010-11-25 14:10:53 +01:00
parent 6121a8008f
commit 4acee62576
3 changed files with 56 additions and 17 deletions

View file

@ -0,0 +1,38 @@
/**
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
*/
package akka.http
import com.sun.jersey.spi.container.servlet.ServletContainer
/**
* This is just a simple wrapper on top of ServletContainer to inject some config from the akka.conf
* If you were using akka.comet.AkkaServlet before, but only use it for Jersey, you should switch to this servlet instead
*/
class AkkaRestServlet extends ServletContainer {
import akka.config.Config.{config => c}
val initParams = new java.util.HashMap[String,String]
addInitParameter("com.sun.jersey.config.property.packages", c.getList("akka.http.resource_packages").mkString(";"))
addInitParameter("com.sun.jersey.spi.container.ResourceFilters",c.getList("akka.http.filters").mkString(","))
/**
* Provide a fallback for default values
*/
override def getInitParameter(key : String) =
Option(super.getInitParameter(key)).getOrElse(initParams get key)
/**
* Provide a fallback for default values
*/
override def getInitParameterNames() = {
import scala.collection.JavaConversions._
initParams.keySet.iterator ++ super.getInitParameterNames
}
/**
* Provide possibility to add config params
*/
def addInitParameter(param: String, value: String): Unit = initParams.put(param,value)
}

View file

@ -205,7 +205,7 @@ object Endpoint {
/** /**
* leverage the akka config to tweak the dispatcher for our endpoints * leverage the akka config to tweak the dispatcher for our endpoints
*/ */
final val Dispatcher = Dispatchers.fromConfig("akka.http.comet-dispatcher") final val Dispatcher = Dispatchers.fromConfig("akka.http.mist-dispatcher")
type Hook = Function[String, Boolean] type Hook = Function[String, Boolean]
type Provider = Function[String, ActorRef] type Provider = Function[String, ActorRef]

View file

@ -35,12 +35,8 @@ akka {
# - Hawt # - Hawt
# - ExecutorBasedEventDriven # - ExecutorBasedEventDriven
# - ExecutorBasedEventDrivenWorkStealing # - ExecutorBasedEventDrivenWorkStealing
# - ReactorBasedThreadPoolEventDriven
# - ReactorBasedSingleThreadEventDriven
# - GlobalHawt # - GlobalHawt
# - GlobalExecutorBasedEventDriven # - GlobalExecutorBasedEventDriven
# - GlobalReactorBasedSingleThreadEventDriven
# - GlobalReactorBasedThreadPoolEventDriven
keep-alive-time = 60 # Keep alive time for threads keep-alive-time = 60 # Keep alive time for threads
core-pool-size-factor = 1.0 # No of core threads ... ceil(available processors * factor) core-pool-size-factor = 1.0 # No of core threads ... ceil(available processors * factor)
max-pool-size-factor = 4.0 # Max no of threads ... ceil(available processors * factor) max-pool-size-factor = 4.0 # Max no of threads ... ceil(available processors * factor)
@ -89,19 +85,13 @@ akka {
http { http {
hostname = "localhost" hostname = "localhost"
port = 9998 port = 9998
#If you are using akka.http.AkkaRestServlet
filters = ["se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use
resource_packages = ["sample.rest.scala",
"sample.rest.java",
"sample.security"] # List with all resource packages for your Jersey services
authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (sample now) authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (sample now)
comet-dispatcher {
#type = "Hawt" # Uncomment if you want to use a different dispatcher than the default one for Comet
}
connection-close = true # toggles the addition of the "Connection" response header with a "close" value
root-actor-id = "_httproot" # the id of the actor to use as the root endpoint
root-actor-builtin = true # toggles the use of the built-in root endpoint base class
timeout = 1000 # the default timeout for all async requests (in ms)
expired-header-name = "Async-Timeout" # the name of the response header to use when an async request expires
expired-header-value = "expired" # the value of the response header to use when an async request expires
# Uncomment if you are using the KerberosAuthenticationActor # Uncomment if you are using the KerberosAuthenticationActor
# kerberos { # kerberos {
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM" # servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
@ -109,6 +99,17 @@ akka {
# kerberosDebug = "true" # kerberosDebug = "true"
# realm = "EXAMPLE.COM" # realm = "EXAMPLE.COM"
# } # }
#If you are using akka.http.AkkaMistServlet
mist-dispatcher {
#type = "Hawt" # Uncomment if you want to use a different dispatcher than the default one for Comet
}
connection-close = true # toggles the addition of the "Connection" response header with a "close" value
root-actor-id = "_httproot" # the id of the actor to use as the root endpoint
root-actor-builtin = true # toggles the use of the built-in root endpoint base class
timeout = 1000 # the default timeout for all async requests (in ms)
expired-header-name = "Async-Timeout" # the name of the response header to use when an async request expires
expired-header-value = "expired" # the value of the response header to use when an async request expires
} }
remote { remote {