diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-16 12:56:23 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-16 12:56:23 +0000 |
commit | 562a484efbe0259642737f835cd6ece3c9ec7c17 (patch) | |
tree | c02e4ed0bb5bccd73bffb4806531dc0a11887e48 | |
parent | ce7d97a055fea161cc2c481d42b60d13f6ce5bf9 (diff) |
TUSCANY-3946 - only reset the TCCL if it's not already set to the contribution classloader
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1171532 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java | 43 |
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; } |