In WAR file I add 2 different JAR that has JAX-RS resources. I add a ResourceConfig subclass to register all resources from this 2 JAR. But in these two JAR one resource has the same name. Is it possible to change the pathname from the register method in ResourceConfig class, or any other way in which I can change the path of the resource and give it to another name?
I can not create multiple @ApplicaionPath.
In JAR 1:
@Path("product")
public class ProductApi(){
......
}
In JAR 2:
@Path("product")
public class ProductApi(){
......
}
In WAR
@ApplicationPath("api")
public class MainAPi extends ResourceConfig {
packages(jar1.apis);
packages(jar2.apis);
}
So the conflict is with ProductApi
. Only one is in effect because it shares the same path /api/product
So how to route from MainApi
to the different ProductApi
?
or is any other way around to change it without modifying JARs?
I found a reference from https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e10848
Resource jar1ProductApi = Resource.builder(Jar1.ProductApi.class).path("newpath/product").build();
registerResources(jar1ProductApi);
I add this to main ResourceConfig File and now onwards it calls via new URL route(newpath/product)