Sometimes when working with JAX-WS services it is nice to be able to test the service without having to deploy to a heavyweight server. You can do this using the Endpoint.publish method and just pass in an instance of your server class.
There is something similar in Jersey, but it isn't part of the JAX-RS specification. So you can publish a single resource as follows:
package client;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.jersey.api.core.ClassNamesResourceConfig;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
public class Test {
public static void main(String[] args) throws IOException {
HttpServer create = HttpServerFactory.create(
"http://localhost:9001/",new ClassNamesResourceConfig(Hello.class));
create.start();
}
}

No comments:
Post a Comment