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-08-17 16:04:45 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2011-08-17 16:04:45 +0000
commit9d69b5d4b215f691496a87eea974179a88885383 (patch)
tree39b4b4e5e5e470a019c5d4a4c66a009214c20bf9 /sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca
parent1798efc6a2291275dcf9a75b6cc06e64776a5cfa (diff)
TUSCANY-3922 - apply Jennifer's patch to add some missing doPrivileged calls around various classloader calls. Thanks for the patch Jennifer.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1158793 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.java31
1 files changed, 26 insertions, 5 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 0b97192cc6..33e1b1891d 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
@@ -18,8 +18,12 @@
*/
package org.apache.tuscany.sca.implementation.java.invocation;
+
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.List;
@@ -94,7 +98,12 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
// 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();
+ final ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ return tccl;
+ }
+ });
try {
// The following call might create a new conversation, as a result, the msg.getConversationID() might
@@ -107,7 +116,7 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
injectCallbacks(wrapper, (JavaInterface)interfaze.getCallbackInterface());
}
- Object instance = wrapper.getInstance();
+ final Object instance = wrapper.getInstance();
// If the method couldn't be computed statically, or the instance being
// invoked is a user-specified callback object that doesn't implement
@@ -125,8 +134,14 @@ 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.
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
+ return null;
+ }
+ });
+
- Thread.currentThread().setContextClassLoader(instance.getClass().getClassLoader());
int argumentHolderCount = 0;
@@ -245,8 +260,14 @@ public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics
} catch (Exception e) {
msg.setFaultBody(e);
} finally {
- // set the tccl
- Thread.currentThread().setContextClassLoader(tccl);
+ // set the tccl
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ Thread.currentThread().setContextClassLoader(tccl);
+ return null;
+ }
+ });
+
}
return msg;
}