Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release/0.0.6'

  • Loading branch information...
commit 6c258a787d048e429a615dc77ea6f582d841e317 2 parents b0ae3fb + 0762fd4
@codahale codahale authored
View
2  project/build.properties
@@ -3,6 +3,6 @@
project.organization=com.yammer
project.name=dropwizard
sbt.version=0.7.7
-project.version=0.0.5
+project.version=0.0.6
build.scala.versions=2.8.1 2.9.0
project.initialize=false
View
4 project/build/DropwizardProject.scala
@@ -35,7 +35,7 @@ class DropwizardProject(info: ProjectInfo) extends DefaultProject(info)
/**
* Jersey Dependencies
*/
- val jerseyScala = "com.codahale" %% "jersey-scala" % "0.1.4"
+ val jerseyScala = "com.codahale" %% "jersey-scala" % "0.1.5"
/**
* Misc Dependencies
@@ -61,7 +61,7 @@ class DropwizardProject(info: ProjectInfo) extends DefaultProject(info)
* Jetty Dependencies
*/
val servletApi = "javax.servlet" % "servlet-api" % "2.5"
- val jettyVersion = "7.4.0.v20110414"
+ val jettyVersion = "7.4.1.v20110513"
val jetty = "org.eclipse.jetty"
val jettyServer = jetty % "jetty-server" % jettyVersion
val jettyServlet = jetty % "jetty-servlet" % jettyVersion
View
3  src/main/scala/com/yammer/dropwizard/Environment.scala
@@ -9,6 +9,7 @@ import javax.servlet.{Servlet, Filter}
import com.sun.jersey.core.reflection.MethodList
import javax.ws.rs.{Path, HttpMethod}
import org.eclipse.jetty.servlet.{ServletHolder, FilterHolder}
+import com.yammer.dropwizard.jetty.NonblockingServletHolder
class Environment extends Logging {
private[dropwizard] var resources = Set.empty[Object]
@@ -68,7 +69,7 @@ class Environment extends Logging {
pathSpec: String,
params: Map[String, String] = Map.empty,
initOrder: Int = 0) {
- val holder = new ServletHolder(servlet)
+ val holder = new NonblockingServletHolder(servlet)
holder.setInitParameters(params)
holder.setInitOrder(initOrder)
servlets += pathSpec -> holder
View
17 src/main/scala/com/yammer/dropwizard/etc/CacheBustingFilter.scala
@@ -0,0 +1,17 @@
+package com.yammer.dropwizard.etc
+
+import javax.servlet._
+import javax.servlet.http.HttpServletResponse
+
+class CacheBustingFilter extends Filter {
+ def init(filterConfig: FilterConfig) {}
+
+ def doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) {
+ if (response.isInstanceOf[HttpServletResponse]) {
+ response.asInstanceOf[HttpServletResponse].setHeader("Cache-Control", "must-revalidate,no-cache,no-store")
+ chain.doFilter(request, response)
+ }
+ }
+
+ def destroy() {}
+}
View
12 src/main/scala/com/yammer/dropwizard/jetty/AsyncRequestLog.scala
@@ -8,6 +8,7 @@ import org.eclipse.jetty.util.log.Log
import org.eclipse.jetty.server.{Authentication, Response, Request, RequestLog}
import org.eclipse.jetty.util.{DateCache, RolloverFileOutputStream}
import java.util.{Locale, ArrayList, TimeZone}
+import java.lang.ThreadLocal
object AsyncRequestLog {
private val i = new AtomicInteger
@@ -28,8 +29,13 @@ class AsyncRequestLog(filenamePattern: Option[String],
import collection.JavaConversions._
private val queue = new LinkedBlockingQueue[String]
- private val logDateCache = new DateCache("dd/MMM/yyyy:HH:mm:ss Z", Locale.getDefault)
- logDateCache.setTimeZoneID("UTC")
+ private val logDateCache = new ThreadLocal[DateCache] {
+ override def initialValue() = {
+ val cache = new DateCache("dd/MMM/yyyy:HH:mm:ss Z", Locale.getDefault)
+ cache.setTimeZoneID("UTC")
+ cache
+ }
+ }
private val dispatcher = new Dispatcher
private val dispatchThread = new Thread(dispatcher)
dispatchThread.setName("async-request-log-dispatcher-" + i.incrementAndGet())
@@ -88,7 +94,7 @@ class AsyncRequestLog(filenamePattern: Option[String],
buf.append(" - ")
}
- buf.append(" [").append(logDateCache.format(request.getTimeStamp)).append("] \"")
+ buf.append(" [").append(logDateCache.get().format(request.getTimeStamp)).append("] \"")
buf.append(request.getMethod).append(' ').append(request.getUri.toString)
buf.append(' ').append(request.getProtocol).append("\" ")
View
26 src/main/scala/com/yammer/dropwizard/jetty/NonblockingServletHolder.scala
@@ -0,0 +1,26 @@
+package com.yammer.dropwizard.jetty
+
+import org.eclipse.jetty.servlet.ServletHolder
+import org.eclipse.jetty.server.Request
+import javax.servlet.{ServletResponse, ServletRequest, Servlet}
+
+/**
+ * A {@link ServletHolder} subclass which removes much of the synchronization
+ * around servlet initialization, preferring instead to simply use an
+ * already-created servlet instance.
+ */
+class NonblockingServletHolder(servlet: Servlet) extends ServletHolder(servlet) {
+ override def getServlet = servlet
+
+ override def handle(baseRequest: Request, request: ServletRequest, response: ServletResponse) {
+ val suspendable = baseRequest.isAsyncSupported
+ if (!isAsyncSupported) {
+ baseRequest.setAsyncSupported(false)
+ }
+ try {
+ servlet.service(request, response)
+ } finally {
+ baseRequest.setAsyncSupported(suspendable)
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.