use of org.apache.cxf.jaxrs.sse.OutboundSseEventBodyWriter in project cxf by apache.
the class SseAtmosphereEventSinkContextProvider method createContext.
@Override
public SseEventSink createContext(Message message) {
final HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST);
if (request == null) {
throw new IllegalStateException("Unable to retrieve HTTP request from the context");
}
final AtmosphereResource resource = (AtmosphereResource) request.getAttribute(AtmosphereResource.class.getName());
if (resource == null) {
throw new IllegalStateException("AtmosphereResource is not present, " + "is AtmosphereServlet configured properly?");
}
final Broadcaster broadcaster = resource.getAtmosphereConfig().getBroadcasterFactory().lookup(resource.uuid(), true);
resource.removeFromAllBroadcasters();
resource.setBroadcaster(broadcaster);
final MessageBodyWriter<OutboundSseEvent> writer = new OutboundSseEventBodyWriter(ServerProviderFactory.getInstance(message), message.getExchange());
return new SseAtmosphereEventSinkImpl(writer, resource);
}
Aggregations