From dbe8becdf75de47cbf289b52fb8164fc6b679c3a Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 16 Jan 2010 01:06:48 +0000 Subject: Fix for POJO_10009_TestCase, making the thread context classloader the one used to load class being invoked git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@899865 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/invocation/JavaImplementationInvoker.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sca-java-2.x/trunk/modules/implementation-java-runtime/src') diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java index ed7a4d278f..108fa428da 100644 --- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java +++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java @@ -77,6 +77,11 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics 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 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics } } + // 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 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics msg.setFaultBody(cause); break; } - } - + } if (sequence != ConversationSequence.CONVERSATION_NONE ){ try { @@ -153,6 +163,9 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics } catch (Exception e) { msg.setFaultBody(e); + } finally { + // set the tccl + Thread.currentThread().setContextClassLoader(tccl); } return msg; } -- cgit v1.2.3