OSGi-JAX-RS Connector 2.1.0 released
Two months ago the OSGi JAX-RS was released in Version 2.0. Today I’m proud to announce Version 2.1. In addition to minor improvements, a new feature was added based on the work of Dirk Lecluse. It’s now possible to register @Provider
annotated objects as OSGi services. The @Provider
annotation is used to register custom de/serialization. Now you can implement a custom MessageBodyWriter
, MessageBodyReader
, ContextResolver
or ExceptionMapper
, annotate it with @Provider
and simply register it as OSGi service. All the connector does is wire together the resources with the provider.
As a side note: A few days ago I was asked why I would like to register @Path
or @Provider
annotated objects as OSGi services. The answer is that it enables you to wire up your REST interface with the rest of your system loosely. For example, the serialization in my system is an OSGi service too. So, when registering an @Provider
as a service I can use Declarative Services to hook my serialization object into the provider. This enables me to separate domain and framework code because I don’t have to get the service myself - which is a good thing, right? ;)
If you would like to use the connector here are the resources to start with:
- Jersey, the library used by the connector.
- JAX-RS 2.0 API Documentation.
- GitHub repository
- p2 repository: https://hstaudacher.github.com/osgi-jax-rs-connector
- Example for the @Provider integration.
- Example for registering @Path resources. Also available using DS.