org.apache.cxf.bus.CXFBusFactory Java Examples

The following examples show how to use org.apache.cxf.bus.CXFBusFactory. 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: WebClientSubstitution.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Substitute
static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    // configLocation is always null and no need to create SpringBusFactory.
    CXFBusFactory bf = new CXFBusFactory();

    // It can not load the extensions from the bus-extensions.txt dynamically.
    // So have to set all of necessary ones here.
    List<Extension> extensions = new ArrayList<>();
    Extension http = new Extension();
    http.setClassname(HTTPTransportFactory.class.getName());
    http.setDeferred(true);
    extensions.add(http);
    ExtensionRegistry.addExtensions(extensions);

    Bus bus = bf.createBus();
    bus.setExtension(new PhaseManagerImpl(), PhaseManager.class);
    bus.setExtension(new ClientLifeCycleManagerImpl(), ClientLifeCycleManager.class);
    bus.setExtension(new ConduitInitiatorManagerImpl(bus), ConduitInitiatorManager.class);

    bean.setBus(bus);
    bean.setAddress(baseAddress);
    return bean;
}
 
Example #2
Source File: BusExtensionLoadingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the ExtensionManagerBus can be built using a given classloader
 *
 * @throws Exception
 */
@Test
public void testBusConstructionWithoutTCCL() throws Exception {
    ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(new TestClassLoader());
        BusFactory factory = new CXFBusFactory() {
            public Bus createBus(Map<Class<?>, Object> e, Map<String, Object> properties) {
                return new ExtensionManagerBus(e, properties, this.getClass().getClassLoader());
            }
        };
        Bus bus = factory.createBus();
        assertNotNullExtensions(bus);
        bus.shutdown(true);
    } finally {
        Thread.currentThread().setContextClassLoader(origClassLoader);
    }
}
 
Example #3
Source File: JaxwsClientToCxfServerIT.java    From tracee with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Before
public void setup() {
	final Bus bus = CXFBusFactory.getThreadDefaultBus();

	JaxWsServerFactoryBean jaxWsServer = createJaxWsServer();
	jaxWsServer.getFeatures().add(new LoggingFeature());
	jaxWsServer.getFeatures().add(new TraceeCxfFeature(serverBackend, Profile.DEFAULT));
	server = jaxWsServer.create();

	JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();

	factoryBean.setServiceClass(HelloWorldTestService.class);
	factoryBean.setAddress(endpointAddress);
	factoryBean.getHandlers().add(new TraceeClientHandler(clientBackend));
	factoryBean.setBus(bus);

	helloWorldPort = factoryBean.create(HelloWorldTestService.class);
}
 
Example #4
Source File: JaxwsClientToJaxwsServerIT.java    From tracee with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Before
public void setup() {

	JaxWsServerFactoryBean jaxWsServer = createJaxWsServer();
	jaxWsServer.getHandlers().add(new TraceeServerHandler(serverBackend, new SoapHeaderTransport()));
	server = jaxWsServer.create();

	JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();

	factoryBean.setServiceClass(HelloWorldTestService.class);
	factoryBean.setAddress(endpointAddress);
	factoryBean.getHandlers().add(new TraceeClientHandler(clientBackend));
	factoryBean.setBus(CXFBusFactory.getDefaultBus());

	helloWorldPort = factoryBean.create(HelloWorldTestService.class);
}
 
Example #5
Source File: QueryControlClient.java    From fosstrak-epcis with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setUpBus() {
    Bus bus = CXFBusFactory.getDefaultBus();
    ClientOnlyHTTPTransportFactory httpTransport = new ClientOnlyHTTPTransportFactory();
    // httpTransport = new ServletTransportFactory();
    httpTransport.setBus(bus);
    List<String> transportIds = Arrays.asList(new String[] {
            "http://schemas.xmlsoap.org/wsdl/soap/http", "http://schemas.xmlsoap.org/soap/http",
            "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://schemas.xmlsoap.org/wsdl/http/",
            "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat", });
    httpTransport.setTransportIds(transportIds);
    httpTransport.registerWithBindingManager();
    // httpTransport.register();
}
 
Example #6
Source File: BusExtensionLoadingTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Test for checking the ExtensionManagerBus is built using the TCCL by default
 *
 * @throws Exception
 */
@Test
public void testDefaultBusConstruction() throws Exception {
    BusFactory factory = new CXFBusFactory();
    Bus bus = factory.createBus();
    assertNotNullExtensions(bus);
    bus.shutdown(true);
}
 
Example #7
Source File: ClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBase64() throws Exception  {
    URL wsdl = getClass().getResource("/wsdl/others/dynamic_client_base64.wsdl");
    assertNotNull(wsdl);
    String wsdlUrl = null;
    wsdlUrl = wsdl.toURI().toString();
    CXFBusFactory busFactory = new CXFBusFactory();
    Bus bus = busFactory.createBus();
    DynamicClientFactory dynamicClientFactory = DynamicClientFactory.newInstance(bus);
    Client client = dynamicClientFactory.createClient(wsdlUrl);
    assertNotNull(client);
}
 
Example #8
Source File: ClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testJaxWsDynamicClient() throws Exception {
    URL wsdl = getClass().getResource("/wsdl/others/dynamic_client_base64.wsdl");
    assertNotNull(wsdl);
    String wsdlUrl = null;
    wsdlUrl = wsdl.toURI().toString();
    CXFBusFactory busFactory = new CXFBusFactory();
    Bus bus = busFactory.createBus();
    org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory dynamicClientFactory =
        org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory.newInstance(bus);
    Client client = dynamicClientFactory.createClient(wsdlUrl);
    assertNotNull(client);
}
 
Example #9
Source File: ConfiguredEndpointTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCXFDefaultClientEndpoint() {
    factory = new CXFBusFactory();
    BusFactory.setDefaultBus(null);
    factory.createBus();
    System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
    doTestDefaultClientEndpoint();
}
 
Example #10
Source File: ConfiguredEndpointTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCXFDefaultServerEndpoint() {
    factory = new CXFBusFactory();
    BusFactory.setDefaultBus(null);
    factory.createBus();
    System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
    initializeBus();
    doTestDefaultServerEndpoint();
}
 
Example #11
Source File: ConfiguredEndpointTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void xtestCXFConfiguredServerEndpoint() {
    CXFBusFactory cf = new CXFBusFactory();
    factory = cf;
    BusFactory.setDefaultBus(null);
    Map<String, Object> properties = new HashMap<>();
    properties.put(Configurer.USER_CFG_FILE_PROPERTY_NAME,
        "org/apache/cxf/jaxws/configured-endpoints.xml");
    BusFactory.setDefaultBus(cf.createBus(null, properties));
    initializeBus();
    System.setProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME, CXFBusFactory.class.getName());
    //doTestConfiguredServerEndpoint();
}
 
Example #12
Source File: AbstractConnectionITHelper.java    From tracee with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected JaxWsServerFactoryBean createJaxWsServer() {
	JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
	serverFactoryBean.setServiceClass(HelloWorldTestServiceImpl.class);
	serverFactoryBean.setAddress(endpointAddress);
	serverFactoryBean.setServiceBean(new HelloWorldTestServiceImpl(serverBackend));
	serverFactoryBean.setBus(CXFBusFactory.getDefaultBus());
	return serverFactoryBean;
}
 
Example #13
Source File: CxfClientToCxfServerIT.java    From tracee with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Before
public void setup() {
	JaxWsServerFactoryBean jaxWsServer = createJaxWsServer();
	jaxWsServer.getFeatures().add(new LoggingFeature());
	jaxWsServer.getFeatures().add(new TraceeCxfFeature(serverBackend, Profile.DEFAULT));
	server = jaxWsServer.create();

	final ClientProxyFactoryBean factoryBean = new ClientProxyFactoryBean();
	factoryBean.getFeatures().add(new LoggingFeature());
	factoryBean.getFeatures().add(new TraceeCxfFeature(clientBackend, Profile.DEFAULT));
	factoryBean.setServiceClass(HelloWorldTestService.class);
	factoryBean.setBus(CXFBusFactory.getDefaultBus());
	factoryBean.setAddress(endpointAddress);
	helloWorldPort = (HelloWorldTestService) factoryBean.create();
}
 
Example #14
Source File: DynamicClientEndpointCreationLoop.java    From cxf with Apache License 2.0 4 votes vote down vote up
private DynamicClientEndpointCreationLoop() {
    CXFBusFactory busFactory = new CXFBusFactory();
    bus = busFactory.createBus();
}
 
Example #15
Source File: Server.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected Server() throws Exception {
    System.out.println("Starting Server");

    customers.put("Tom", new Customer.PremiumCustomer("Tom"));
    customers.put("Rob", new Customer.PreferredCustomer("Rob"));
    customers.put("Vince", new Customer.RegularCustomer("Vince"));
    customers.put("Malcolm", new Customer.CheapCustomer("Malcolm"));
    customers.put("Jonas", new Customer.TrialCustomer("Jonas"));

    Map<String, Object> properties = new HashMap<>();
    properties.put("bus.jmx.usePlatformMBeanServer", Boolean.TRUE);
    properties.put("bus.jmx.enabled", Boolean.TRUE);
    Bus b = new CXFBusFactory().createBus(null, properties);
    MetricRegistry registry = new MetricRegistry();
    CodahaleMetricsProvider.setupJMXReporter(b, registry);
    b.setExtension(registry, MetricRegistry.class);

    ThrottlingManager manager = new ThrottlingManager() {
        @Override
        public ThrottleResponse getThrottleResponse(String phase, Message m) {
            ThrottleResponse r = new ThrottleResponse();
            if (m.get("THROTTLED") != null) {
                return null;
            }
            m.put("THROTTLED", true);
            Customer c = m.getExchange().get(Customer.class);
            c.throttle(r);
            return r;
        }

        @Override
        public List<String> getDecisionPhases() {
            return Collections.singletonList(Phase.PRE_STREAM);
        }

    };
    b.getInInterceptors().add(new CustomerMetricsInterceptor(registry, customers));

    Object implementor = new GreeterImpl();
    String address = "http://localhost:9001/SoapContext/SoapPort";
    Endpoint.publish(address, implementor,
                     new MetricsFeature(),
                     new ThrottlingFeature(manager));
}
 
Example #16
Source File: HolderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Override
protected Bus createBus() throws BusException {
    return new CXFBusFactory().createBus();
}