REST - Declarative Services

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

REST - Declarative Services

Guenther Schmidt
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


Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre
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é
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

cschneider
In reply to this post by Guenther Schmidt
Aries JAX-RS should work. It is not yet released though. So currently there is only a snapshot. A release should follow soon.

Another option is to use CXF-DOSGi. You can find an example below. It is similar to Aries JAX-RS so a later switch should be easy.


Christian

2018-05-28 19:40 GMT+02:00 Guenther Schmidt <[hidden email]>:
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





--
--
Christian Schneider

http://www.liquid-reality.de

Computer Scientist

Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Alex Weirig

I'm using the approach Christian is referring to and I can confirm that it's really easy and convenient.

I'm creating DS services to expose selected backend services with a REST API

@Component(
        immediate = true
        , property = {
                "service.exported.interfaces=*",
                "service.exported.configs=org.apache.cxf.rs",
                "org.apache.cxf.rs.address=/room-service"
        }
        , service = GestionInfrastructuresREST.class               
)
public class GestionInfrastructuresRESTImpl implements GestionInfrastructuresREST {

    @Reference private LogService logger;
    @Reference private GestionInfrastructuresService service;        // my backend service
   
    ...

  
    @Override
    public Response getAllRooms() {
        List<GestionInfrastructuresRoomModel> allRooms = service.getAllRooms();    // call to the backend service

        ... // process the result from the backend service

       return Response.ok(json, MediaType.APPLICATION_JSON).build();    // if result is OK

        ...  // do some error processing and return some error .... e.g.      
        return Response.serverError().build();
    }

}


Mat frëndleche Gréiss,
Mit freundlichen Grüßen,
Meilleures salutations,
Kind regards,

Alex Weirig
Responsable Technique
Ville de Luxembourg
Service Enseignement
Centre Technolink

Tel <a href="tel:+35247966127">+352 4796 - 6127
Fax +352 42 88 81
Email [hidden email]
www.vdl.lu // www.technolink.lu

Centre Technolink
2, rue Charles de Tornaco 
L-2623 LUXEMBOURG

On 28/05/2018 23:01, Christian Schneider wrote:
Aries JAX-RS should work. It is not yet released though. So currently there is only a snapshot. A release should follow soon.

Another option is to use CXF-DOSGi. You can find an example below. It is similar to Aries JAX-RS so a later switch should be easy.


Christian

2018-05-28 19:40 GMT+02:00 Guenther Schmidt <[hidden email]>:
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





--
--
Christian Schneider

http://www.liquid-reality.de

Computer Scientist

-- 
This email was Anti Virus checked by SOPHOS UTM


alex_weirig.vcf (348 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Alex Weirig

BTW: these should be the features I installed in karaf ...

feature:repo-add cxf-dosgi
feature:install cxf-dosgi-provider-rs


Mat frëndleche Gréiss,
Mit freundlichen Grüßen,
Meilleures salutations,
Kind regards,

Alex Weirig
Responsable Technique
Ville de Luxembourg
Service Enseignement
Centre Technolink

Tel <a href="tel:+35247966127">+352 4796 - 6127
Fax +352 42 88 81
Email [hidden email]
www.vdl.lu // www.technolink.lu

Centre Technolink
2, rue Charles de Tornaco 
L-2623 LUXEMBOURG

On 29/05/2018 08:36, Alex Weirig wrote:

I'm using the approach Christian is referring to and I can confirm that it's really easy and convenient.

I'm creating DS services to expose selected backend services with a REST API

@Component(
        immediate = true
        , property = {
                "service.exported.interfaces=*",
                "service.exported.configs=org.apache.cxf.rs",
                "org.apache.cxf.rs.address=/room-service"
        }
        , service = GestionInfrastructuresREST.class               
)
public class GestionInfrastructuresRESTImpl implements GestionInfrastructuresREST {

    @Reference private LogService logger;
    @Reference private GestionInfrastructuresService service;        // my backend service
   
    ...

  
    @Override
    public Response getAllRooms() {
        List<GestionInfrastructuresRoomModel> allRooms = service.getAllRooms();    // call to the backend service

        ... // process the result from the backend service

       return Response.ok(json, MediaType.APPLICATION_JSON).build();    // if result is OK

        ...  // do some error processing and return some error .... e.g.      
        return Response.serverError().build();
    }

}


Mat frëndleche Gréiss,
Mit freundlichen Grüßen,
Meilleures salutations,
Kind regards,

Alex Weirig
Responsable Technique
Ville de Luxembourg
Service Enseignement
Centre Technolink

Tel <a href="tel:+35247966127" moz-do-not-send="true">+352 4796 - 6127
Fax +352 42 88 81
Email [hidden email]
www.vdl.lu // www.technolink.lu

Centre Technolink
2, rue Charles de Tornaco 
L-2623 LUXEMBOURG

On 28/05/2018 23:01, Christian Schneider wrote:
Aries JAX-RS should work. It is not yet released though. So currently there is only a snapshot. A release should follow soon.

Another option is to use CXF-DOSGi. You can find an example below. It is similar to Aries JAX-RS so a later switch should be easy.


Christian

2018-05-28 19:40 GMT+02:00 Guenther Schmidt <[hidden email]>:
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





--
--
Christian Schneider

http://www.liquid-reality.de

Computer Scientist

-- 
This email was Anti Virus checked by SOPHOS UTM



alex_weirig.vcf (348 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Steinar Bang
In reply to this post by Guenther Schmidt
>>>>> Guenther Schmidt <[hidden email]>:

> 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?

Take a look at these two:

 https://github.com/steinarb/post-body-capture
   A super-simple REST service/debug tool that just writes the POSTed
   body to a file, and the file name to the injected OSGi log service (I
   used it to see what sonarcloud was sending to its webhooks)

 https://github.com/steinarb/sonar-collector
  A REST service intended to be used as a postbuild SonarCloud/SonarQube
  webhook.  The service will store key numbers from the build in a
  PostgreSQL database.
  Nifty things here are using liquibase to initialize the PostgreSQL
  database and injecting config in the @Activate method, allowing the
  JDBC connection info to be configured from the karaf console.

Build and install information can be found in the README files.

Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Scott Lewis
In reply to this post by Guenther Schmidt
On 5/28/2018 10:40 AM, 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
>
>
Hi Guenther,

Another option would be ECF Remote Services [1].   It's a full
implementation of the OSGi Remote Services and Remote Service Admin
(R7/latest) specifications [2].   These specifications standardize the
remoting of OSGi services (meta-data and dynamics), so it works
seemlessly with DS and other frameworks that use the OSGi service registry.

ECF has a provider architecture so allows the use of a variety of
distribution providers [3], including CXF [4].

We have features defined for Karaf [5] and we also now have support for
bndtools-based development [6] (workspace and project templates).

Caveat:   ECF is in the middle of 'release season' for the Eclipse
simultaneous release (late June), so the transition to ECF 3.14.0 is not
yet complete.  For example, the Karaf features don't yet point to 3.14.0
at maven central only because we have to wait for the SR  process before
deployment of the release to maven central.   However, I'm happy to
provide needed support via [7].

Scott

[1] https://wiki.eclipse.org/Eclipse_Communication_Framework_Project

[2]
https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteserviceadmin.html

[3] https://wiki.eclipse.org/Distribution_Providers

[4] https://github.com/ECF/JaxRSProviders

[5] https://wiki.eclipse.org/EIG:Install_into_Apache_Karaf

[6]
https://wiki.eclipse.org/Bndtools_Support_for_Remote_Services_Development

[7] https://accounts.eclipse.org/mailing-list/ecf-dev

[8] http://eclipseecf.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Tim Ward-2
Almost certainly the simplest option has already been suggested. The OSGi JAX-RS whiteboard provides a simple, standard mechanism for registering JAX-RS applications, resources, and extensions using the OSGi service registry. The Aries JAX-RS whiteboard is the Reference Implementation of this spec, and is in the process of being released (it should be available within the next three weeks). Using the JAX-RS whiteboard gives you more control over your resources, gives you access to more of the JAX-RS specification, and is more portable than using RSA.

There’s a simple set of tutorials using the R7 specifications provided by OSGi enRoute:


The quickstart application should provide you with everything you need.

Best Regards,

Tim

On 29 May 2018, at 17:03, Scott Lewis <[hidden email]> wrote:

On 5/28/2018 10:40 AM, 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


Hi Guenther,

Another option would be ECF Remote Services [1].   It's a full implementation of the OSGi Remote Services and Remote Service Admin (R7/latest) specifications [2].   These specifications standardize the remoting of OSGi services (meta-data and dynamics), so it works seemlessly with DS and other frameworks that use the OSGi service registry.

ECF has a provider architecture so allows the use of a variety of distribution providers [3], including CXF [4].

We have features defined for Karaf [5] and we also now have support for bndtools-based development [6] (workspace and project templates).

Caveat:   ECF is in the middle of 'release season' for the Eclipse simultaneous release (late June), so the transition to ECF 3.14.0 is not yet complete.  For example, the Karaf features don't yet point to 3.14.0 at maven central only because we have to wait for the SR  process before deployment of the release to maven central.   However, I'm happy to provide needed support via [7].

Scott

[1] https://wiki.eclipse.org/Eclipse_Communication_Framework_Project

[2] https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteserviceadmin.html

[3] https://wiki.eclipse.org/Distribution_Providers

[4] https://github.com/ECF/JaxRSProviders

[5] https://wiki.eclipse.org/EIG:Install_into_Apache_Karaf

[6] https://wiki.eclipse.org/Bndtools_Support_for_Remote_Services_Development

[7] https://accounts.eclipse.org/mailing-list/ecf-dev

[8] http://eclipseecf.blogspot.com/


Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Scott Lewis
On 5/30/2018 2:17 AM, Tim Ward wrote:
Almost certainly the simplest option has already been suggested. The OSGi JAX-RS whiteboard provides a simple, standard mechanism for registering JAX-RS applications, resources, and extensions using the OSGi service registry. The Aries JAX-RS whiteboard is the Reference Implementation of this spec, and is in the process of being released (it should be available within the next three weeks). Using the JAX-RS whiteboard gives you more control over your resources, gives you access to more of the JAX-RS specification, and is more portable than using RSA.

It's debatable to say that the JAX-RS whiteboard spec is more portable than using RSA.   Portability can mean multiple things...e.g. across impls (e.g. CXF or Jersey), or service contracts across transports (http vs. mqtt).   Further, RSA does have things that JAXRS currently lacks...e.g. proxys, mgmt agent, topology mgr, discovery/edef. 

But I don't wish to debate.   I'll just point to an example running on Karaf that uses Jersey, CXF, JAX-RS, OSGi R7 RSA:  https://wiki.eclipse.org/Tutorial:_JaxRS_Remote_Services_on_Karaf

Scott


There’s a simple set of tutorials using the R7 specifications provided by OSGi enRoute:


The quickstart application should provide you with everything you need.

Best Regards,

Tim

On 29 May 2018, at 17:03, Scott Lewis <[hidden email]> wrote:

On 5/28/2018 10:40 AM, 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


Hi Guenther,

Another option would be ECF Remote Services [1].   It's a full implementation of the OSGi Remote Services and Remote Service Admin (R7/latest) specifications [2].   These specifications standardize the remoting of OSGi services (meta-data and dynamics), so it works seemlessly with DS and other frameworks that use the OSGi service registry.

ECF has a provider architecture so allows the use of a variety of distribution providers [3], including CXF [4].

We have features defined for Karaf [5] and we also now have support for bndtools-based development [6] (workspace and project templates).

Caveat:   ECF is in the middle of 'release season' for the Eclipse simultaneous release (late June), so the transition to ECF 3.14.0 is not yet complete.  For example, the Karaf features don't yet point to 3.14.0 at maven central only because we have to wait for the SR  process before deployment of the release to maven central.   However, I'm happy to provide needed support via [7].

Scott

[1] https://wiki.eclipse.org/Eclipse_Communication_Framework_Project

[2] https://osgi.org/specification/osgi.cmpn/7.0.0/service.remoteserviceadmin.html

[3] https://wiki.eclipse.org/Distribution_Providers

[4] https://github.com/ECF/JaxRSProviders

[5] https://wiki.eclipse.org/EIG:Install_into_Apache_Karaf

[6] https://wiki.eclipse.org/Bndtools_Support_for_Remote_Services_Development

[7] https://accounts.eclipse.org/mailing-list/ecf-dev

[8] http://eclipseecf.blogspot.com/



Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

atouat
In reply to this post by jbonofre
Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
    <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
        <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
    </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Tim Ward-2
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre
In reply to this post by atouat
Hi,

My example works for the http whiteboard, but not Aries JAXRS
whiteboard. For JAXRS, I provided example based on CXF.

If CXF is not convenient for you, I can add a Aries JAXRS Whiteboard
example, no problem.

If your case, 404 means that the "listener servlet" has not been
deployed or not on the alias you expect.

Did you check what you have with http:list command ?

Regards
JB


On 05/09/2018 16:18, atouat wrote:

> Hello to everybody,
>
> I wanted to try out using Aries JAXRS Whiteboard, since there is released
> version now.
>
> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
> to install Aries Jaxrs Whiteboard.
>
> The feature.xml looks like this:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
> name="aries-jaxrs-whiteboard">
>      <feature name="aries-jaxrs-whiteboard"
> description="aries-jaxrs-whiteboard" version="1.0.0">
>          <feature>http-whiteboard</feature>
>
> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>
> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>
> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>          <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>
> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
>      </feature>
> </features>
>
> I have now all bundles active.
>
> I tried the code example from @jbonofre (the giothub link returns an HTTP
> 404 error). My bundle was deplyoed and active, but I could not access my
> rest service.
>
> I tried to url http://loclahost:8181/myName but there was no response at
> all.
>
> What am I missing? Can someone provide a working example with Aris JAXRS
> Whiteboard please?
>
>
> Greetings,
>
> Adnan
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre
In reply to this post by Tim Ward-2

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Tim Ward-2
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html



Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre

OK, it's what I knew ;)

So, basically, you answer helped the user generally speaking but I guess it's not exactly what the user expects.

Karaf has exactly the same target for the runtime space. Karaf Boot is more on the same space as enRoute.

I would be more than happy to help to support Karaf in enRoute, but it seems that Karaf doesn't have a lot of supporters "at" enRoute. I got comment from some enRoute guys saying that Karaf doesn't make sense and other blabla. That's why I didn't find the motivation to help ;)

Anyway, back on the user request, @Adnan I will add an example using Aries JAXRS in Karaf.

Thanks,
Regards


On 05/09/2018 16:41, Tim Ward wrote:
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html




Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Tim Ward-2


On 5 Sep 2018, at 15:54, Jean-Baptiste Onofré <[hidden email]> wrote:

OK, it's what I knew ;)

So, basically, you answer helped the user generally speaking but I guess it's not exactly what the user expects.


I was attempting to answer the question:

Can someone provide a working example with Aris JAXRS
Whiteboard please?

Other than the Aries JAX-RS whiteboard integration tests (which aren’t a gentle introduction!) enRoute has the only working examples I’m currently aware of. This is why I flagged it.

Karaf has exactly the same target for the runtime space. Karaf Boot is more on the same space as enRoute.

I would be more than happy to help to support Karaf in enRoute, but it seems that Karaf doesn't have a lot of supporters "at" enRoute. I got comment from some enRoute guys saying that Karaf doesn't make sense and other blabla. That's why I didn't find the motivation to help ;)

Anyway, back on the user request, @Adnan I will add an example using Aries JAXRS in Karaf.

Thanks,
Regards


On 05/09/2018 16:41, Tim Ward wrote:
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html





Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre
In reply to this post by Tim Ward-2

By the way, Karaf is "not just Maven after all" ;) It's a little more than that ;) (actually largely more than that ;)).


On 05/09/2018 16:41, Tim Ward wrote:
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html




Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

Tim Ward-2
I wasn’t referring to Karaf, I was referring to the enRoute build output!

Tim

On 5 Sep 2018, at 16:00, Jean-Baptiste Onofré <[hidden email]> wrote:

By the way, Karaf is "not just Maven after all" ;) It's a little more than that ;) (actually largely more than that ;)).


On 05/09/2018 16:41, Tim Ward wrote:
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html





Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

jbonofre

Got it ;)

AFAIR, Christian started a PoC about a Karaf resolver. I will resume what he started.

Regards
JB


On 05/09/2018 17:01, Tim Ward wrote:
I wasn’t referring to Karaf, I was referring to the enRoute build output!

Tim

On 5 Sep 2018, at 16:00, Jean-Baptiste Onofré <[hidden email]> wrote:

By the way, Karaf is "not just Maven after all" ;) It's a little more than that ;) (actually largely more than that ;)).


On 05/09/2018 16:41, Tim Ward wrote:
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <[hidden email]> wrote:

Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/

Best Regards,

Tim

On 5 Sep 2018, at 15:18, atouat <[hidden email]> wrote:

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
   <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
       <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
       <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
   </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html






Reply | Threaded
Open this post in threaded view
|

Re: REST - Declarative Services

atouat
In reply to this post by jbonofre
Hi @all,

Wow! Very active community here in the forum. I appreciate this, thanks.

@jbonofre In a current project at work, we already have rest services
running in karaf by using cxf and blueprint.
I also tried out @cschneider's propositon wiht cxf-dosgi and I got that
running too.

I just wanted to try out publishing rest services via whiteboard, and since
aries jax rs whiteboard is the reference implementation I took that.

About your example. My code looks like this:

/import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;


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

    @Activate
    public void onActivate(){
        System.out.println("ExampleRest activating!");
    }

    @GET
    @Path("/{name}")
    public String sayHello(@PathParam("name") String name) {
        return "Hello " + name;
    }

}/

The generated service.component.xml under OSGI-INF looks like this:

/<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
name="de.rest.test.ExampleRest" immediate="true" activate="onActivate">
  <implementation class="de.rest.test.ExampleRest"/>
  <service>
    <provide interface="de.rest.test.ExampleRest"/>
  </service>
  <property name="osgi.jaxrs.application.select" type="String"
value="(osgi.jaxrs.name=.default)"/>
  <property name="osgi.jaxrs.resource" type="String" value="true"/>
</scr:component>/


And the generated Manifest like this:

/Manifest-Version: 1.0
Bnd-LastModified: 1536171585428
Build-Jdk: 1.8.0_171
Built-By: adnan
Bundle-Description: de.rest.test.whiteboard.ds OSGi bundle project.
Bundle-ManifestVersion: 2
Bundle-Name: de.rest.test.whiteboard.ds Bundle
Bundle-SymbolicName: de.rest.test.whiteboard.ds
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: de.rest.test;version="1.0.0.SNAPSHOT";uses:="javax.ws.
 rs"
Import-Package: javax.ws.rs;version="[2.1,3)"
Provide-Capability: osgi.service;objectClass:List<String>="de.rest.tes
 t.ExampleRest"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
 nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.ee;filter:="(&(osgi.e
 e=JavaSE)(version=1.8))"
Service-Component: OSGI-INF/de.rest.test.ExampleRest.xml
Tool: Bnd-3.5.0.201709291849/

I also already had a look at the osgienroute example @Tim-Ward-2 mentioned.
I created the rest bundle based on the osgi enroute maven archetype. The
code looks very similar (The following is the code generated by the enroute
archetype):

/import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;

@Component(service=RestComponentImpl.class)
@JaxrsResource
public class RestComponentImpl {
   
    //TODO add an implementation
   
    @Path("rest")
    @GET
    public String toUpper() {
        return "Hello World!";
    }
}
/

I couldnt get a well generetaed manifest by the bnd-tool, so I used the
maven-bundle.-plugin and the generetd service.component.xml and the genrated
Manifest look similar too.


After installing the feature as mentioned in my previous post and deploying
the bundle with you corde examples @jbonofre
 (bundle symbolic name is de.rest.test.whiteboard.ds Bundle)  and also the
enroute exmaple bunlde (bundly symbolic name is rest-enroute), I have the
following in karaf:

/
karaf@root()> list                                                                                                                                      
START LEVEL 100 , List Threshold: 50
 ID │ State  │ Lvl │ Version            │ Name
────┼────────┼─────┼────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 23 │ Active │  80 │ 4.2.1              │ Apache Karaf :: OSGi Services ::
Event
 45 │ Active │  80 │ 0.0.0              │ aries-jaxrs-whiteboard.xml
 49 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Specification
API
 50 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Whiteboard
 52 │ Active │  80 │ 1.1.2              │ Apache Felix Servlet API
 59 │ Active │  80 │ 1.3.0.1            │ Apache ServiceMix :: Specs ::
Annotation API 1.3
 60 │ Active │  80 │ 4.6.0              │ Apache XBean OSGI Bundle Utilities
 61 │ Active │  80 │ 4.6.0              │ Apache XBean :: Classpath Resource
Finder
 89 │ Active │  80 │ 6.2.0              │ org.objectweb.asm
 90 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.commons
 91 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.tree
 98 │ Active │  80 │ 1.1.0.201802012106 │
org.osgi:org.osgi.service.http.whiteboard
 99 │ Active │  80 │ 1.0.0.201802012106 │ org.osgi:org.osgi.service.jaxrs
100 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.function
101 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.promise
102 │ Active │  80 │ 1.0.0.SNAPSHOT     │ de.rest.test.whiteboard.ds Bundle
103 │ Active │  80 │ 1.0.0.SNAPSHOT     │ rest-enroute
karaf@root()> /


With the command karaf@root()> service:list , I get (excerpt) :

/karaf@root()> service:list                                                                                              
[de.rest.test.ExampleRest]
--------------------------
 component.id = 2
 component.name = de.rest.test.ExampleRest
 osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
 osgi.jaxrs.resource = true
 service.bundleid = 102
 service.id = 123
 service.scope = bundle
Provided by :
 de.rest.test.whiteboard.ds Bundle (102)

[val.rest.enroute.RestComponentImpl]
------------------------------------
 component.id = 3
 component.name = val.rest.enroute.RestComponentImpl
 service.bundleid = 103
 service.id = 124
 service.scope = bundle
Provided by :
 rest-enroute (103)/

With the command karaf@root()> http:list , I get :

/karaf@root()> http:list
ID │ Servlet │ Servlet-Name │ State │ Alias │ Url
───┼─────────┼──────────────┼───────┼───────┼────
karaf@root()>  /

Yes, nothing. So no servlet or something in that regard is registered. It
can not work, right?

When I install the feature cxf-jaxrs I get this:

/karaf@root(feature)> http:list
ID  │ Servlet             │ Servlet-Name               │ State       │ Alias
│ Url
────┼─────────────────────┼────────────────────────────┼─────────────┼───────┼─────────
114 │ CXFNonSpringServlet │ cxf-osgi-transport-servlet │ Deployed    │ /cxf
│ [/cxf/*]
karaf@root(feature)/


I assume I am missing something obvious and substantial. Can someone point
me to what I am missing?

Thanks in advance!


Greetings,

Adnan






--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
12