use of org.jboss.resteasy.core.PostResourceMethodInvoker 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();
}
});
}
}
Aggregations