hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

Support for SSe #34

Closed tmontanaro closed 10 years ago

tmontanaro commented 10 years ago

Even if Jersey let us use SSe (as shown here: https://jersey.java.net/documentation/latest/sse.html ) it is not possible to use it with osgi-jax-rs-connector.

The error shown in the console is the following:

MessageBodyWriter not found for media type=text/event-stream, type=class org.glassfish.jersey.media.sse.OutboundEvent, genericType=class org.glassfish.jersey.media.sse.OutboundEvent

And it seems to depend on a not satisfied dependency: on the official Jersey page we can find the following specification

Firstly you need to add a Jersey SSE module dependency to your project as shown in the earlier section and register the SseFeature from this module in your Application or ResourceConfig.
hstaudacher commented 10 years ago

This was a hard one ;). But I think it was worth it...

Anyway, to enable Sse support I had to fix several things: 1) It's now possible to register a Feature as OSGi service besides resources and providers. 2) The SPI lookup had to be enabled again. 3) I have added a provider (com.eclipsesource.jaxrs.provider.sse) that registers the SseFeature as a Service.

So, all you have to do now is to start the provider bundle and you are done. Of cause, you have to implemen tyour sse resources too ;)

I have also added an example bundle called com.eclipsesource.jaxrs.sse.example