Hi Guenther,

You can use CXF registering the CXF JAXRS server using DS.

Another option could be to use Aries JAXRS with the whiteboard pattern.

We are preparing samples about that:

https://github.com/jbonofre/karaf/tree/DEV_GUIDE/examples/karaf-rest-example

I will add an example with Aries JAXRS and DS.

With Aries JAXRS, you can simply do:

@Component(
    property = {
        JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT +
"=(osgi.jaxrs.name=.default)",
        JaxrsWhiteboardConstants.JAX_RS_RESOURCE + "=true"
    },
    service = ExampleRest.class
)
public class ExampleRest {

    @GET
    @Path("/{name}")
    public String sayHello(@PathParam("name") String name) {
        if (_log.isDebugEnabled()) {
            _log.debug("URI: " + _uriInfo.getAbsolutePath());
        }

        return "Hello " + name;
    }

    @Context
    UriInfo _uriInfo;

    private static final Logger _log = LoggerFactory.getLogger(
        ExampleAddon.class);

}

Regards
JB

On 28/05/2018 19:40, Guenther Schmidt wrote:
> Hello All,
> 
> I’ve been developing services using Declarative Services for dependency 
> injection and it was a breeze so far. Now I want to expose some of the 
> functionality via a REST API and I’m stuck. So far I’ve deployed my bundles 
> through bundle:install -s man: …. all very easy. But what should be simple, 
> exposing this through REST is becoming difficult. There are tips out there 
> suggesting to use Blueprint, which I don’t want, others seem to suggest that 
> I need to create a “feature” package.
> 
> Then there’s also the requirements to “feature” install cxf. That’s OK btw, I 
> only have to do that once. But is there really no simple way to create a 
> simple REST service using merely DS?
> 
> Guenther
> 
> 

-- 
--
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to