use of org.jboss.resteasy.core.interception.jaxrs.PostMatchContainerRequestContext in project resteasy by resteasy.
the class SseEventSinkInterceptor method filter.
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
ResourceMethodInvoker rmi = ((PostMatchContainerRequestContext) requestContext).getResourceMethod();
if (rmi.isAsyncStreamProvider() || rmi.isSse()) {
Dispatcher dispatcher = ResteasyContext.getContextData(Dispatcher.class);
ResteasyProviderFactory providerFactory = dispatcher != null ? dispatcher.getProviderFactory() : ResteasyProviderFactory.getInstance();
SseEventOutputImpl sink = new SseEventOutputImpl(new SseEventProvider(providerFactory), providerFactory);
ResteasyContext.getContextDataMap().put(SseEventSink.class, sink);
ResteasyContext.getContextData(PostResourceMethodInvokers.class).addInvokers(new PostResourceMethodInvoker() {
@Override
public void invoke() {
sink.flushResponseToClient();
}
});
}
}
use of org.jboss.resteasy.core.interception.jaxrs.PostMatchContainerRequestContext in project resteasy by resteasy.
the class ResourceMethodInvoker method invokeOnTarget.
protected BuiltResponse invokeOnTarget(HttpRequest request, HttpResponse response, Object target) {
final RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request);
final long timestamp = tracingLogger.timestamp("METHOD_INVOKE");
final long msTimeStamp = methodStatisticsLogger.timestamp();
try {
// we don't pop so writer interceptors can get at this
ResteasyContext.pushContext(ResourceInfo.class, resourceInfo);
ResteasyContext.pushContext(Configuration.class, resourceMethodProviderFactory);
if (requestFilters != null && requestFilters.length > 0) {
PostMatchContainerRequestContext requestContext = new PostMatchContainerRequestContext(request, this, requestFilters, () -> invokeOnTargetAfterFilter(request, response, target));
// let it handle the continuation
return requestContext.filter();
} else {
return invokeOnTargetAfterFilter(request, response, target);
}
} finally {
methodStatisticsLogger.duration(msTimeStamp);
if (resource instanceof SingletonResource) {
tracingLogger.logDuration("METHOD_INVOKE", timestamp, ((SingletonResource) resource).traceInfo(), method.getMethod());
} else {
tracingLogger.logDuration("METHOD_INVOKE", timestamp, resource, method.getMethod());
}
}
}
Aggregations