ContainerResponseContextImpl responseContext = new ContainerResponseContextImpl(request, response, jaxrsResponse, requestContext, responseFilters, onComplete, continuation); responseContext.filter(); logger.logDuration("RESPONSE_FILTER_SUMMARY", timestamp, responseFilters.length);
@Override public void setEntity(Object entity) { //if (entity != null) logger.info("*** setEntity(Object) " + entity.toString()); jaxrsResponse.setEntity(entity); // todo TCK does weird things in its testing of get length // it resets the entity in a response filter which results // in a bad content-length being sent back to the client // so, we'll remove any content-length setting getHeaders().remove(HttpHeaders.CONTENT_LENGTH); }
@Override public synchronized void resume() { if(!suspended) throw new RuntimeException("Cannot resume: not suspended"); if(inFilter) { // suspend/resume within filter, same thread: just ignore and move on suspended = false; return; } ResteasyContext.pushContextDataMap(contextDataMap); // go on, but with proper exception handling try { filter(); }catch(Throwable t) { // don't throw to client writeException(t); } }
@Override public synchronized void resume(Throwable t) { if(!suspended) throw new RuntimeException("Cannot resume: not suspended"); if(inFilter) { // not suspended, or suspend/abortWith within filter, same thread: collect and move on throwable = t; suspended = false; } else { ResteasyContext.pushContextDataMap(contextDataMap); writeException(t); } }
@Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { ContainerResponseContextImpl ctx = (ContainerResponseContextImpl)responseContext; BuiltResponse jaxrsResposne = ctx.getJaxrsResponse(); ServerResponse serverResponse = new ServerResponse(jaxrsResposne); try { interceptor.postProcess(serverResponse); } finally { jaxrsResposne.setStatus(serverResponse.getStatus()); jaxrsResposne.setAnnotations(serverResponse.getAnnotations()); jaxrsResposne.setEntity(serverResponse.getEntity()); jaxrsResposne.setMetadata(serverResponse.getMetadata()); jaxrsResposne.setEntityClass(serverResponse.getEntityClass()); jaxrsResposne.setGenericType(serverResponse.getGenericType()); } } }
else writeException(throwable); return;
@Override public synchronized void resume() { if(!suspended) throw new RuntimeException("Cannot resume: not suspended"); if(inFilter) { // suspend/resume within filter, same thread: just ignore and move on suspended = false; return; } ResteasyContext.pushContextDataMap(contextDataMap); // go on, but with proper exception handling try { filter(); }catch(Throwable t) { // don't throw to client writeException(t); } }
ContainerResponseContextImpl responseContext = new ContainerResponseContextImpl(request, response, jaxrsResponse, requestContext, responseFilters, onComplete, continuation); responseContext.filter(); logger.logDuration("RESPONSE_FILTER_SUMMARY", timestamp, responseFilters.length);
@Override public void setEntity(Object entity, Annotation[] annotations, MediaType mediaType) { //if (entity != null) logger.info("*** setEntity(Object, Annotation[], MediaType) " + entity.toString() + ", " + mediaType); jaxrsResponse.setEntity(entity); jaxrsResponse.setAnnotations(annotations); jaxrsResponse.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, mediaType); // todo TCK does weird things in its testing of get length // it resets the entity in a response filter which results // in a bad content-length being sent back to the client // so, we'll remove any content-length setting getHeaders().remove(HttpHeaders.CONTENT_LENGTH); }
@Override public synchronized void resume(Throwable t) { if(!suspended) throw new RuntimeException("Cannot resume: not suspended"); if(inFilter) { // not suspended, or suspend/abortWith within filter, same thread: collect and move on throwable = t; suspended = false; } else { ResteasyContext.pushContextDataMap(contextDataMap); writeException(t); } }
@Override public void setEntity(Object entity) { //if (entity != null) logger.info("*** setEntity(Object) " + entity.toString()); jaxrsResponse.setEntity(entity); // todo TCK does weird things in its testing of get length // it resets the entity in a response filter which results // in a bad content-length being sent back to the client // so, we'll remove any content-length setting getHeaders().remove(HttpHeaders.CONTENT_LENGTH); }
else writeException(throwable); return;
@Override public void setEntity(Object entity, Annotation[] annotations, MediaType mediaType) { //if (entity != null) logger.info("*** setEntity(Object, Annotation[], MediaType) " + entity.toString() + ", " + mediaType); jaxrsResponse.setEntity(entity); jaxrsResponse.setAnnotations(annotations); jaxrsResponse.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, mediaType); // todo TCK does weird things in its testing of get length // it resets the entity in a response filter which results // in a bad content-length being sent back to the client // so, we'll remove any content-length setting getHeaders().remove(HttpHeaders.CONTENT_LENGTH); }