Comments (7)
Hi,
Yes it is possible to replace the /1 with some other string. The reason it is 1 is because it needs to be unique for each service instance, and the remote service id (1 in typical case) does that.
It's not enough to use the pathPrefix only, however to do so...as typically this will result in /pathprefix/1.
This can be easily addressed as well, but before refreshing my own memory about how to do this let me leave it at that and see if this is necessary.
Thanks,
Scott
from jaxrsproviders.
Thanks for the quick response.
Well, I've been trying to figure it out for a while.
I've tried to configure the service context path through DS Component annotation and ended up with something like this:
@Component(property = { "service.exported.interfaces=*", "service.intents=jaxrs",
"service.exported.configs=ecf.jaxrs.jersey.server", "ecf.jaxrs.jersey.server.uri=/test",
"ecf.jaxrs.jersey.server.exported.interfaces=MyInterface" })
But it stil gives me http://localhost:8080/1/test
(or http://localhost:8080/test/1
if I go with ecf.jaxrs.jersey.server.pathPrefix
instead of ecf.jaxrs.jersey.server.uri
as you mentioned).
So help would be very helpful if it's not too much trouble for you.
from jaxrsproviders.
Hi Airaketa
I will respond more fully later this evening. It currently requires extending a class and I'll explain that later but I'm considering adding properties based customization in next release version.
from jaxrsproviders.
Hi Airaketa. I haven't forgotten about this, I just had something come up. I've decided to do two things:
-
I have an example that I'm completing of how to create a new remote service provider...based upon the jersey provider, that shows how to override the use of the remote service id (i.e. /1) in the path. This will work with the current version of JaxRSProvider release.
-
Add to the JaxRSProvider to allow folks like yourself to customize the use/or not of remote service id via service or system properties (e.g. like the pathPrefix). I want to think about this a little bit though, so that it has to be done only once with sufficient generality.
from jaxrsproviders.
Hi Airakea. WRT 1 in my message above:
I've added a new example project here:
This project is an extension of the jersey server remote services provider allows you or others to customize the URL creation at runtime. There are two classes: Activator and ExtJerseyServerContainer. The activator has code that allows a new provider to be made available with config id: ecf.jaxrs.jersey.server.ext. You can use this provider in the student service example (StudentServiceImpl class) by adding a service property: service.exported.configs=ecf.jaxrs.jersey.server.ext
The ExtJerseyServerContainer class is where the url path prefix can be customized. This is by implementing this method (overrides superclass method that is responsible for the '/{serviceId}' ...e.g. '/1' in the url path:
As you can see, to get an empty string (rather than /1) just return "". Or you can specify any prefix you want via the pathPrefix service property, which will be then available at runtime in the ExtJerseyServerContainer.servletPathPrefix variable.
I intend to create my own example usage of this extended jersey provider, but first I want to complete 2. With 2 in place, it won't be necessary to create an extended provider as per 1 at all, but rather it will be possible to set a servletPathPrefix and have that be used instead of /1. I wanted to create the 1 example anyway, however, because it does allow other more-specialized customization of the provider behavior, which some may wish to do as well.
from jaxrsproviders.
Hi Scott,
Thank you so much for your help in solving this issue. I will try to implement this for my own service.
Adding the new service property would also be very useful. So I will definitely be watching and waiting for a new version to come out.
from jaxrsproviders.
Hi Airaketa.
I've just released version 1.10.0 of the JaxRSProviders.
I made a number of subtle changes to assist in implementing your use case.
First, I added a new system/service property for both/all JaxRSProviders called includeRemoteServiceId which defaults to 'false'...meaning that the /1 will be default not be added to the remote service URL as it was in the past. If the includeRemoteServiceId is set to true, howeveer, the /1 will be added as suffix as it was previously. See the page describing the includeRemoteServiceId as well as other system/service properties:
https://github.com/ECF/JaxRSProviders/wiki/JaxRS-Distribution-Provider-Configuration-Properties
As before, the pathPrefix system/service property allows an explicit path prefix to be set for the remote service servlet. This Karaf tutorial shows how this works:
https://wiki.eclipse.org/Tutorial:_JaxRS_Remote_Services_on_Karaf
I think this will be more understandable, but it does have the consequence that if the same pathPrefix is used for two service instances the second will fail. In that case it might be helpful to set includeRemoteServiceId to true.
I'm going to close this issue. Please reopen if these changes and the example distribution provider described above are not sufficient for dealing with your use cases.
from jaxrsproviders.
Related Issues (20)
- new isssue HOT 3
- Could we make these features available on Eclipse update site? HOT 2
- Clean up metadata for features HOT 1
- Adding needed plug-ins to features HOT 1
- Remove example plugins from features HOT 1
- Update feature dependencies for Jersey JAX-RS Client feature HOT 3
- Custom ObjectMapper not used because of Jackson priority value HOT 6
- Cannot get asynchronous JAX-RS calls working as expected HOT 8
- Create simpler and more flexible endpoint descriptions HOT 21
- Provide JAX-RS and Jersey defaults so they don't have to be duplicated in EDEF files HOT 20
- Clean clone of repo will not build HOT 9
- cxf repository should be absolute HOT 1
- warning when com.mycorp.examples.student.client is executed in karaf HOT 1
- Consume Jersey and all dependencies using Maven repositories HOT 6
- Blank default uuid causes issues with multiple bundles providing services HOT 2
- Issues when starting RCP Client via Webstart HOT 16
- Possible racecondition on Service creation and injection? HOT 27
- Wrong Character enconding on % in parameter HOT 3
- Problem running the example com.mycorp.examples.student.remoteservice.host HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jaxrsproviders.