Hi,
When running Jetty embedded version 9.1, I could add JAX-WS support for a running server as in the following example:
public class JettyJaxWs {
public static void main(String[] args) throws Exception {
Server server = new Server(7777);
ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
server.setHandler(contextHandlerCollection);
server.start();
// later ...
HttpContext context = build(server, "/ws");
MyWebService ws = new MyWebService();
Endpoint endpoint = Endpoint.create(ws);
endpoint.publish(context);
// access wsdl on http://localhost:7777/ws/MyWebService?wsdl
}
@WebService
public static class MyWebService {
public String hello(String s) {
return "hi " + s;
}
}
// following the code of
JettyHttpServerProvider
public static HttpContext build(Server server, String contextString) throws Exception {
JettyHttpServer jettyHttpServer = new JettyHttpServer(server, true);
return jettyHttpServer.createContext(contextString);
}
}
Since about 9.2, the internal "HttpSpiContextHandler" object is not automatically started, so I'm doing this (and is working):
public static HttpContext build(Server server, String contextString) throws Exception {
JettyHttpServer jettyHttpServer = new JettyHttpServer(server, true);
JettyHttpContext ctx = (JettyHttpContext) jettyHttpServer.createContext(contextString);
Method method = JettyHttpContext.class.getDeclaredMethod("getJettyContextHandler");
method.setAccessible(true);
HttpSpiContextHandler contextHandler = (HttpSpiContextHandler) method.invoke(ctx);
contextHandler.start();
return ctx;
}
Seems to me that the JettyHttpContext should declare its start() method public in order to avoid the reflection. Or there is another way?
Regards,