Author: ningjiang
Date: Tue Dec 14 03:27:10 2010
New Revision: 1048919
URL: http://svn.apache.org/viewvc?rev=1048919&view=rev
Log:
CXF-3184 Fixed the issue of SOAPBindingUtil.getProxy in OSGi
Modified:
cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
Modified:
cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java?rev=1048919&r1=1048918&r2=1048919&view=diff
==============================================================================
---
cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
(original)
+++
cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
Tue Dec 14 03:27:10 2010
@@ -84,8 +84,20 @@ public final class SOAPBindingUtil {
/*
* If we put proxies into the loader of the proxied class, they'll
just pile up.
*/
- Object proxy =
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ Object proxy = null;
+ try {
+ proxy =
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
new Class[] {cls}, ih);
+ } catch (IllegalArgumentException 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 {
+ throw ex;
+ }
+ }
return cls.cast(proxy);
}