You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by ismail berrada <is...@yahoo.fr> on 2015/06/03 14:37:38 UTC

Registering REST web service without default path services

Hello,
I'm using Felix and I expose a REST web service using jersey framework
Everything works fine but every resources are accessible via the default path i.e. services.
Each time I ask for a resource I send the following HTTP request template 

curl -v -X GET "http://localhost:8080/services/path/to/resource"

Is there a way to change the default path ? I want to get my resources from URL like

http://localhost:8080/path/to/resource

Please note that my service is not a servlet and I also have several services!I tried to add properties to my service by adding a dictionnary object when registering the service
Here is an extract of my Activator class

[CODE]
@Override
public void start(BundleContext bundleContext) throws Exception {
   try {
    
    Dictionary<String,String> properties = new Hashtable<String, String>();
    properties.put("root","/");

    //....
    // Register web services
    webServiceRegistration = bundleContext.registerService(MyWebService.class, new MyWebService(), properties);
    
    //.....
    
    }
    catch(Exception ex){
    //handling ex
    }
}
[/CODE]

I can see in the web console that the service is registered and resources are still availaible with the unwanted URL

Regards


Re: Registering REST web service without default path services

Posted by ismail berrada <is...@yahoo.fr>.
I'm working with hstaudacher/osgi-jax-rs-connector and it also works fine but I did not found the way to change the context path using Felix


|   |
|   |  |   |   |   |   |   |
| hstaudacher/osgi-jax-rs-connectorosgi-jax-rs-connector - An OSGi - JAX-RS 2.0 Connector, software repository available on the link below |
|  |
| Afficher sur github.com | Aperçu par Yahoo |
|  |
|   |

   
 


     Le Mercredi 3 juin 2015 15h51, Paul Bakker <pa...@luminis.eu> a écrit :
   
 

 Mandatory, no; you can use another framework/your own implementation to work with JAX-RS in OSGi. It is a very convenient way however, but as an Amdatu developer I'm probably biased ;-) Take a look at the video and decide for yourself.

Cheers,
Paul
On Wed, Jun 3, 2015 at 3:47 PM ismail berrada <is...@yahoo.fr> wrote:

 Thanks Paul for your answer. So does it means that I have to use Amdatu component ?
Is it mandatory ? Is it the easiest way to do this  ?
Regards



 


     Le Mercredi 3 juin 2015 15h28, Paul Bakker <pa...@luminis.eu> a écrit :



 Hi Ismail,

You can configure the root path using the "wink.rest.path" property for PID
"org.amdatu.web.rest.wink".

I will create an issue to also document this on the website, it seems to be
missing.

Cheers,

Paul

On Wed, Jun 3, 2015 at 2:38 PM ismail berrada <is...@yahoo.fr> wrote:

> Hello,
> I'm using Felix and I expose a REST web service using jersey framework
> Everything works fine but every resources are accessible via the default
> path i.e. services.
> Each time I ask for a resource I send the following HTTP request template
>
> curl -v -X GET "http://localhost:8080/services/path/to/resource"
>
> Is there a way to change the default path ? I want to get my resources
> from URL like
>
> http://localhost:8080/path/to/resource
>
> Please note that my service is not a servlet and I also have several
> services!I tried to add properties to my service by adding a dictionnary
> object when registering the service
> Here is an extract of my Activator class
>
> [CODE]
> @Override
> public void start(BundleContext bundleContext) throws Exception {
>    try {
>
>    Dictionary<String,String> properties = new Hashtable<String, String>();
>    properties.put("root","/");
>
>    //....
>    // Register web services
>    webServiceRegistration =
> bundleContext.registerService(MyWebService.class, new MyWebService(),
> properties);
>
>    //.....
>
>    }
>    catch(Exception ex){
>    //handling ex
>    }
> }
> [/CODE]
>
> I can see in the web console that the service is registered and resources
> are still availaible with the unwanted URL
>
> Regards
>
>



  


 
  

Re: Registering REST web service without default path services

Posted by Paul Bakker <pa...@luminis.eu>.
Mandatory, no; you can use another framework/your own implementation to
work with JAX-RS in OSGi. It is a very convenient way however, but as an
Amdatu developer I'm probably biased ;-) Take a look at the video and
decide for yourself.

Cheers,

Paul

On Wed, Jun 3, 2015 at 3:47 PM ismail berrada <is...@yahoo.fr> wrote:

>  Thanks Paul for your answer. So does it means that I have to use Amdatu
> component ?
> Is it mandatory ? Is it the easiest way to do this  ?
> Regards
>
>
>
>
>
>
>      Le Mercredi 3 juin 2015 15h28, Paul Bakker <pa...@luminis.eu>
> a écrit :
>
>
>
>  Hi Ismail,
>
> You can configure the root path using the "wink.rest.path" property for PID
> "org.amdatu.web.rest.wink".
>
> I will create an issue to also document this on the website, it seems to be
> missing.
>
> Cheers,
>
> Paul
>
> On Wed, Jun 3, 2015 at 2:38 PM ismail berrada <is...@yahoo.fr>
> wrote:
>
> > Hello,
> > I'm using Felix and I expose a REST web service using jersey framework
> > Everything works fine but every resources are accessible via the default
> > path i.e. services.
> > Each time I ask for a resource I send the following HTTP request template
> >
> > curl -v -X GET "http://localhost:8080/services/path/to/resource"
> >
> > Is there a way to change the default path ? I want to get my resources
> > from URL like
> >
> > http://localhost:8080/path/to/resource
> >
> > Please note that my service is not a servlet and I also have several
> > services!I tried to add properties to my service by adding a dictionnary
> > object when registering the service
> > Here is an extract of my Activator class
> >
> > [CODE]
> > @Override
> > public void start(BundleContext bundleContext) throws Exception {
> >    try {
> >
> >    Dictionary<String,String> properties = new Hashtable<String,
> String>();
> >    properties.put("root","/");
> >
> >    //....
> >    // Register web services
> >    webServiceRegistration =
> > bundleContext.registerService(MyWebService.class, new MyWebService(),
> > properties);
> >
> >    //.....
> >
> >    }
> >    catch(Exception ex){
> >    //handling ex
> >    }
> > }
> > [/CODE]
> >
> > I can see in the web console that the service is registered and resources
> > are still availaible with the unwanted URL
> >
> > Regards
> >
> >
>
>
>
>

Re: Registering REST web service without default path services

Posted by ismail berrada <is...@yahoo.fr>.
 Thanks Paul for your answer. So does it means that I have to use Amdatu component ? 
Is it mandatory ? Is it the easiest way to do this  ?
Regards



  


     Le Mercredi 3 juin 2015 15h28, Paul Bakker <pa...@luminis.eu> a écrit :
   
 

 Hi Ismail,

You can configure the root path using the "wink.rest.path" property for PID
"org.amdatu.web.rest.wink".

I will create an issue to also document this on the website, it seems to be
missing.

Cheers,

Paul

On Wed, Jun 3, 2015 at 2:38 PM ismail berrada <is...@yahoo.fr> wrote:

> Hello,
> I'm using Felix and I expose a REST web service using jersey framework
> Everything works fine but every resources are accessible via the default
> path i.e. services.
> Each time I ask for a resource I send the following HTTP request template
>
> curl -v -X GET "http://localhost:8080/services/path/to/resource"
>
> Is there a way to change the default path ? I want to get my resources
> from URL like
>
> http://localhost:8080/path/to/resource
>
> Please note that my service is not a servlet and I also have several
> services!I tried to add properties to my service by adding a dictionnary
> object when registering the service
> Here is an extract of my Activator class
>
> [CODE]
> @Override
> public void start(BundleContext bundleContext) throws Exception {
>    try {
>
>    Dictionary<String,String> properties = new Hashtable<String, String>();
>    properties.put("root","/");
>
>    //....
>    // Register web services
>    webServiceRegistration =
> bundleContext.registerService(MyWebService.class, new MyWebService(),
> properties);
>
>    //.....
>
>    }
>    catch(Exception ex){
>    //handling ex
>    }
> }
> [/CODE]
>
> I can see in the web console that the service is registered and resources
> are still availaible with the unwanted URL
>
> Regards
>
>


 
  

Re: Registering REST web service without default path services

Posted by Paul Bakker <pa...@luminis.eu>.
Hi Ismail,

You can configure the root path using the "wink.rest.path" property for PID
"org.amdatu.web.rest.wink".

I will create an issue to also document this on the website, it seems to be
missing.

Cheers,

Paul

On Wed, Jun 3, 2015 at 2:38 PM ismail berrada <is...@yahoo.fr> wrote:

> Hello,
> I'm using Felix and I expose a REST web service using jersey framework
> Everything works fine but every resources are accessible via the default
> path i.e. services.
> Each time I ask for a resource I send the following HTTP request template
>
> curl -v -X GET "http://localhost:8080/services/path/to/resource"
>
> Is there a way to change the default path ? I want to get my resources
> from URL like
>
> http://localhost:8080/path/to/resource
>
> Please note that my service is not a servlet and I also have several
> services!I tried to add properties to my service by adding a dictionnary
> object when registering the service
> Here is an extract of my Activator class
>
> [CODE]
> @Override
> public void start(BundleContext bundleContext) throws Exception {
>    try {
>
>     Dictionary<String,String> properties = new Hashtable<String, String>();
>     properties.put("root","/");
>
>     //....
>     // Register web services
>     webServiceRegistration =
> bundleContext.registerService(MyWebService.class, new MyWebService(),
> properties);
>
>     //.....
>
>     }
>     catch(Exception ex){
>     //handling ex
>     }
> }
> [/CODE]
>
> I can see in the web console that the service is registered and resources
> are still availaible with the unwanted URL
>
> Regards
>
>

Re: Registering REST web service without default path services

Posted by Paul Bakker <pa...@luminis.eu>.
Hi Ismail,

I just realise my answer is bogus. I thought your question was about Amdatu
Web (which also uses JAX-RS), but you're asking about Jersey.

Amdatu Web does make it easier to work with JAX-RS in OSGi, so you might
want to take a look at that anyway: http://amdatu.org/components/web.html

Cheers,

Paul



On Wed, Jun 3, 2015 at 2:38 PM ismail berrada <is...@yahoo.fr> wrote:

> Hello,
> I'm using Felix and I expose a REST web service using jersey framework
> Everything works fine but every resources are accessible via the default
> path i.e. services.
> Each time I ask for a resource I send the following HTTP request template
>
> curl -v -X GET "http://localhost:8080/services/path/to/resource"
>
> Is there a way to change the default path ? I want to get my resources
> from URL like
>
> http://localhost:8080/path/to/resource
>
> Please note that my service is not a servlet and I also have several
> services!I tried to add properties to my service by adding a dictionnary
> object when registering the service
> Here is an extract of my Activator class
>
> [CODE]
> @Override
> public void start(BundleContext bundleContext) throws Exception {
>    try {
>
>     Dictionary<String,String> properties = new Hashtable<String, String>();
>     properties.put("root","/");
>
>     //....
>     // Register web services
>     webServiceRegistration =
> bundleContext.registerService(MyWebService.class, new MyWebService(),
> properties);
>
>     //.....
>
>     }
>     catch(Exception ex){
>     //handling ex
>     }
> }
> [/CODE]
>
> I can see in the web console that the service is registered and resources
> are still availaible with the unwanted URL
>
> Regards
>
>