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;
}
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;
}
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());
}
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);
}
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));
}
Aggregations