Hi Steinar, I think it would be great to have such example in the Karaf ones.
Mind to create a PR ? Thanks Regards JB On 07/10/2018 12:53, Steinar Bang wrote: >>>>>> Serge Huber <[email protected]>: > >> Hello everyo >> I've just started a Google Document where I started a step-by-step >> comparison of creating a REST service with Karaf and Spring Boot. I >> used a guide from Spring boot as a starting point and copied all the >> steps over from there. I haven't done the Karaf part because I'm sure >> others can do it and I'm a little pressed for time this morning. > > Here's a code example of setting up a Jersey REST service in karaf: > https://github.com/steinarb/jersey-demo > > It defines an OSGi service in the bundle jerseyinkaraf.servicedef, > implements the service with a DS component in the bundle > jerseyinkaraf.services. > > Then it creates a web whiteboard DS component that implements a Servlet > service based on the Jersey servlet container. In that DS component, it > does a little magic to connect the Jersey resources to OSGi services. > Basically this init() method makes it possible to have the OSGi services > injected into the Jersey resources when Jersey creates them: > > https://github.com/steinarb/jersey-demo/blob/master/jerseyinkaraf.webapi/src/main/java/no/priv/bang/demos/jerseyinkaraf/webapi/CounterServiceServlet.java#L54 > > A Jersey resource with an OSGi service injection looks like this: > > https://github.com/steinarb/jersey-demo/blob/master/jerseyinkaraf.webapi/src/main/java/no/priv/bang/demos/jerseyinkaraf/webapi/resources/CounterResource.java#L28 > > The jerseyinkaraf.webgui bundle contains a DS component that creates a > web whiteboard Servlet service that defines a simple web GUI for the > counter service. > > The top POM also creates and attaches a feature.xml file including all > of the bundles' feature repositories. > -- Jean-Baptiste Onofré [email protected] http://blog.nanthrax.net Talend - http://www.talend.com
