Search in sources :

Example 1 with ContainerResponseContextImpl

use of org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl in project resteasy by resteasy.

the class ServerResponseWriter method executeFilters.

private static void executeFilters(BuiltResponse jaxrsResponse, HttpRequest request, HttpResponse response, ResteasyProviderFactory providerFactory, ResourceMethodInvoker method, Consumer<Throwable> onComplete, RunnableWithIOException continuation) throws IOException {
    ContainerResponseFilter[] responseFilters = null;
    if (method != null) {
        responseFilters = method.getResponseFilters();
    } else {
        responseFilters = providerFactory.getContainerResponseFilterRegistry().postMatch(null, null);
    }
    if (responseFilters != null) {
        ResponseContainerRequestContext requestContext = new ResponseContainerRequestContext(request);
        ContainerResponseContextImpl responseContext = new ContainerResponseContextImpl(request, response, jaxrsResponse, requestContext, responseFilters, onComplete, continuation);
        RESTEasyTracingLogger logger = RESTEasyTracingLogger.getInstance(request);
        final long timestamp = logger.timestamp("RESPONSE_FILTER_SUMMARY");
        // filter calls the continuation
        responseContext.filter();
        logger.logDuration("RESPONSE_FILTER_SUMMARY", timestamp, responseFilters.length);
    } else {
        try {
            continuation.run(onComplete);
        } catch (Throwable t) {
            onComplete.accept(t);
            SynchronousDispatcher.rethrow(t);
        }
    }
}
Also used : ContainerResponseFilter(jakarta.ws.rs.container.ContainerResponseFilter) ResponseContainerRequestContext(org.jboss.resteasy.core.interception.jaxrs.ResponseContainerRequestContext) ContainerResponseContextImpl(org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl) RESTEasyTracingLogger(org.jboss.resteasy.tracing.RESTEasyTracingLogger)

Aggregations

ContainerResponseFilter (jakarta.ws.rs.container.ContainerResponseFilter)1 ContainerResponseContextImpl (org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl)1 ResponseContainerRequestContext (org.jboss.resteasy.core.interception.jaxrs.ResponseContainerRequestContext)1 RESTEasyTracingLogger (org.jboss.resteasy.tracing.RESTEasyTracingLogger)1