public void start() throws Exception { // Setup the system properties to use the CXFBusFactory not the // SpringBusFactory String busFactory = System .getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, "org.apache.cxf.bus.CXFBusFactory"); // Start up the jetty embedded server Server httpServer = new Server(port); ContextHandlerCollection contexts = new ContextHandlerCollection(); httpServer.setHandler(contexts); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); httpServer.setHandler(context); CXFNonSpringServlet cxf = new CXFNonSpringServlet(); ServletHolder servlet = new ServletHolder(cxf); servlet.setName("soap"); servlet.setForcedPath("soap"); context.addServlet(servlet, "/*"); httpServer.start(); Bus bus = cxf.getBus(); // setBus(bus); BusFactory.setDefaultBus(bus); Object implementor = new MainService(idf, archFac); Endpoint ep = Endpoint.publish("/main", implementor); SOAPBinding soap = (SOAPBinding) ep.getBinding(); soap.setMTOMEnabled(false); }
protected void run() { String busFactory = System.getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, "org.apache.cxf.bus.CXFBusFactory"); try { CXFNonSpringServlet cxf = new CXFNonSpringServlet(); httpServer(cxf).start(); serverFactory(cxf.getBus()).create(); } catch (Exception e) { throw new RuntimeException(e); } finally { if (busFactory != null) { System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, busFactory); } else { System.clearProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME); } } }
void initializeServer(CXFNonSpringServlet cxf) { try { httpServer.start(); } catch (Exception e) { throw new RuntimeException(e); } Bus bus = cxf.getBus(); if (in != null) { bus.getInInterceptors().add(in); } if (out != null) { bus.getOutInterceptors().add(out); } BusFactory.setDefaultBus(bus); Endpoint.publish("/server", serviceInstance); }