Author: slaws
Date: Fri Dec 9 13:34:11 2011
New Revision: 1212406
URL: http://svn.apache.org/viewvc?rev=1212406&view=rev
Log:
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.
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java?rev=1212406&r1=1212405&r2=1212406&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/Constants.java
Fri Dec 9 13:34:11 2011
@@ -24,8 +24,14 @@ package org.apache.tuscany.sca.core.invo
*
*/
public interface Constants {
- String MESSAGE_ID = "MESSAGE_ID";
- String RELATES_TO = "RELATES_TO";
- String ASYNC_RESPONSE_INVOKER = "ASYNC_RESPONSE_INVOKER";
- String ASYNC_CALLBACK = "ASYNC_CALLBACK";
+ public static final String MESSAGE_ID =
"MESSAGE_ID";
+ public static final String RELATES_TO =
"RELATES_TO";
+ public static final String ASYNC_RESPONSE_INVOKER =
"ASYNC_RESPONSE_INVOKER";
+ public static final String ASYNC_CALLBACK =
"ASYNC_CALLBACK";
+
+ /**
+ * If you've set the TCCL in your binding impl according to OASIS rules
you can prevent
+ * the implementation provider from repeating the process by including
this header
+ */
+ public static final String SUPPRESS_TCCL_SWAP = "SUPPRESS_TCCL_SWAP";
}
Modified:
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java?rev=1212406&r1=1212405&r2=1212406&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
Fri Dec 9 13:34:11 2011
@@ -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 i
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 i
}
}
- // 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 i
} 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);