Well I finally figured this out through lots and lots of trial and error of
internal classes. If anyone else comes across this issue via search engine,
here is the working solution that I came up with:
public static void serveStaticAndRS() throws Exception {
System.out.println("Starting JAX-RS server...");
JAXRSServiceFactoryBean svcFactory = new
JAXRSServiceFactoryBean();
JAXRSServerFactoryBean sf = new
JAXRSServerFactoryBean(svcFactory);
sf.setResourceClasses(CustomerService.class);
sf.setAddress("http://localhost:9001/");
org.apache.cxf.endpoint.Server cxfServer = sf.create();
Destination dest = cxfServer.getDestination();
JettyHTTPDestination jettyDestination =
JettyHTTPDestination.class.cast(dest);
ServerEngine engine = jettyDestination.getEngine();
JettyHTTPServerEngine serverEngine =
JettyHTTPServerEngine.class.cast(engine);
org.eclipse.jetty.server.Server httpServer =
serverEngine.getServer();
// Had to start the server to get the Jetty Server instance.
// Have to stop it to add the custom Jetty handler.
httpServer.stop();
httpServer.join();
Handler[] existingHandlers = httpServer.getHandlers();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[] {"index.html"});
resource_handler.setResourceBase(".");
HandlerList handlers = new HandlerList();
handlers.addHandler(resourceHandler);
if (existingHandlers != null) {
for (Handler h : existingHandlers) {
handlers.addHandler(h);
}
}
httpServer.setHandler(handlers);
httpServer.start();
System.out.println("Started...");
httpServer.join();
}
--
View this message in context:
http://cxf.547215.n5.nabble.com/Host-CXF-REST-Service-Static-Web-Content-on-Same-Embedded-Server-tp3232898p3236410.html
Sent from the cxf-user mailing list archive at Nabble.com.