summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-01-16 01:06:48 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-01-16 01:06:48 +0000
commitdbe8becdf75de47cbf289b52fb8164fc6b679c3a (patch)
tree21b944b77a1b82d3c263d283081b42937ffeb71b /sca-java-2.x/trunk/modules/implementation-java-runtime/src/main
parent48f1b91425a87111de5c0f43ccdb3f3c26a5b222 (diff)
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-java-runtime/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java17
1 files changed, 15 insertions, 2 deletions
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;
}