I'm creating an embedded server using JBoss RestEasy's embedded TJWS. The limited documentation is inaccurate, but I was able to create a server instance with a test JAX-RS resource:
@Path("test")
public class TestResource {
public static void main(String[] args) throws Exception {
TJWSEmbeddedJaxrsServer tjws = new TJWSEmbeddedJaxrsServer();
tjws.setPort(8080);
tjws.start();
tjws.getDeployment().getRegistry().addPerRequestResource(TestResource.class);
}
...
That allows me to browse to http://localhost:8080/test
to test the GET
method implementation (not shown here).
But how do I specify that the embedded server should be mounted at some other base path? For example, how do I get the test resource mounted to http://localhost:8080/example/test
? Sure, I could hard code this into the @Path
designation, but the base path shouldn't be part of the resource---I should be able to redeploy this resource class in a J2EE server at any base path.
I'm guessing there is something like a tjws.getDeployment().setBasePath("example")
that I haven't found, yet. (If anybody has some in-depth documentation for this please let me know as well!) Thanks in advance.
So far I've found that I can simulate this by specifying a prefix when adding resources to the server:
That's not quite the same as I was looking for, but it does allow me to access the resource as
http://localhost:8080/example/test
without being forced to indicate this base path in the resource definition.