private final Map<String, String[]> parameters;
- private final int status;
+ private int status;
- private final Map<String, String> responseHeaders;
+ private Map<String, String> responseHeaders;
- AccessEvent(Request req, Response rsp) {
+ AccessEvent(Request req) {
method = req.getMethod();
uri = req.getRequestURI();
requestHeaders = cloneHeaders(req);
parameters = clone(req.getParameterMap());
+ }
+ void setResponse(Response rsp) {
status = rsp.getStatus();
responseHeaders = cloneHeaders(rsp);
}
* @return first value of the response header; null if not sent.
*/
public String getResponseHeader(String name) {
- return responseHeaders.get(name);
+ return responseHeaders != null ? responseHeaders.get(name) : null;
}
/** {@inheritDoc} */
}
}
+ AccessEvent event = null;
+ if (DispatcherType.REQUEST
+ .equals(baseRequest.getDispatcherType())) {
+ event = new AccessEvent((Request) request);
+ synchronized (events) {
+ events.add(event);
+ }
+ }
+
super.handle(target, baseRequest, request, response);
- if (DispatcherType.REQUEST.equals(baseRequest.getDispatcherType()))
- log((Request) request, (Response) response);
+ if (event != null) {
+ event.setResponse((Response) response);
+ }
} finally {
active.release();
}
}
-
- private void log(Request request, Response response) {
- synchronized (events) {
- events.add(new AccessEvent(request, response));
- }
- }
}