Re: REST - Declarative Services

2018-09-06 Thread Jean-Baptiste Onofré
Hi,

As said, let me finish the Decanter 2.1.0 release and I will add a full
example.

Thanks !
Regards
JB

On 06/09/2018 11:54, atouat wrote:
> Good morning @jbonofre,thanks for your reply. I tried it, but unfortunately I
> got the same results.Here are the generated service.xmls:*1)
> RestApiApp*/  /*2)
> Api*//I can see the
> two services starting ( the sysouts are displayed int he karaf console).But
> the http:list and the cxf:list-endpoints command show an empty
> list.(Precisely, the http:list command shows only the CXFServletID  |
> Servlet | Servlet-Name   | State   | Alias |
> Url+-++-+---+-113
> | CXFNonSpringServlet | cxf-osgi-transport-servlet | Deployed| /cxf  |
> [/cxf/*])Calling the url http://localhost:8181/rest/object/getObject result
> in a 404 Not found@nicolas.brasey also calling the url 
> http://localhost:8181/cxf/rest/object/getObject result in a 404 Not foundI
> don't know what is missng :(Greetings, Adnan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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


Re: REST - Declarative Services

2018-09-06 Thread Francois Papon
Hi,

There is an issue on the Apache Aries JAX-RS Whiteboard component, may
be it's related to your problem :

https://issues.apache.org/jira/browse/ARIES-1825

regards,

François Papon
fpa...@apache.org

Le 06/09/2018 à 14:09, atouat a écrit :
> Hi @Tim-Ward-2,
>
> thatns for your input. I cleaned my karaf and just installed my feature xml.
> Aöll Bunldes are active.
>
> 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
>
> This is what I found about the JaxrsServiceRuntime:
>
>
> karaf@root()> service:list JaxrsServiceRuntime
> [org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime]
> 
>  service.bundleid = 50
>  service.id = 115
>  service.pid = org.apache.aries.jax.rs.whiteboard.default
>  service.ranking = -2147483648
>  service.scope = singleton
> Provided by :
>  Apache Aries JAX-RS Whiteboard (50)
>
>
> The JaxrsServiceRuntime is rgeistered as a service, so far so good. But I
> dont's see a osgi.jaxrs.endpoint  service property. 
>
> @jbonofre do you have an idea what is missing within the karaf context?
>
> Greetings,
>
>
> Adnan
>
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html



Re: REST - Declarative Services

2018-09-06 Thread atouat
Hi @Tim-Ward-2,

thatns for your input. I cleaned my karaf and just installed my feature xml.
Aöll Bunldes are active.

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

This is what I found about the JaxrsServiceRuntime:


karaf@root()> service:list JaxrsServiceRuntime
[org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime]

 service.bundleid = 50
 service.id = 115
 service.pid = org.apache.aries.jax.rs.whiteboard.default
 service.ranking = -2147483648
 service.scope = singleton
Provided by :
 Apache Aries JAX-RS Whiteboard (50)


The JaxrsServiceRuntime is rgeistered as a service, so far so good. But I
dont's see a osgi.jaxrs.endpoint  service property. 

@jbonofre do you have an idea what is missing within the karaf context?

Greetings,


Adnan






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


Re: REST - Declarative Services

2018-09-06 Thread atouat
Good morning @jbonofre,thanks for your reply. I tried it, but unfortunately I
got the same results.Here are the generated service.xmls:*1)
RestApiApp*/  /*2)
Api*//I can see the
two services starting ( the sysouts are displayed int he karaf console).But
the http:list and the cxf:list-endpoints command show an empty
list.(Precisely, the http:list command shows only the CXFServletID  |
Servlet | Servlet-Name   | State   | Alias |
Url+-++-+---+-113
| CXFNonSpringServlet | cxf-osgi-transport-servlet | Deployed| /cxf  |
[/cxf/*])Calling the url http://localhost:8181/rest/object/getObject result
in a 404 Not found@nicolas.brasey also calling the url 
http://localhost:8181/cxf/rest/object/getObject result in a 404 Not foundI
don't know what is missng :(Greetings, Adnan



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


Re: REST - Declarative Services

2018-09-06 Thread Jean-Baptiste Onofré
I will add a full example to test this.

Thanks for your feedback.

Regards
JB

On 06/09/2018 10:49, Tim Ward wrote:
> Hi,
> 
> So there have been a number of suggestions on this thread which are
> unnecessary, and will confuse matters.
> 
>  1. There is no need to provide a JAX-RS Application to use the JAX-RS
> whiteboard. The whiteboard always has a default application which
> is, unsurprisingly, what is used by default.
>  2. The “osgi.jaxrs.endpoint” property is a service property of the
> JaxrsServiceRuntime service. You can use it to work out what URI the
> JAX-RS whiteboard is available on. It does absolutely nothing when
> used as a property on your resource
>  3. The JAX_RS_APPLICATION_SELECT filter is not needed if you just want
> to use the default application to host your resource.
> 
> 
> If you trim out the extra bits that have been added you should be back
> to a simple JAX-RS resource service that has the property
> “osgi.jaxrs.resource=true”. If you update to bnd 4.0 (the maven bundle
> plugin release was at the end of last week), then you can use the
> @JaxrsResource annotation to do this, otherwise you will need to keep
> using the String property name.
> 
> Verifying that the Aries JAX-RS whiteboard is working should be pretty
> simple. Once you have the bundle installed and running it will use the
> Http Whiteboard to register a Servlet. Once this is activated the
> whiteboard will register a JaxrsServiceRuntime service. If you look at
> the osgi.jaxrs.endpoint property of the JaxrsServiceRuntime service it
> will give you one or more URIs that you can use to reach the whiteboard.
> If you use a browser to connect to this URI you should get a welcome page.
> 
>   * If you don’t see a JaxrsServiceRuntime service then this indicates
> that the whiteboard servlet it uses hasn’t been picked up. This
> would be a problem with the Karaf web container.
>   * If the URI presented as a service property of the
> JaxrsServiceRuntime service does not give you a welcome page then it
> indicates that Karaf is doing some level of context root setting.
> You will need to query the Karaf Http Whiteboard to work out what it
> might have done
> 
> 
> Once you’ve validated that part it should be a case of
> installing/starting the bundle containing your resource, and navigating
> to it using the URI from before, plus the path of your resource method.
> 
> I hope this helps,
> 
> Best Regards,
> 
> Tim
> 
>> On 6 Sep 2018, at 06:56, Nicolas Brasey > > wrote:
>>
>> Hi,
>>
>> Are you sure you are not missing the "cxf" prefix in the URL to access
>> your endpoint? By default, cxf deploys your endpoint with the
>> CXFNonSpringServlet, which listens on the cxf context path, so your
>> endpoint should be available here:
>>
>> http://localhost:8181/cxf/hello 
>>
>> my 2 cents...
>>
>> Nicolas
>>
>>
>>
>>
>>
>> On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré > > wrote:
>>
>> Hi,
>>
>> did you try to add a application with your context.
>>
>> Something like:
>>
>> @Component(
>>                 service = Application.class,
>>                 property= {
>>                                 "osgi.jaxrs.name
>> =RestApp",
>>                                 JAX_RS_APPLICATION_BASE +
>> "=/rest",     
>>                                 "authentication.with=keycloak"
>>                 }
>>         )
>> public class RestApiApp extends Application{
>>
>>         @Override
>>   public Set getSingletons() {
>>       return Collections.singleton(this);
>>   }
>> }
>>
>> The resource can refer this application:
>>
>> @Component(
>>         service = Api.class,
>>         property = {
>>                         "osgi.jaxrs.name
>> =RestApi",
>>                         "osgi.jaxrs.resource=true",
>>                        
>> "osgi.jaxrs.application.select=(osgi.jaxrs.name
>> =RestApp)"
>>         }
>> )
>> @Path("/object")
>> public final class Api {
>>         public static final Response EMPTY_RESPONSE =
>> Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
>>         @GET
>>         @Path("/getObject")
>>         @Produces(MediaType.APPLICATION_JSON)
>>         public String getObject() {
>>             //return some json
>>         }
>> }
>>
>> Regards
>> JB
>>
>> On 05/09/2018 22:38, atouat wrote:
>> > Hi Francois,
>> >
>> > I treid that too. See this excerpt:
>> >
>> > karaf@root()> service:list | grep -C 10 rest
>> > [de.rest.test.ExampleRest]
>> > --
>> >  component.id  = 4
>> >  component.name  = 

Re: REST - Declarative Services

2018-09-06 Thread Tim Ward
Hi,

So there have been a number of suggestions on this thread which are 
unnecessary, and will confuse matters.

There is no need to provide a JAX-RS Application to use the JAX-RS whiteboard. 
The whiteboard always has a default application which is, unsurprisingly, what 
is used by default.
The “osgi.jaxrs.endpoint” property is a service property of the 
JaxrsServiceRuntime service. You can use it to work out what URI the JAX-RS 
whiteboard is available on. It does absolutely nothing when used as a property 
on your resource
The JAX_RS_APPLICATION_SELECT filter is not needed if you just want to use the 
default application to host your resource.

If you trim out the extra bits that have been added you should be back to a 
simple JAX-RS resource service that has the property 
“osgi.jaxrs.resource=true”. If you update to bnd 4.0 (the maven bundle plugin 
release was at the end of last week), then you can use the @JaxrsResource 
annotation to do this, otherwise you will need to keep using the String 
property name.

Verifying that the Aries JAX-RS whiteboard is working should be pretty simple. 
Once you have the bundle installed and running it will use the Http Whiteboard 
to register a Servlet. Once this is activated the whiteboard will register a 
JaxrsServiceRuntime service. If you look at the osgi.jaxrs.endpoint property of 
the JaxrsServiceRuntime service it will give you one or more URIs that you can 
use to reach the whiteboard. If you use a browser to connect to this URI you 
should get a welcome page.

If you don’t see a JaxrsServiceRuntime service then this indicates that the 
whiteboard servlet it uses hasn’t been picked up. This would be a problem with 
the Karaf web container.
If the URI presented as a service property of the JaxrsServiceRuntime service 
does not give you a welcome page then it indicates that Karaf is doing some 
level of context root setting. You will need to query the Karaf Http Whiteboard 
to work out what it might have done

Once you’ve validated that part it should be a case of installing/starting the 
bundle containing your resource, and navigating to it using the URI from 
before, plus the path of your resource method.

I hope this helps,

Best Regards,

Tim

> On 6 Sep 2018, at 06:56, Nicolas Brasey  wrote:
> 
> Hi,
> 
> Are you sure you are not missing the "cxf" prefix in the URL to access your 
> endpoint? By default, cxf deploys your endpoint with the CXFNonSpringServlet, 
> which listens on the cxf context path, so your endpoint should be available 
> here:
> 
> http://localhost:8181/cxf/hello 
> 
> my 2 cents...
> 
> Nicolas
> 
> 
> 
> 
> 
> On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré  > wrote:
> Hi,
> 
> did you try to add a application with your context.
> 
> Something like:
> 
> @Component(
> service = Application.class,
> property= {
> "osgi.jaxrs.name 
> =RestApp",
> JAX_RS_APPLICATION_BASE + "=/rest", 
> "authentication.with=keycloak"
> }
> )
> public class RestApiApp extends Application{
> 
> @Override
>   public Set getSingletons() {
>   return Collections.singleton(this);
>   }
> }
> 
> The resource can refer this application:
> 
> @Component(
> service = Api.class,
> property = {
> "osgi.jaxrs.name =RestApi",
> "osgi.jaxrs.resource=true",
> "osgi.jaxrs.application.select=(osgi.jaxrs.name 
> =RestApp)"
> }
> )
> @Path("/object")
> public final class Api {
> public static final Response EMPTY_RESPONSE =
> Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
> @GET
> @Path("/getObject")
> @Produces(MediaType.APPLICATION_JSON)
> public String getObject() {
> //return some json
> }
> }
> 
> Regards
> JB
> 
> On 05/09/2018 22:38, atouat wrote:
> > Hi Francois,
> > 
> > I treid that too. See this excerpt:
> > 
> > karaf@root()> service:list | grep -C 10 rest
> > [de.rest.test.ExampleRest]
> > --
> >  component.id  = 4
> >  component.name  = de.rest.test.ExampleRest
> >  osgi.jaxrs.application.select = (osgi.jaxrs.name 
> > =.default)
> > * osgi.jaxrs.endpoint = /hello* 
> > osgi.jaxrs.resource = true
> >  service.bundleid = 102
> >  service.id  = 139
> >  service.scope = bundle
> > Provided by : 
> >  de.rest.test.whiteboard.ds Bundle (102)
> > 
> > 
> > But when calling http://localhost:8181/hello , 
> > I get a 404 not found error.
> > 
> > 
> > Thansk for your input :)
> > 
> > 
> > Greetings,
> > 
> > Adnan
> > 
> > 
> > 
> > --
> > Sent from: 

Re: REST - Declarative Services

2018-09-05 Thread Nicolas Brasey
Hi,

Are you sure you are not missing the "cxf" prefix in the URL to access your
endpoint? By default, cxf deploys your endpoint with the
CXFNonSpringServlet, which listens on the cxf context path, so your
endpoint should be available here:

http://localhost:8181/cxf/hello 

my 2 cents...

Nicolas





On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré  wrote:

> Hi,
>
> did you try to add a application with your context.
>
> Something like:
>
> @Component(
> service = Application.class,
> property= {
> "osgi.jaxrs.name=RestApp",
> JAX_RS_APPLICATION_BASE + "=/rest",
> "authentication.with=keycloak"
> }
> )
> public class RestApiApp extends Application{
>
> @Override
>   public Set getSingletons() {
>   return Collections.singleton(this);
>   }
> }
>
> The resource can refer this application:
>
> @Component(
> service = Api.class,
> property = {
> "osgi.jaxrs.name=RestApi",
> "osgi.jaxrs.resource=true",
> "osgi.jaxrs.application.select=(osgi.jaxrs.name
> =RestApp)"
> }
> )
> @Path("/object")
> public final class Api {
> public static final Response EMPTY_RESPONSE =
> Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
> @GET
> @Path("/getObject")
> @Produces(MediaType.APPLICATION_JSON)
> public String getObject() {
> //return some json
> }
> }
>
> Regards
> JB
>
> On 05/09/2018 22:38, atouat wrote:
> > Hi Francois,
> >
> > I treid that too. See this excerpt:
> >
> > karaf@root()> service:list | grep -C 10 rest
> > [de.rest.test.ExampleRest]
> > --
> >  component.id = 4
> >  component.name = de.rest.test.ExampleRest
> >  osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
> > * osgi.jaxrs.endpoint = /hello*
> > osgi.jaxrs.resource = true
> >  service.bundleid = 102
> >  service.id = 139
> >  service.scope = bundle
> > Provided by :
> >  de.rest.test.whiteboard.ds Bundle (102)
> >
> >
> > But when calling http://localhost:8181/hello, I get a 404 not found
> error.
> >
> >
> > Thansk for your input :)
> >
> >
> > Greetings,
> >
> > Adnan
> >
> >
> >
> > --
> > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> >
>
> --
> Jean-Baptiste Onofré
> jbono...@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>


Re: REST - Declarative Services

2018-09-05 Thread Jean-Baptiste Onofré
Hi,

did you try to add a application with your context.

Something like:

@Component(
service = Application.class,
property= {
"osgi.jaxrs.name=RestApp",
JAX_RS_APPLICATION_BASE + "=/rest", 
"authentication.with=keycloak"
}
)
public class RestApiApp extends Application{

@Override
  public Set getSingletons() {
  return Collections.singleton(this);
  }
}

The resource can refer this application:

@Component(
service = Api.class,
property = {
"osgi.jaxrs.name=RestApi",
"osgi.jaxrs.resource=true",

"osgi.jaxrs.application.select=(osgi.jaxrs.name=RestApp)"
}
)
@Path("/object")
public final class Api {
public static final Response EMPTY_RESPONSE =
Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
@GET
@Path("/getObject")
@Produces(MediaType.APPLICATION_JSON)
public String getObject() {
//return some json
}
}

Regards
JB

On 05/09/2018 22:38, atouat wrote:
> Hi Francois,
> 
> I treid that too. See this excerpt:
> 
> karaf@root()> service:list | grep -C 10 rest
> [de.rest.test.ExampleRest]
> --
>  component.id = 4
>  component.name = de.rest.test.ExampleRest
>  osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
> * osgi.jaxrs.endpoint = /hello* 
> osgi.jaxrs.resource = true
>  service.bundleid = 102
>  service.id = 139
>  service.scope = bundle
> Provided by : 
>  de.rest.test.whiteboard.ds Bundle (102)
> 
> 
> But when calling http://localhost:8181/hello, I get a 404 not found error.
> 
> 
> Thansk for your input :)
> 
> 
> Greetings,
> 
> Adnan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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


Re: REST - Declarative Services

2018-09-05 Thread atouat
Hi Francois,

I treid that too. See this excerpt:

karaf@root()> service:list | grep -C 10 rest
[de.rest.test.ExampleRest]
--
 component.id = 4
 component.name = de.rest.test.ExampleRest
 osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
* osgi.jaxrs.endpoint = /hello* 
osgi.jaxrs.resource = true
 service.bundleid = 102
 service.id = 139
 service.scope = bundle
Provided by : 
 de.rest.test.whiteboard.ds Bundle (102)


But when calling http://localhost:8181/hello, I get a 404 not found error.


Thansk for your input :)


Greetings,

Adnan



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


Re: REST - Declarative Services

2018-09-05 Thread Francois Papon
Hi,

May be you are missing the JAX_RS_SERVICE_ENDPOINT, there is a
description in the specification :

https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT

regards,

François Papon
fpa...@apache.org

Le 05/09/2018 à 22:47, atouat a écrit :
> 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:
>
> /
> http://www.osgi.org/xmlns/scr/v1.3.0;
> name="de.rest.test.ExampleRest" immediate="true" activate="onActivate">
>   
>   
> 
>   
>value="(osgi.jaxrs.name=.default)"/>
>   
> /
>
>
> 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="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 

Re: REST - Declarative Services

2018-09-05 Thread atouat
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:

/
http://www.osgi.org/xmlns/scr/v1.3.0;
name="de.rest.test.ExampleRest" immediate="true" activate="onActivate">
  
  

  
  
  
/


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="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 │ 

Re: REST - Declarative Services

2018-09-05 Thread Jean-Baptiste Onofré

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é > 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é > 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 > 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:


http://karaf.apache.org/xmlns/features/v1.4.0;
name="aries-jaxrs-whiteboard">
   
   http-whiteboard

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

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

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

mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 


   


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














Re: REST - Declarative Services

2018-09-05 Thread Tim Ward
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é  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é >> > 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  > 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:
> 
> 
> http://karaf.apache.org/xmlns/features/v1.4.0 
> "
> name="aries-jaxrs-whiteboard">
> description="aries-jaxrs-whiteboard" version="1.0.0">
>http-whiteboard
> 
> mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0
> 
> mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2
> 
> mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1
>
> mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0
>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0
>mvn:org.osgi/org.osgi.util.function/1.1.0
>mvn:org.osgi/org.osgi.util.promise/1.1.0
> 
> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
>  
> 
>
> 
> 
> 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 
> 
 
>>> 
>> 
> 



Re: REST - Declarative Services

2018-09-05 Thread Tim Ward


> On 5 Sep 2018, at 15:54, Jean-Baptiste Onofré  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é >> > 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  > 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:
> 
> 
> http://karaf.apache.org/xmlns/features/v1.4.0 
> "
> name="aries-jaxrs-whiteboard">
> description="aries-jaxrs-whiteboard" version="1.0.0">
>http-whiteboard
> 
> mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0
> 
> mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2
> 
> mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1
>
> mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0
>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0
>mvn:org.osgi/org.osgi.util.function/1.1.0
>mvn:org.osgi/org.osgi.util.promise/1.1.0
> 
> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
>  
> 
>
> 
> 
> 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 
> 
 
>>> 
>> 
> 



Re: REST - Declarative Services

2018-09-05 Thread Jean-Baptiste Onofré

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é > 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 > 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:


http://karaf.apache.org/xmlns/features/v1.4.0;
name="aries-jaxrs-whiteboard">
   
   http-whiteboard

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

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

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

mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 


   


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










Re: REST - Declarative Services

2018-09-05 Thread Tim Ward
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é  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 >> > 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:
>>> 
>>> 
>>> http://karaf.apache.org/xmlns/features/v1.4.0 
>>> "
>>> name="aries-jaxrs-whiteboard">
>>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>http-whiteboard
>>> 
>>> mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0
>>> 
>>> mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2
>>> 
>>> mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1
>>>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0
>>>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0
>>>mvn:org.osgi/org.osgi.util.function/1.1.0
>>>mvn:org.osgi/org.osgi.util.promise/1.1.0
>>> 
>>> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
>>>  
>>> 
>>>
>>> 
>>> 
>>> 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 
>>> 
>> 
> 



Re: REST - Declarative Services

2018-09-05 Thread Jean-Baptiste Onofré

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


http://karaf.apache.org/xmlns/features/v1.4.0;
name="aries-jaxrs-whiteboard">
   
   http-whiteboard

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

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

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

mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 


   


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






Re: REST - Declarative Services

2018-09-05 Thread Jean-Baptiste Onofré

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:


http://karaf.apache.org/xmlns/features/v1.4.0;
name="aries-jaxrs-whiteboard">
 
 http-whiteboard

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

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

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

mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
 


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




Re: REST - Declarative Services

2018-09-05 Thread Tim Ward
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  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:
> 
> 
> http://karaf.apache.org/xmlns/features/v1.4.0;
> name="aries-jaxrs-whiteboard">
> description="aries-jaxrs-whiteboard" version="1.0.0">
>http-whiteboard
> 
> mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0
> 
> mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2
> 
> mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1
>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0
>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0
>mvn:org.osgi/org.osgi.util.function/1.1.0
>mvn:org.osgi/org.osgi.util.promise/1.1.0
> 
> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0
>
> 
> 
> 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



Re: REST - Declarative Services

2018-09-05 Thread atouat
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:


http://karaf.apache.org/xmlns/features/v1.4.0;
name="aries-jaxrs-whiteboard">

http-whiteboard

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

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

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

mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0



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


Re: REST - Declarative Services

2018-07-02 Thread 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:


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

The quickstart application should provide you with everything you need.

Best Regards,

Tim

On 29 May 2018, at 17:03, Scott Lewis > 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/







Re: REST - Declarative Services

2018-05-30 Thread Tim Ward
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:

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

The quickstart application should provide you with everything you need.

Best Regards,

Tim

> On 29 May 2018, at 17:03, Scott Lewis  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/
> 



Re: REST - Declarative Services

2018-05-29 Thread Scott Lewis

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/



Re: REST - Declarative Services

2018-05-29 Thread Steinar Bang
> Guenther Schmidt :

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



Re: REST - Declarative Services

2018-05-29 Thread 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* +352 4796 - 6127  *Fax* +352 42 88 81 
*Email* alex.wei...@technolink.lu  
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 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* +352 4796 - 6127  *Fax* +352 42 88 
81 *Email* alex.wei...@technolink.lu 
 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.


https://github.com/apache/cxf-dosgi/tree/master/samples/rest

Christian

2018-05-28 19:40 GMT+02:00 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





--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

--
This email was Anti Virus checked by SOPHOS UTM




<>

Re: REST - Declarative Services

2018-05-29 Thread 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 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* +352 4796 - 6127  *Fax* +352 42 88 81 
*Email* alex.wei...@technolink.lu  
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.


https://github.com/apache/cxf-dosgi/tree/master/samples/rest

Christian

2018-05-28 19:40 GMT+02:00 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





--
--
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com

--
This email was Anti Virus checked by SOPHOS UTM


<>

Re: REST - Declarative Services

2018-05-28 Thread Christian Schneider
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.

https://github.com/apache/cxf-dosgi/tree/master/samples/rest

Christian

2018-05-28 19:40 GMT+02:00 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
>
>
>


-- 
-- 
Christian Schneider
http://www.liquid-reality.de

Computer Scientist
http://www.adobe.com


Re: REST - Declarative Services

2018-05-28 Thread Jean-Baptiste Onofré
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