OSGi-JAX-RS Connector 2.1.0 released

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:

4 Comments
  • Eric
    Posted at 4:46 pm, November 16, 2012

    Hi

    Do you think your connector could work with Glassfish? I tried installing it (not an easy task since Glassfish is using a different version of Jersey) and I was able to get it in Active state but when I try to install one of the samples it fails with things like

    java.net.URISyntaxException: Illegal character in path at index 30: bundle://281.0:0/launch/JAX-RS Example DS.launch

    or

    java.lang
    .IllegalStateException: org.osgi.service.http.NamespaceException: alias already registered
    Caused by: org.osgi.service.http.NamespaceException: alias already registered

    Regards

  • Thomas
    Posted at 6:24 pm, December 12, 2012

    Hi Holger,

    i’m using your connector for my osgi services. now i want to convert my pojos to json transparently. some tutorials around the internet suggest me to configure my servlet with an init param (like here: mkyong.com/webservices/jax-rs/json-example-with-jersey-jackson) . currently i’m using an equinox bridgeservlet which delegates the servlet requests to a http service, and finally to your dynamically registred “rest servlet”. how i can configure this servlet init params? cause, currently i’m stucked with Exceptions like this: “A message body writer for Java class java.util.ArrayList, and Java type java.util.List, and MIME media type application/json was not found”

    thank you in advance
    thomas