THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||
---|---|---|---|---|
| ||||
// get the jetty server form the destination EndpointInfo ei = new EndpointInfo(); ei.setAddress(serviceFactory.getAddress()); Destination destination = df.getDestination(ei); JettyHTTPDestination jettyDestination = (JettyHTTPDestination) destination; ServerEngine engine = jettyDestination.getEngine(); Handler handler = engine.getServant(new URL(serviceFactory.getAddress())); org.mortbay.jetty.Server server = handler.getServer(); // The Server // add the resource handler to server We have to create a HandlerList structure that includes both a ResourceHandler for the static // content as well as the ContextHandlerCollection Handlercreated serverHandlerby =CXF server.getHandler();(which we retrieve as serverHandler). ContextHandlerCollectionHandler contextHandlerCollectionserverHandler = server.getHandler(ContextHandlerCollection)serverHandler; HandlerList handlerList = new HandlerList(); ResourceHandler resourceHandler = new ResourceHandler(); handlerList.addHandler(resourceHandler); handlerList.addHandler(contextHandlerCollectionserverHandler); // replace the CXF servlet connect collection with the list. server.setHandler(handlerList); // and tell the handler list that it is alive. handlerList.start(); // setsetup the resource handler File staticContentFile = new File(staticContentPath); // ordinary pathname. URL targetURL = new URL("file://" + staticContentFile.getCanonicalPath()); FileResource fileResource = new FileResource(targetURL); resourceHandler.setBaseResource(fileResource); |