diff --git a/akka-http/src/main/scala/Jersey.scala b/akka-http/src/main/scala/Jersey.scala new file mode 100644 index 0000000000..0ee24b0b9f --- /dev/null +++ b/akka-http/src/main/scala/Jersey.scala @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2009-2010 Scalable Solutions AB + */ +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) +} \ No newline at end of file diff --git a/akka-http/src/main/scala/Mist.scala b/akka-http/src/main/scala/Mist.scala index 3cc5faa40b..f9616c831c 100644 --- a/akka-http/src/main/scala/Mist.scala +++ b/akka-http/src/main/scala/Mist.scala @@ -205,7 +205,7 @@ object Endpoint { /** * 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 Provider = Function[String, ActorRef] diff --git a/config/akka-reference.conf b/config/akka-reference.conf index caee1f6d9b..496dd6c640 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -35,12 +35,8 @@ akka { # - Hawt # - ExecutorBasedEventDriven # - ExecutorBasedEventDrivenWorkStealing - # - ReactorBasedThreadPoolEventDriven - # - ReactorBasedSingleThreadEventDriven # - GlobalHawt # - GlobalExecutorBasedEventDriven - # - GlobalReactorBasedSingleThreadEventDriven - # - GlobalReactorBasedThreadPoolEventDriven keep-alive-time = 60 # Keep alive time for threads 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) @@ -89,19 +85,13 @@ akka { http { hostname = "localhost" 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) - - 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 # kerberos { # servicePrincipal = "HTTP/localhost@EXAMPLE.COM" @@ -109,6 +99,17 @@ akka { # kerberosDebug = "true" # 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 {