Search in sources :

Example 1 with BusFactory

use of org.apache.cxf.BusFactory in project camel by apache.

the class CamelTransportTestSupport method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    BusFactory bf = BusFactory.newInstance();
    //setup the camel transport for the bus
    bus = bf.createBus();
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    CamelTransportFactory camelTransportFactory = new CamelTransportFactory();
    //set the context here to the transport factory;
    camelTransportFactory.setCamelContext(context);
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    dfm.registerDestinationFactory(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);
    cim.registerConduitInitiator(CamelTransportFactory.TRANSPORT_ID, camelTransportFactory);
    BusFactory.setDefaultBus(bus);
    endpointInfo = new EndpointInfo();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) BusFactory(org.apache.cxf.BusFactory) Before(org.junit.Before)

Example 2 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class AbstractClient method testBusCreation.

public static void testBusCreation() throws BusTestException {
    Bus initialDefaultBus = BusFactory.getDefaultBus(false);
    Bus initialThreadBus = BusFactory.getThreadDefaultBus(false);
    BusFactory factory = BusFactory.newInstance();
    Bus bus = factory.createBus();
    assert (bus != null);
    if (// if the thread bus was not set before, it should now be
    initialThreadBus == null) {
        checkThreadBus(bus);
    }
    checkDefaultBus(initialDefaultBus);
    BusFactory.setThreadDefaultBus(initialThreadBus);
    checkThreadBus(initialThreadBus);
    checkDefaultBus(initialDefaultBus);
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 3 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class AbstractClient method testWebServiceRef.

public static void testWebServiceRef(Endpoint port) throws BusTestException {
    Bus initialDefaultBus = BusFactory.getDefaultBus(false);
    Bus threadBus = BusFactory.getThreadDefaultBus(false);
    // does not change anything to the bus, as the port is already created when injecting serviceref
    performInvocation(port);
    checkDefaultBus(initialDefaultBus);
    checkThreadBus(threadBus);
    try {
        BusFactory.setThreadDefaultBus(null);
        // does not change anything to the bus, as the port is already created when injecting serviceref
        performInvocation(port);
        checkDefaultBus(initialDefaultBus);
        checkThreadBus(null);
        BusFactory factory = BusFactory.newInstance();
        // internally sets the thread bus
        Bus bus = factory.createBus();
        // does not change anything to the bus, as the port is already created when injecting serviceref
        performInvocation(port);
        checkDefaultBus(initialDefaultBus);
        checkThreadBus(bus);
    } finally {
        BusFactory.setThreadDefaultBus(threadBus);
    }
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 4 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class Helper method verifyCXF.

public static void verifyCXF() {
    // check BusFactory customization; this is required by the JBWS-CXF Configurer integration (HTTPConduit customization, JAXBIntros, ...)
    BusFactory factory = BusFactory.newInstance();
    if (!(factory instanceof JBossWSBusFactory))
        throw new RuntimeException("Expected " + JBossWSBusFactory.class + " but got " + (factory == null ? null : factory.getClass()));
    // check the Apache CXF JAXWS implementation is actually used
    Object obj = getImplementationObject();
    if (!obj.getClass().getName().contains("cxf"))
        throw new RuntimeException("JAXWS implementation is not properly selected or endorsed!");
}
Also used : JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory) BusFactory(org.apache.cxf.BusFactory) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)

Example 5 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class Helper method testJBossWSCXFBus.

/**
 * Verify the BusFactory.newInstance() still return the JBossWS-CXF version of BusFactory
 * (the web app has a dependency on jbossws-cxf-client) and that still create a plain bus
 * version, without being fooled by the Spring availability in the TCCL when Spring is not
 * installed in the AS.
 *
 * @return
 */
public boolean testJBossWSCXFBus() {
    BusFactory factory = BusFactory.newInstance();
    if (!(factory instanceof JBossWSBusFactory)) {
        throw new RuntimeException("Expected JBossWSBusFactory");
    }
    Bus bus = null;
    try {
        // set Configurer.USER_CFG_FILE_PROPERTY_NAME so that if the SpringBusFactory is
        // internally erroneously used, that won't fallback delegating to the non Spring
        // one, which would shade the issue
        final String prop = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
        try {
            System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, "unexistentfile.xml");
            bus = factory.createBus();
            // the created bus should not be a SpringBus, as the classloader for CXF has no visibility over the deployment spring jars
            return !isSpringBus(bus);
        } finally {
            if (prop == null) {
                System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
            } else {
                System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, prop);
            }
        }
    } finally {
        if (bus != null) {
            bus.shutdown(true);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory) BusFactory(org.apache.cxf.BusFactory) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)

Aggregations

BusFactory (org.apache.cxf.BusFactory)20 Bus (org.apache.cxf.Bus)13 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)5 Test (org.junit.Test)5 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 JaxWsDynamicClientFactory (org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory)4 CXFBusFactory (org.apache.cxf.bus.CXFBusFactory)3 JBossWSBusFactory (org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)3 URL (java.net.URL)2 Subject (javax.security.auth.Subject)2 QName (javax.xml.namespace.QName)2 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 KeyStore (java.security.KeyStore)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)1