summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-09 13:34:11 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-12-09 13:34:11 +0000
commit0fb1fd45f479254df6b527908d61720c8d08e083 (patch)
treeec564d5c462ec884a0ccce626a3cea37bdff9d00 /sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca
parent342f347a90282bcb3c86c3029203049859a970bc (diff)
TUSCANY-3946 - Had a bit of a change of heart about this one. I'm concerned that putting extra doPrivileged checks in the main message flow is going to have a negative impact on performance so I've swapped out that code so a check on the presence of a message header.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1212406 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java24
1 files changed, 10 insertions, 14 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 4ce1fdcf4b..de15651227 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
@@ -31,6 +31,7 @@ import javax.xml.ws.Holder;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.invocation.Constants;
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.ScopeContainer;
import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
@@ -104,7 +105,13 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
return tccl;
}
});
- ClassLoader contributionClassloader = null;
+
+ // TUSCANY-3946 - If the TCCL has not already been set to the contribution classloader earlier
+ // in the wire processing 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
+ // used to load the POJO implementation class.
+ boolean swapTCCL = (msg.getHeaders().get(Constants.SUPPRESS_TCCL_SWAP) == null);
try {
// The following call might create a new conversation, as a result, the msg.getConversationID() might
@@ -132,18 +139,7 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
}
}
- // 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
- // used to load the POJO implementation class.
- contributionClassloader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- ClassLoader contributionClassloader = instance.getClass().getClassLoader();
- return contributionClassloader;
- }
- });
-
- if (tccl != contributionClassloader){
+ if (swapTCCL){
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
@@ -271,7 +267,7 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
} finally {
// reset the tccl if it was replaced above
// with the contribution classloader
- if (tccl != contributionClassloader){
+ if (swapTCCL){
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
Thread.currentThread().setContextClassLoader(tccl);