...
The JAX-RS 2.1 introduced the support of server-sent events (SSE). Although SSE in general works on top of HTTP transport, the SSE implementation in CXF uses the dedicated one, based on Atmosphere framework. This transport only required on the server-side (client side works over normal HTTP) and is fully compatible with HTTP onetransport.
Configuration
There are several ways to configure SSE transport (and as the consequence, SSE support). The most straightforward one is to pass the init parameter "transportId" to the CXF servlet in question, for example:
Code Block |
---|
final CXFNonSpringServlet cxfServlet = new CXFNonSpringServlet();
final ServletHolder holder = new ServletHolder(cxfServlet);
holder.setInitParameter(CXFCdiServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID);
... |
In this case the JAXRSServerFactoryBean instances should also specify the SSE transport during construction time, for example:
Code Block |
---|
final JAXRSServerFactoryBean factory = RuntimeDelegate.getInstance().createEndpoint(<application>, JAXRSServerFactoryBean.class); factory.setTransportId(SseHttpTransportFactory.TRANSPORT_ID); ... return factory.create(); |