You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2010/01/16 02:06:49 UTC

svn commit: r899865 - /tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java

Author: lresende
Date: Sat Jan 16 01:06:48 2010
New Revision: 899865

URL: http://svn.apache.org/viewvc?rev=899865&view=rev
Log:
Fix for POJO_10009_TestCase, making the thread context classloader the one used to load class being invoked

Modified:
    tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java

Modified: tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java?rev=899865&r1=899864&r2=899865&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java Sat Jan 16 01:06:48 2010
@@ -77,6 +77,11 @@
 
         EndpointReference from = msg.getFrom();
 
+        // store the current thread context classloader
+        // as we need to replace it with the class loader
+        // used to load the java class as per SCA Spec
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        
         try {
             // The following call might create a new conversation, as a result, the msg.getConversationID() might 
             // return a new value
@@ -97,6 +102,12 @@
                 }
             }
             
+            // Set the thread context classloader of the thread used to invoke an operation 
+            // of a Java POJO component implementation is the class loader of the contribution 
+            // that contains the POJO implementation class.
+            
+            Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
+            
             Object ret;
             if (payload != null && !payload.getClass().isArray()) {
                 ret = imethod.invoke(instance, payload);
@@ -116,8 +127,7 @@
                     msg.setFaultBody(cause);
                     break;
                 }
-            }
-
+            } 
             
             if (sequence != ConversationSequence.CONVERSATION_NONE ){
                 try {
@@ -153,6 +163,9 @@
                 
         } catch (Exception e) {
             msg.setFaultBody(e);           
+        } finally {
+            // set the tccl 
+            Thread.currentThread().setContextClassLoader(tccl);
         }
         return msg;
     }