summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java43
1 files changed, 24 insertions, 19 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 33e1b1891d..33008c2e25 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
@@ -84,7 +84,7 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
@SuppressWarnings("unchecked")
public Message invoke(Message msg) {
-
+
Operation op = msg.getOperation();
if (op == null) {
op = this.operation;
@@ -104,6 +104,7 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
return tccl;
}
});
+ ClassLoader contributionClassloader = null;
try {
// The following call might create a new conversation, as a result, the msg.getConversationID() might
@@ -131,17 +132,19 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
}
}
- // Set the thread context classloader of the thread used to invoke an operation
+ // TUSCANY-3946 - If the TCCL has not already been set to the contribution classloader then
+ // set it so that 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.
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
- return null;
- }
- });
-
-
+ // used to load the POJO implementation class.
+ contributionClassloader = instance.getClass().getClassLoader();
+ if (tccl != contributionClassloader){
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
+ return null;
+ }
+ });
+ }
int argumentHolderCount = 0;
@@ -260,14 +263,16 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
} catch (Exception e) {
msg.setFaultBody(e);
} finally {
- // set the tccl
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- Thread.currentThread().setContextClassLoader(tccl);
- return null;
- }
- });
-
+ // reset the tccl if it was replaced above
+ // with the contribution classloader
+ if (tccl != contributionClassloader){
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(tccl);
+ return null;
+ }
+ });
+ }
}
return msg;
}