org.apache.cxf.transport.servlet.CXFNonSpringServlet Java Examples

The following examples show how to use org.apache.cxf.transport.servlet.CXFNonSpringServlet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookCxfContinuationServlet3Server.java    From cxf with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example #2
Source File: Whiteboard.java    From aries-jax-rs-whiteboard with Apache License 2.0 5 votes vote down vote up
private static CXFNonSpringServlet createCXFServlet(Bus bus) {
    @SuppressWarnings("serial")
    CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet() {

        @Override
        public void destroyBus() {
        }

    };

    cxfNonSpringServlet.setBus(bus);

    return cxfNonSpringServlet;
}
 
Example #3
Source File: BookCxfContinuationServlet3Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Server httpServer(CXFNonSpringServlet cxf) {
    Server server = new Server(Integer.parseInt(PORT));
    ServletHandler handler = new ServletHandler();
    server.setHandler(handler);
    handler.addServletWithMapping(new ServletHolder(cxf), "/*");
    return server;
}
 
Example #4
Source File: HttpServiceTrackerCust.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #5
Source File: JAXWSEnvironment.java    From dropwizard-jaxws with Apache License 2.0 4 votes vote down vote up
public HttpServlet buildServlet() {
    CXFNonSpringServlet cxf = new CXFNonSpringServlet();
    cxf.setBus(bus);
    return cxf;
}
 
Example #6
Source File: JAXWSEnvironmentTest.java    From dropwizard-jaxws with Apache License 2.0 4 votes vote down vote up
@Test
public void buildServlet() {
    Object result = jaxwsEnvironment.buildServlet();
    assertThat(result, is(instanceOf(CXFNonSpringServlet.class)));
    assertThat(((CXFNonSpringServlet) result).getBus(), is(instanceOf(Bus.class)));
}
 
Example #7
Source File: JAXWSExporterWithHttpServiceTest.java    From fuchsia with Apache License 2.0 4 votes vote down vote up
@Test
public void worksInCaseHttpServiceWasInjected() throws BinderException, ServletException, NamespaceException {

    Map<String, Object> metadata = new HashMap<String, Object>();

    metadata.put(ID, "TestJAXWSDeclaration");
    metadata.put("fuchsia.export.cxf.class.name", ServiceForExportation.class.getName());
    metadata.put("fuchsia.export.cxf.url.context", "/" + ServiceForExportation.class.getSimpleName());

    ExportDeclaration declaration = spy(ExportDeclarationBuilder.fromMetadata(metadata).build());
    declaration.bind(serviceReferenceFromExporter);

    exporter.registration(serviceReferenceFromExporter);

    exporter.addDeclaration(declaration);

    verify(httpServiceMock, times(1)).registerServlet(eq(org.ow2.chameleon.fuchsia.exporter.jaxws.internal.Constants.CXF_SERVLET), any(CXFNonSpringServlet.class), any(Dictionary.class), any(org.osgi.service.http.HttpContext.class));

}