@Override public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException { // Copy the headers because they get committed before the message body writer context is // called, and when they are committed, the contents of the map is modified. ResponseMethodStats stats = new ResponseMethodStats(); MultivaluedTreeMap.addAll(response.getHeaders(), stats.responseHeaders); stats.statusCode = response.getStatus(); request.setProperty(RESPONSE_STATS_NAME, stats); }
protected RequestMethodStats doPreProcess(PreMatchContainerRequestContext request) throws Failure, WebApplicationException { RequestMethodStats stats = new RequestMethodStats(); stats.uri = request.getUriInfo().getRequestUri().toString(); stats.method = request.getMethod(); stats.callStartTime = System.nanoTime(); try { stats.callStartTime = Long.parseLong(httpHeaders.getHeaderString(REQUEST_START_TIME_HEADER)); } catch (Exception e) { // ignore -- we just won't set call start time properly } try { stats.loginTime = Long.parseLong(httpHeaders.getHeaderString(REQUEST_LOGIN_TIME_HEADER)); } catch (Exception e) { // ignore -- we just won't set login time. } MultivaluedTreeMap.addAll(request.getHeaders(), stats.requestHeaders); MediaType mediaType = request.getMediaType(); if (mediaType != null && mediaType.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) { MultivaluedMap<String,String> formParameters = request.getHttpRequest().getDecodedFormParameters(); if (formParameters != null) MultivaluedTreeMap.addAll(formParameters, stats.formParameters); } request.setProperty(REQUEST_STATS_NAME, stats); return stats; }