Search in sources :

Example 1 with PostResourceMethodInvoker

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();
            }
        });
    }
}
Also used : PostResourceMethodInvoker(org.jboss.resteasy.core.PostResourceMethodInvoker) ResourceMethodInvoker(org.jboss.resteasy.core.ResourceMethodInvoker) PostMatchContainerRequestContext(org.jboss.resteasy.core.interception.jaxrs.PostMatchContainerRequestContext) PostResourceMethodInvoker(org.jboss.resteasy.core.PostResourceMethodInvoker) Dispatcher(org.jboss.resteasy.spi.Dispatcher) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory) PostResourceMethodInvokers(org.jboss.resteasy.core.PostResourceMethodInvokers)

Aggregations

PostResourceMethodInvoker (org.jboss.resteasy.core.PostResourceMethodInvoker)1 PostResourceMethodInvokers (org.jboss.resteasy.core.PostResourceMethodInvokers)1 ResourceMethodInvoker (org.jboss.resteasy.core.ResourceMethodInvoker)1 PostMatchContainerRequestContext (org.jboss.resteasy.core.interception.jaxrs.PostMatchContainerRequestContext)1 Dispatcher (org.jboss.resteasy.spi.Dispatcher)1 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)1