use of org.apache.cxf.common.util.ClassUnwrapper in project tomee by apache.
the class CxfUtil method initDefaultBus.
private static Bus initDefaultBus() {
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(CxfUtil.class.getClassLoader());
try {
// create the bus reusing cxf logic but skipping factory lookup
final Bus bus = BusFactory.newInstance(CXFBusFactory.class.getName()).createBus();
bus.setId(SystemInstance.get().getProperty("openejb.cxf.bus.id", "openejb.cxf.bus"));
final BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
bindingFactoryMap = (Map<String, BindingFactory>) Reflections.get(bfm, "bindingFactories");
bus.setExtension(new OpenEJBHttpDestinationFactory(), HttpDestinationFactory.class);
// ensure client proxies can use app classes
CXFBusFactory.setDefaultBus(Bus.class.cast(Proxy.newProxyInstance(CxfUtil.class.getClassLoader(), new Class<?>[] { Bus.class }, new ClientAwareBusHandler())));
bus.setProperty(ClassUnwrapper.class.getName(), new ClassUnwrapper() {
@Override
public Class<?> getRealClass(final Object o) {
final Class<?> aClass = o.getClass();
Class<?> c = aClass;
while (c.getName().contains("$$")) {
c = c.getSuperclass();
}
return c == Object.class ? aClass : c;
}
});
SystemInstance.get().addObserver(new LifecycleManager());
initAuthenticators();
// we keep as internal the real bus and just expose to cxf the client aware bus to be able to cast it easily
return bus;
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
Aggregations