@Override public HttpService addingService(ServiceReference<HttpService> reference) { HttpService httpService = context.getService(reference); Servlet servlet = new CXFNonSpringServlet(destinationRegistry, false); servletExporter = new ServletExporter(servlet, httpService); servletPublisherReg = context.registerService(ManagedService.class, servletExporter, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, CXF_CONFIG_PID)); return httpService; } }
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); initialized = true; }
@Override public void init(ServletConfig sc) throws ServletException { super.init(sc); if (this.bus == null && loadBus) { loadBus(sc); } if (this.bus != null) { loader = initClassLoader(); registerServletContextResolver(sc); if (destinationRegistry == null) { this.destinationRegistry = getDestinationRegistryFromBusOrDefault(sc.getInitParameter(TRANSPORT_ID)); } } this.controller = createServletController(sc); finalizeServletInit(sc); }
public HttpServlet buildServlet() { CXFNonSpringServlet cxf = new CXFNonSpringServlet(); cxf.setBus(bus); return cxf; }
@Override public void init(ServletConfig sc) throws ServletException { super.init(sc); if (this.bus == null && loadBus) { loadBus(sc); } if (this.bus != null) { loader = initClassLoader(); registerServletContextResolver(sc); if (destinationRegistry == null) { this.destinationRegistry = getDestinationRegistryFromBus(this.bus); } } this.controller = createServletController(sc); finalizeServletInit(sc); }
public CxfPlugin(@Config(defaultValue = "/ws/*", doc = "Path where the CXF plugin will be deployed") String mountPoint, @Config(defaultValue = "BOTH") String schemaValidation, Collection<EndpointCustomizer> endpointCustomizers, Collection<ServiceCustomizer> serviceCustomizers, ServletBuilder servletBuilder) throws ServletException { this.schemaValidation = schemaValidation; this.endpointCustomizers = endpointCustomizers; Bus bus = BusFactory.newInstance().createBus(); ServiceContractResolverRegistry reg = new ServiceContractResolverRegistryImpl(bus); reg.register(new RespiroServiceContractResolver()); CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet(); cxfNonSpringServlet.setBus(bus); cxfNonSpringServlet.init(servletBuilder.servletConfig("cxf", new Properties())); cxfFilter = servletBuilder.servlet(cxfNonSpringServlet, mountPoint); endpointBuilder = new DefaultEndpointBuilder(); serviceBuilder = new DefaultServiceBuilder(serviceCustomizers); endpointDeployer = endpointConfigs -> CxfPlugin.this.deployEndpoints(endpointConfigs); }
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); }
@Override public void loadBus(ServletConfig servletConfig) { super.loadBus(servletConfig); BusFactory.setDefaultBus(getBus()); server = new SOAPServer(this); try { server.start(); } catch (Exception ex) { Logger.getLogger(AstennServlet.class.getName()).log(Level.SEVERE, null, ex); } }// END Method loadBus
@Override @Inject public void setBus(final Bus bus) { super.setBus(bus); }
public void destroy() { if (!globalRegistry) { for (String path : destinationRegistry.getDestinationsPaths()) { // clean up the destination in case the destination itself can // no longer access the registry later AbstractHTTPDestination dest = destinationRegistry.getDestinationForPath(path); synchronized (dest) { destinationRegistry.removeDestination(path); dest.releaseRegistry(); } } destinationRegistry = null; } destroyBus(); super.destroy(); }
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); } } }
@Override protected void loadBus(ServletConfig sc) { super.loadBus(sc); boolean cdiPresent = "true".equalsIgnoreCase(getInitParameter(CDI_INIT_PARAM)); final CXFWebservicePublisher publisher = new CXFWebservicePublisher(); endpoints.stream().forEach(e -> publisher.publish(e, bus, cdiPresent)); publisher.close(); }
@Override @Inject public void setBus(final Bus bus) { super.setBus(bus); }
public void destroy() { if (!globalRegistry) { for (String path : destinationRegistry.getDestinationsPaths()) { // clean up the destination in case the destination itself can // no longer access the registry later AbstractHTTPDestination dest = destinationRegistry.getDestinationForPath(path); synchronized (dest) { destinationRegistry.removeDestination(path); dest.releaseRegistry(); } } destinationRegistry = null; } destroyBus(); }
@Override public void init(ServletConfig sc) throws ServletException { super.init(sc); if (this.bus == null && loadBus) { loadBus(sc); } if (this.bus != null) { loader = initClassLoader(); registerServletContextResolver(sc); if (destinationRegistry == null) { this.destinationRegistry = getDestinationRegistryFromBusOrDefault(sc.getInitParameter(TRANSPORT_ID)); } } this.controller = createServletController(sc); finalizeServletInit(sc); }
@Override public HttpService addingService(ServiceReference<HttpService> reference) { HttpService httpService = context.getService(reference); Servlet servlet = new CXFNonSpringServlet(destinationRegistry, false); servletExporter = new ServletExporter(servlet, httpService); servletPublisherReg = context.registerService(ManagedService.class, servletExporter, CollectionUtils.singletonDictionary(Constants.SERVICE_PID, CXF_CONFIG_PID)); return httpService; } }
public void init() throws ServletException { super.init(); final JaxWsAnnotationProcessorUtil wsInstance = JaxWsAnnotationProcessorUtil.getInstance(); this.endpoints = wsInstance.getEndpointList(); }
protected void loadBus(ServletConfig sc) { super.loadBus(sc); for (Class<?> klass : Scans.me().scanPackage(appContext.getPackage(), null)) { // 有@WebService和@IocBean注解的非接口类 WebService ws = klass.getAnnotation(WebService.class); if (ws == null || klass.isInterface()) continue; if (Strings.isBlank(ws.serviceName())) { log.infof("%s has @WebService but serviceName is blank, ignore", klass.getName()); continue; } log.debugf("add WebService addr=/%s type=%s", ws.serviceName(), klass.getName()); JaxWsServerFactoryBean sfb = new JaxWsServerFactoryBean(); sfb.setServiceBean(ioc.get(klass)); sfb.create(); } } }