summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.5.1/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-18 13:39:01 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-07-18 13:39:01 +0000
commitcf2920e3a3de88ba22a577fea114ad39fbf338b3 (patch)
tree173ee98617d49d4c6d02d64678048a38fa0ac837 /branches/sca-java-1.5.1/modules
parent6aeb3566cde641802342a196fab4e339451eb9b1 (diff)
TUSCANY-3140 - Test for difference between loadtime and runtime classloaders and, in the case where they are different, fix up the wire source interface based on the interface provided to the getService() call.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@795365 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java b/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
index b2b30db558..bb9595bf9c 100644
--- a/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
+++ b/branches/sca-java-1.5.1/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
@@ -30,8 +30,10 @@ import java.util.UUID;
import javax.xml.ws.Holder;
+import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.assembly.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.CallableReferenceImpl;
+import org.apache.tuscany.sca.core.context.ComponentContextImpl;
import org.apache.tuscany.sca.core.context.InstanceWrapper;
import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.conversation.ConversationState;
@@ -45,8 +47,10 @@ import org.apache.tuscany.sca.interfacedef.ConversationSequence;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.ParameterMode;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
@@ -94,6 +98,39 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
this.businessInterface = callableReference.getBusinessInterface();
this.conversation = (ExtendedConversation)callableReference.getConversation();
this.wire = ((CallableReferenceImpl<?>)callableReference).getRuntimeWire();
+
+ /* ==========================================================================*/
+ // TUSCANY-3140 - in some cases we have noticed that the runtime engine for a
+ // component implementation uses a different classloader compared
+ // to the classloader used in the first instance to introspect the
+ // component type and create the component model. If the business
+ // interface of the callable reference is different from the
+ // interface of the reference then set the reference interface to the
+ // business interface
+ if (wire != null){
+ Interface iface = wire.getSource().getInterfaceContract().getInterface();
+ if (iface instanceof JavaInterface) {
+ JavaInterface javaIFace = (JavaInterface)iface;
+ // only reset the interface if the classes have the same name but the
+ // class object is different
+ if ((javaIFace.getJavaClass().getName().equals(this.businessInterface.getName())) &&
+ (javaIFace.getJavaClass() != this.businessInterface)) {
+ try {
+ RuntimeComponent wireSourceComponent = wire.getSource().getComponent();
+ CompositeActivator compositeActivator = ((ComponentContextImpl)wireSourceComponent.getComponentContext()).getCompositeActivator();
+ if (compositeActivator != null && compositeActivator.getJavaInterfaceFactory() != null) {
+ //reconstruct java interface using interface loaded by implementation class loader
+ iface.getOperations().clear();
+ compositeActivator.getJavaInterfaceFactory().createJavaInterface((JavaInterface) iface, this.businessInterface);
+ }
+ } catch (InvalidInterfaceException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ /* ==========================================================================*/
+
if (wire != null) {
init(wire);
}