tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edward...@apache.org
Subject svn commit: r800984 - /tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
Date Tue, 04 Aug 2009 21:24:11 GMT
Author: edwardsmj
Date: Tue Aug  4 21:24:11 2009
New Revision: 800984

URL: http://svn.apache.org/viewvc?rev=800984&view=rev
Log:
Fix classloading problem with Axis dependencies used by binding-ws-axis2 on references that
use this binding: force TCCL for those dependencies to be the OSGi Bundle ClassLoader when
running under OSGi

Modified:
    tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java

Modified: tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java?rev=800984&r1=800983&r2=800984&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
(original)
+++ tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
Tue Aug  4 21:24:11 2009
@@ -126,7 +126,12 @@
      * Create an Axis2 ServiceClient
      */
     protected ServiceClient createServiceClient() {
-        try {
+    	ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+    	ClassLoader axiscl = this.getClass().getClassLoader();
+
+    	try {
+    		if( axiscl != tccl ) Thread.currentThread().setContextClassLoader(axiscl);
+    		
             final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding);
             ConfigurationContext configContext;
             
@@ -145,7 +150,7 @@
                 // configureSecurity();
             } catch (PrivilegedActionException e) {
                 throw new ServiceRuntimeException(e.getException());
-            }
+            } // end try
 
             createPolicyHandlers();
 
@@ -171,7 +176,7 @@
                         }
                     }
                 }
-            }
+            } // end if
             AxisService axisService =
                 createClientSideAxisService(definition, serviceQName, port.getName(), new
Options());
 
@@ -188,7 +193,7 @@
                 configContext.setThreadPool(new ThreadPool(1, 5));
                 configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
                 configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
-            }
+            } // end if
 
             return new ServiceClient(configContext, axisService);
 
@@ -200,8 +205,11 @@
             throw new RuntimeException(e);
         } catch (IllegalAccessException e) {
             throw new RuntimeException(e);
-        }
-    }
+        } finally {
+        	// Restore the Thread Context ClassLoader...
+    		if( axiscl != tccl ) Thread.currentThread().setContextClassLoader(tccl);
+        } // end try
+    } // end method createServiceClient
 
     /**
      * URI resolver implementation for XML schema



Mime
View raw message