Hi Steinar,

If you’re looking to use JAX-RS then the standard approach would be to use the 
JAX-RS Whiteboard specification 
(https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html 
<https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html>). There are 
examples of how you can do this in OSGi enRoute (https://enroute.osgi.org 
<https://enroute.osgi.org/>). The reference implementation from Apache Aries is 
easily available in Maven Central 
(https://mvnrepository.com/artifact/org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
 
<https://mvnrepository.com/artifact/org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0>)

The good news is that the JAX-RS whiteboard doesn’t need you to annotate your 
interfaces with JAX-RS annotations, or even use interfaces at all if you don’t 
want to. The whiteboard will automatically process any services that set the 
relevant properties from the specification. If you are using OSGi R7 then you 
can do this with Component Property annotations, but R7 isn’t required (you can 
just put the properties on using the component annotation). The Aries 
implementation also runs just fine on an R6 framework with R6 compendium 
services. It even uses the Http Service whiteboard 1.0 specification, which is 
what you want!

The really good news is that because your JAX-RS resources are provided as 
services you can use DS to inject your service dependencies. This prevents you 
from having to mess around trying to add service injection to the JAX-RS 
runtime.

In summary, you should be able to add Aries JAX-RS whiteboard 1.0.0, Aries 
JAX-RS API 1.0.0, and ServiceMix Specs  Annotation API 1.3 and start using it.

Best Regards,

Tim

> On 14 Jul 2018, at 23:18, Steinar Bang <s...@dod.no> wrote:
> 
>>>>>> Scott Lewis <sle...@composent.com>:
> 
> 
>> If you would like to expidite, please open an issue here [1] for the
>> use of http-whiteboard in jersey and cxf distribution providers, and
>> it could happen pretty quickly.
> 
> https://github.com/ECF/JaxRSProviders/issues/7
> 
> (but as I say below: the biggest hurdle for me is transitioning to karaf
> 4.2.x as I ran into some problems when I (inadvertently) tried it last
> week)
> 
>> BTW:  why do you require http-whiteboard for implementation?   I'm not
>> arguing against using http-whiteboard, but I expect that using
>> HttpService directly and http-whiteboard can co-exist in a single
>> framework,  so why not consider both?
> 
> The ukelonn webapp[1] started out in July 2016 as a JSF/primefaces war
> bundle, configured with web.xml[2].  In October 2016 I started running the
> webapp on karaf (and using OSGi for webapps became a *lot* easier...).  
> 
> Then it was transformed into a vaadin application[3], still as a war
> bundle with web.xml.  Then it was transformed into vaadin webapp in a
> jar bundle with the servlets registering with the HttpService, then
> finally turned into a vaadin webapp using http whiteboard (the current
> master).
> 
> I'm now in the process of transforming this into a reactjs webapp[4],
> and am still using http whiteboard.  Registering with the HttpService is
> of course possible, but feels like a step backwards. :-)
> 
> The biggest hurdle will be the transition to karaf 4.2.0, which I
> eventually need to make, but right now it's more fun to work on the
> reactjs part of things.  So it will happen sometime in the future.
> 
> References:
> [1] <https://github.com/steinarb/ukelonn>
> [2] <https://github.com/steinarb/ukelonn/tree/using-primefaces>
> [3] <https://github.com/steinarb/ukelonn/tree/using-vaadin>
> [4] <https://github.com/steinarb/ukelonn/tree/using-react>
> 

Reply via email to