Search in sources :

Example 31 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project jbossws-cxf by jbossws.

the class JBossWSBusFactory method createBus.

@Override
public Bus createBus(Map<Class<?>, Object> extensions, Map<String, Object> properties) {
    if (extensions == null) {
        extensions = new HashMap<Class<?>, Object>();
    }
    if (!extensions.containsKey(Configurer.class)) {
        extensions.put(Configurer.class, new JBossWSConfigurerImpl(new BeanCustomizer()));
    }
    // Explicitly ask for the ProviderImpl.class.getClassLoader() to be used for getting
    // cxf bus extensions (as that classloader is the jaxws-client module one which 'sees' all
    // extensions, unless different dependencies are explicitly set)
    ExtensionManagerBus bus = new ExtensionManagerBus(extensions, properties, ProviderImpl.class.getClassLoader());
    possiblySetDefaultBus(bus);
    initializeBus(bus);
    bus.initialize();
    DefaultHTTPConduitFactoryWrapper.install(bus);
    return bus;
}
Also used : ProviderImpl(org.jboss.wsf.stack.cxf.client.ProviderImpl) Configurer(org.apache.cxf.configuration.Configurer) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus)

Example 32 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project aries-jax-rs-whiteboard by apache.

the class Whiteboard method createBus.

private ExtensionManagerBus createBus(Map<String, ServiceTuple<Object>> extensions) {
    BundleWiring wiring = _bundleContext.getBundle().adapt(BundleWiring.class);
    Map<String, Object> properties = new HashMap<>(_configurationMap);
    properties.putIfAbsent("replace.loopback.address.with.localhost", "false");
    HashMap<Class<?>, Object> cxfExtensions = new HashMap<>();
    if (extensions.isEmpty()) {
        cxfExtensions = null;
    } else {
        for (Map.Entry<String, ServiceTuple<Object>> entry : extensions.entrySet()) {
            String className = entry.getKey();
            ServiceTuple<Object> serviceTuple = entry.getValue();
            ClassLoader classLoader = getClassLoader(serviceTuple);
            try {
                Class<?> clazz = classLoader.loadClass(className);
                cxfExtensions.put(clazz, serviceTuple.getService());
            } catch (Exception e) {
                if (_log.isErrorEnabled()) {
                    _log.error("Could not load extension for CXF bus", e);
                }
            }
        }
    }
    if (_log.isDebugEnabled()) {
        _log.debug("Creating CXF Bus with extensions {} and properties {}", extensions, properties);
    }
    ExtensionManagerBus bus = new ExtensionManagerBus(cxfExtensions, properties, wiring.getClassLoader());
    bus.initialize();
    if (_log.isDebugEnabled()) {
        _log.debug("Created CXF Bus with extensions {} and properties {}", extensions, properties);
    }
    return bus;
}
Also used : BundleWiring(org.osgi.framework.wiring.BundleWiring) Utils.getString(org.apache.aries.jax.rs.whiteboard.internal.utils.Utils.getString) ServiceTuple(org.apache.aries.jax.rs.whiteboard.internal.utils.ServiceTuple) Collectors.toMap(java.util.stream.Collectors.toMap) Utils.accumulateInMap(org.apache.aries.component.dsl.Utils.accumulateInMap) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus)

Example 33 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class EndpointImplTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() throws Exception {
    Bus bus = new ExtensionManagerBus();
    Service svc = new ServiceImpl();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    EndpointInfo ei2 = new EndpointInfo();
    ei2.setAddress("http://nowhere.com/foo/bar");
    Endpoint ep = new EndpointImpl(bus, svc, ei);
    Endpoint ep1 = new EndpointImpl(bus, svc, ei);
    Endpoint ep2 = new EndpointImpl(bus, svc, ei2);
    int hashcode = ep.hashCode();
    int hashcode1 = ep1.hashCode();
    int hashcode2 = ep2.hashCode();
    assertEquals("hashcodes must be equal", hashcode, hashcode1);
    assertNotEquals("hashcodes must not be equal", hashcode, hashcode2);
    // assertEquals("reflexivity violated", ep, ep);
    assertNotEquals("two objects must not be equal", ep, ep1);
    assertNotEquals("two objects must not be equal", ep, ep2);
    ep.put("custom", Boolean.TRUE);
    assertEquals("hashcode must remain equal", hashcode, ep.hashCode());
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServiceImpl(org.apache.cxf.service.ServiceImpl) Service(org.apache.cxf.service.Service) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 34 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("please provide wsdl");
        System.exit(0);
    }
    final Bus bus = new ExtensionManagerBus();
    BusFactory.setDefaultBus(bus);
    bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
    bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
    bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
    bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
    bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
    bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
    run(args, bus);
    System.exit(0);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) FactoryClassLoader(org.apache.cxf.jaxb.FactoryClassLoader) ExtensionClassLoader(org.apache.cxf.wsdl.ExtensionClassLoader) GeneratedNamespaceClassLoader(org.apache.cxf.common.spi.GeneratedNamespaceClassLoader) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) ExceptionClassLoader(org.apache.cxf.endpoint.dynamic.ExceptionClassLoader) WrapperClassLoader(org.apache.cxf.jaxws.spi.WrapperClassLoader) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus)

Example 35 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class CXFBusImplTest method testConstructionWithExtensions.

@Test
public void testConstructionWithExtensions() throws BusException {
    IMocksControl control;
    BindingFactoryManager bindingFactoryManager;
    InstrumentationManager instrumentationManager;
    PhaseManager phaseManager;
    control = EasyMock.createNiceControl();
    Map<Class<?>, Object> extensions = new HashMap<>();
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    instrumentationManager = control.createMock(InstrumentationManager.class);
    phaseManager = control.createMock(PhaseManager.class);
    extensions.put(BindingFactoryManager.class, bindingFactoryManager);
    extensions.put(InstrumentationManager.class, instrumentationManager);
    extensions.put(PhaseManager.class, phaseManager);
    Bus bus = new ExtensionManagerBus(extensions);
    assertSame(bindingFactoryManager, bus.getExtension(BindingFactoryManager.class));
    assertSame(instrumentationManager, bus.getExtension(InstrumentationManager.class));
    assertSame(phaseManager, bus.getExtension(PhaseManager.class));
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) PhaseManager(org.apache.cxf.phase.PhaseManager) HashMap(java.util.HashMap) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Aggregations

ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)59 Bus (org.apache.cxf.Bus)48 Test (org.junit.Test)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)28 Message (org.apache.cxf.message.Message)14 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)14 QName (javax.xml.namespace.QName)8 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)8 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 ArrayList (java.util.ArrayList)6 AtmosphereInterceptor (org.atmosphere.cpr.AtmosphereInterceptor)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 URL (java.net.URL)4 List (java.util.List)4 ASMHelperImpl (org.apache.cxf.common.util.ASMHelperImpl)4 MessageObserver (org.apache.cxf.transport.MessageObserver)4 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)4 HttpURLConnection (java.net.HttpURLConnection)3 Hashtable (java.util.Hashtable)3