use of org.apache.cxf.common.util.ExtensionInvocationHandler in project cxf by apache.
the class SOAPBindingUtil method getProxy.
public static <T> T getProxy(Class<T> cls, Object obj) {
InvocationHandler ih = new ExtensionInvocationHandler(obj);
/*
* If we put proxies into the loader of the proxied class, they'll just pile up.
*/
Object proxy;
try {
proxy = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] { cls }, ih);
} catch (Throwable ex) {
// Using cls classloader as a fallback to make it work within OSGi
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
if (contextLoader != cls.getClassLoader()) {
proxy = Proxy.newProxyInstance(cls.getClassLoader(), new Class[] { cls }, ih);
} else {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
}
return cls.cast(proxy);
}
use of org.apache.cxf.common.util.ExtensionInvocationHandler in project cxf by apache.
the class SOAPBindingUtil method getProxy.
public static <T> T getProxy(Class<T> cls, Object obj) {
InvocationHandler ih = new ExtensionInvocationHandler(obj);
/*
* If we put proxies into the loader of the proxied class, they'll just pile up.
*/
Object proxy;
try {
proxy = Proxy.newProxyInstance(getContextClassLoader(), new Class[] { cls }, ih);
} catch (Throwable ex) {
// Using cls classloader as a fallback to make it work within OSGi
ClassLoader contextLoader = getContextClassLoader();
final ClassLoader clsClassLoader = getClassLoader(cls);
if (contextLoader != clsClassLoader) {
proxy = Proxy.newProxyInstance(clsClassLoader, new Class[] { cls }, ih);
} else {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
}
throw new RuntimeException(ex);
}
}
return cls.cast(proxy);
}
Aggregations