public void handle(String target, Request request,
HttpServletRequest httpRequest, HttpServletResponse httpResponse)
throws IOException, ServletException {
activeDispatches.inc();
final AsyncContinuation continuation = request.getAsyncContinuation();
final long start;
final boolean isMilliseconds;
if (continuation.isInitial()) {
activeRequests.inc();
start = request.getTimeStamp();
isMilliseconds = true;
} else {
activeSuspendedRequests.dec();
if (continuation.isResumed()) {
resumes.mark();
}
isMilliseconds = false;
start = System.nanoTime();
}
try {
super.handle(target, request, httpRequest, httpResponse);
} finally {
if (isMilliseconds) {
final long duration = System.currentTimeMillis() - start;
dispatches.update(duration, TimeUnit.MILLISECONDS);
requestTimer(request.getMethod()).update(duration, TimeUnit.MILLISECONDS);
} else {
final long duration = System.nanoTime() - start;
dispatches.update(duration, TimeUnit.NANOSECONDS);
requestTimer(request.getMethod()).update(duration, TimeUnit.NANOSECONDS);
}
activeDispatches.dec();
if (continuation.isSuspended()) {
if (continuation.isInitial()) {
continuation.addContinuationListener(listener);
}
suspends.mark();
activeSuspendedRequests.inc();
} else if (continuation.isInitial()) {
updateResponses(request);
}
}
}