tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r572238 - in /incubator/tuscany/java/sca/modules: binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/ core/src/main/java/org/apache/tuscany/sca/core/context/ core/src/main/java/org/apache/tuscany/sca/core/invocation/
Date Mon, 03 Sep 2007 06:39:28 GMT
Author: rfeng
Date: Sun Sep  2 23:39:28 2007
New Revision: 572238

URL: http://svn.apache.org/viewvc?rev=572238&view=rev
Log:
Apply the patch from Simon Nash for TUSCANY-1591

Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
Sun Sep  2 23:39:28 2007
@@ -50,7 +50,8 @@
     private Options options;
     private SOAPFactory soapFactory;
 
-    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA_NS, "conversationID");
+    public static final QName CALLBACK_ID_REFPARM_QN = new QName(Constants.SCA_NS, "CallbackID");
+    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA_NS, "ConversationID");
 
     public Axis2BindingInvoker(ServiceClient serviceClient,
                                QName wsdlOperationName,
@@ -124,15 +125,31 @@
 
         // Axis2 operationClients can not be shared so create a new one for each request
         OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
+        operationClient.setOptions(options);
+
+        // set callback endpoint and callback ID for WS-Addressing header
+        EndpointReference fromEPR = null;
+        if (msg.getFrom() != null) {
+            fromEPR = new EndpointReference(msg.getFrom().getBinding().getURI());
+            //FIXME: serialize callback ID to XML in case it is not a string
+            fromEPR.addReferenceParameter(CALLBACK_ID_REFPARM_QN,
+                                          (String)msg.getCallableReference().getCallbackID());
+        }
 
+        // set conversation ID for WS-Addressing header
+        //FIXME: get conversation ID from the message's callable reference
+        //FIXME: serialize conversation ID to XML in case it is not a string
         String conversationId = msg.getConversationID();
         if (conversationId != null && conversationId.length() != 0) {
-            EndpointReference fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+            if (fromEPR == null) {
+                fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+            }
             fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId);
-            options.setFrom(fromEPR);
-            requestMC.setFrom(fromEPR); //who knows why two ways ?
+        }
 
-            //For now do this the brute force method. Need to figure out how to do axis addressing
.. configure mar in flow.
+        // add WS-Addressing header
+        //FIXME: is there any way to use the Axis2 addressing support for this?
+        if (fromEPR != null) {
             SOAPEnvelope sev = requestMC.getEnvelope();
             SOAPHeader sh = sev.getHeader();
             OMElement el =
@@ -140,9 +157,9 @@
                              AddressingConstants.WSA_FROM,
                              AddressingConstants.WSA_DEFAULT_PREFIX);
             sh.addChild(el);
+            requestMC.setFrom(fromEPR);
         }
 
-        operationClient.setOptions(options);
         // if target endpoint was not specified when this invoker was created, 
         // use dynamically specified target endpoint passed in on this call
         if (options.getTo() == null) {
@@ -153,30 +170,7 @@
                 throw new RuntimeException("Unable to determine destination endpoint");
             }
         }
-        //FIXME: need to consolidate the following code with similar code above for
-        // conversations, so that conversations and callbacks work when used together
-        if (options.getFrom() != null) {
-            requestMC.setFrom(options.getFrom());
-            //FIXME: is there any way to use the Axis2 addressing support for this?
-            SOAPEnvelope sev = requestMC.getEnvelope();
-            SOAPHeader sh = sev.getHeader();
-            OMElement el =
-                options.getFrom().toOM(AddressingConstants.Final.WSA_NAMESPACE,
-                                       AddressingConstants.WSA_FROM,
-                                       AddressingConstants.WSA_DEFAULT_PREFIX);
-            sh.addChild(el);
-        } else if (msg.getFrom() != null)  {
-            EndpointReference fromEpr = new EndpointReference(msg.getFrom().getURI());
-            requestMC.setFrom(fromEpr);
-            SOAPEnvelope sev = requestMC.getEnvelope();
-            SOAPHeader sh = sev.getHeader();
-            OMElement el = fromEpr.toOM(AddressingConstants.Final.WSA_NAMESPACE,
-                                        AddressingConstants.WSA_FROM,
-                                        AddressingConstants.WSA_DEFAULT_PREFIX);
-            sh.addChild(el);
-        } else {
-            // the from field remains blank
-        }
+
         operationClient.addMessageContext(requestMC);
 
         return operationClient;

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
Sun Sep  2 23:39:28 2007
@@ -19,7 +19,6 @@
 package org.apache.tuscany.sca.binding.ws.axis2;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
 import org.apache.tuscany.sca.host.http.ServletHost;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -56,20 +55,7 @@
         // Set to use the Axiom data binding
         contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
 
-        // look for a matching callback binding
-        WebServiceBinding callbackBinding = null;
-        if (reference.getCallback() != null) {
-            for (Binding binding : reference.getCallback().getBindings()) {
-                if (binding instanceof WebServiceBinding) {
-                    // set the first compatible callback binding
-                    callbackBinding = (WebServiceBinding)binding;
-                    continue;
-                }
-            }
-        }
-
-        axisClient =
-            new Axis2ServiceClient(component, reference, wsBinding, servletHost, messageFactory,
callbackBinding);
+        axisClient = new Axis2ServiceClient(component, reference, wsBinding, servletHost,
messageFactory);
     }
 
     public void start() {

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
Sun Sep  2 23:39:28 2007
@@ -52,17 +52,14 @@
 
     private WebServiceBinding wsBinding;
     private ServiceClient serviceClient;
-    private WebServiceBinding callbackBinding;
 
     public Axis2ServiceClient(RuntimeComponent component,
                               AbstractContract contract,
                               WebServiceBinding wsBinding,
                               ServletHost servletHost,
-                              MessageFactory messageFactory,
-                              WebServiceBinding callbackBinding) {
+                              MessageFactory messageFactory) {
 
         this.wsBinding = wsBinding;
-        this.callbackBinding = callbackBinding;
         this.serviceClient = createServiceClient();
     }
 
@@ -140,9 +137,6 @@
         EndpointReference epTo = getPortLocationEPR(wsBinding);
         if (epTo != null) {
             options.setTo(epTo);
-        }
-        if (callbackBinding != null) {
-            options.setFrom(getPortLocationEPR(callbackBinding));
         }
         options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
Sun Sep  2 23:39:28 2007
@@ -45,10 +45,7 @@
         try {
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
-
-            String conversationID = provider.getConversationID(inMC);
-            String callbackAddress = provider.getFromEPR(inMC);
-            provider.invokeTarget(operation, args, null, conversationID, callbackAddress);
+            provider.invokeTarget(operation, args, inMC);
 
         } catch (InvocationTargetException e) {
             Throwable t = e.getCause();
@@ -57,8 +54,8 @@
             }
             throw new RuntimeException(e);
         } catch (Exception e) {
+            e.printStackTrace();
             throw AxisFault.makeFault(e);
         }
-
     }
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
Sun Sep  2 23:39:28 2007
@@ -47,14 +47,10 @@
         try {
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
-            
-            String conversationID = provider.getConversationID(inMC);
-            String callbackAddress = provider.getFromEPR(inMC);
-            OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, null,
conversationID,
-                                                                    callbackAddress);
+            OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, inMC);
 
             SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
-            if(null != responseOM ){
+            if (null != responseOM ) {
                 soapEnvelope.getBody().addChild(responseOM);
             }
             outMC.setEnvelope(soapEnvelope);
@@ -69,6 +65,5 @@
         } catch (Exception e) {
             throw AxisFault.makeFault(e);
         }
-
     }
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
Sun Sep  2 23:39:28 2007
@@ -35,6 +35,7 @@
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.deployment.util.Utils;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
@@ -67,6 +68,13 @@
     private MessageFactory messageFactory;
     private ConfigurationContext configContext;
 
+    public static final QName QNAME_WSA_ADDRESS =
+            new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
+    public static final QName QNAME_WSA_FROM =
+            new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
+    public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
+            new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
+
     // TODO: what to do about the base URI?
     // This port number may be used to construct callback URIs.  The value 8085 is used
     // beacuse it matches the service port number used by the simple-callback-ws sample.
@@ -280,107 +288,105 @@
         }
         return null;
     }
-
+                                            
     // methods for Axis2 message receivers
 
-    //FIXME: can we use the Axis2 addressing support for this?
-    /**
-     * @param inMC
-     * @return conversationID
-     */
-    protected String getConversationID(MessageContext inMC) {
+    public Object invokeTarget(Operation op,
+                               Object[] args,
+                               MessageContext inMC) throws InvocationTargetException {
+
+        String callbackAddress = null;
+        String callbackID = null;
         String conversationID = null;
-        if (isConversational()) {
-            SOAPHeader header = inMC.getEnvelope().getHeader();
-            if (header != null) {
-                Iterator<?> i = header.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
"From"));
-                for (; i.hasNext();) {
-                    Object a = i.next();
-                    if (a instanceof OMElement) {
-                        OMElement ao = (OMElement)a;
-                        for (Iterator<?> rpI =
-                            ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
-                                                             "ReferenceParameters")); rpI.hasNext();)
{
-                            OMElement rpE = (OMElement)rpI.next();
-                            for (Iterator<?> cidI =
-                                rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN);
cidI.hasNext();) {
-                                OMElement cidE = (OMElement)cidI.next();
-                                conversationID = cidE.getText();
+
+        //FIXME: can we use the Axis2 addressing support for this?
+        SOAPHeader header = inMC.getEnvelope().getHeader();
+        if (header != null) {
+            Iterator<?> i = header.getChildrenWithName(QNAME_WSA_FROM);
+            Object a = null;
+            for (; i.hasNext();) {
+                if (a != null) {
+                    throw new IllegalArgumentException("Duplicate wsa:From element");
+                }
+                a = i.next();
+                if (a instanceof OMElement) {
+                    OMElement ao = (OMElement)a;
+
+                    // process required Address element
+                    Iterator<?> adI = ao.getChildrenWithName(QNAME_WSA_ADDRESS);
+                    OMElement adE = null;
+                    for (; adI.hasNext();) {
+                        if (adE != null) {
+                            throw new IllegalArgumentException("Duplicate wsa:Address element");
+                        }
+                        adE = (OMElement)adI.next();
+                        if (contract.getInterfaceContract().getCallbackInterface() != null)
{
+                            callbackAddress = adE.getText();
+                            if (callbackAddress.equals(AddressingConstants.Final.WSA_ANONYMOUS_URL))
{
+                                throw new IllegalArgumentException("Anonymous wsa:Address
passed for callback");
                             }
                         }
-
                     }
-                }
-            }
-        }
-        return conversationID;
-    }
+                    if (adE == null) {
+                        throw new IllegalArgumentException("Missing wsa:Address element");
+                    }
 
-    //FIXME: can we use the Axis2 addressing support for this?
-    /**
-     * @param inMC
-     * @return fromEPR
-     */
-    protected String getFromEPR(MessageContext inMC) {
-        String fromEPR = null;
-        if (contract instanceof RuntimeComponentService && contract.getInterfaceContract().getCallbackInterface()
!= null) {
-            SOAPHeader header = inMC.getEnvelope().getHeader();
-            if (header != null) {
-                Iterator<?> i = header.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
"From"));
-                for (; i.hasNext();) {
-                    Object a = i.next();
-                    if (a instanceof OMElement) {
-                        OMElement ao = (OMElement)a;
-                        for (Iterator<?> adI =
-                            ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
"Address")); adI
-                            .hasNext();) {
-                            OMElement adE = (OMElement)adI.next();
-                            fromEPR = adE.getText();
+                    // process optional ReferenceParameters element
+                    Iterator<?> rpI = ao.getChildrenWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+                    OMElement rpE = null;
+                    for (; rpI.hasNext();) {
+                        if (rpE != null) {
+                            throw new IllegalArgumentException("Duplicate wsa:ReferenceParameters
element");
+                        }
+                        rpE = (OMElement)rpI.next();
+                        Iterator<?> cidI = rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN);
+                        OMElement cidE = null;
+                        for (; cidI.hasNext();) {
+                            if (cidE != null) {
+                                throw new IllegalArgumentException("Duplicate SCA conversation
ID element");
+                            }
+                            cidE = (OMElement)cidI.next();
+                            if (isConversational()) {
+                                conversationID = cidE.getText();
+                            }
+                        }
+                        Iterator<?> cbidI = rpE.getChildrenWithName(Axis2BindingInvoker.CALLBACK_ID_REFPARM_QN);
+                        OMElement cbidE = null;
+                        for (; cbidI.hasNext();) {
+                            if (cbidE != null) {
+                                throw new IllegalArgumentException("Duplicate SCA callback
ID element");
+                            }
+                            cbidE = (OMElement)cbidI.next();
+                            if (contract.getInterfaceContract().getCallbackInterface() !=
null) {
+                                callbackID = cbidE.getText();
+                            }
                         }
                     }
+
                 }
             }
         }
-        return fromEPR;
-    }
-
-    public Object invokeTarget(Operation op,
-                               Object[] args,
-                               Object messageId,
-                               String conversationID,
-                               String callbackAddress) throws InvocationTargetException {
 
         Message requestMsg = messageFactory.createMessage();
-
-        if (messageId != null) {
-            requestMsg.setMessageID(messageId);
-        }
         requestMsg.setBody(args);
-
-        if (contract instanceof RuntimeComponentService)
-            requestMsg.setTo(((RuntimeComponentService)contract).getRuntimeWire(getBinding()).getTarget());
-        else
-            requestMsg.setTo(((RuntimeComponentReference)contract).getRuntimeWire(getBinding()).getTarget());
+        requestMsg.setTo(((RuntimeComponentService)contract).getRuntimeWire(getBinding()).getTarget());
         if (callbackAddress != null) {
             requestMsg.setFrom(new EndpointReferenceImpl(callbackAddress));
         }
+        if (callbackID != null) {
+            requestMsg.setCorrelationID(callbackID);
+        }
+        if (conversationID != null) {
+            requestMsg.setConversationID(conversationID);
+        }
 
-        Message workContext = ThreadMessageContext.getMessageContext();
-
-        ThreadMessageContext.setMessageContext(requestMsg);
+        Message workContext = ThreadMessageContext.setMessageContext(requestMsg);
         try {
-            if (isConversational() && conversationID != null) {
-                requestMsg.setConversationID(conversationID);
-            } else {
-                requestMsg.setConversationID(null);
-            }
-
             Message responseMsg = ((RuntimeComponentService)contract).getInvoker(getBinding(),
op).invoke(requestMsg);
             if (responseMsg.isFault()) {
                 throw new InvocationTargetException((Throwable)responseMsg.getBody());
             }
             return responseMsg.getBody();
-
         } finally {
             ThreadMessageContext.setMessageContext(workContext);
         }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceImpl.java
Sun Sep  2 23:39:28 2007
@@ -112,7 +112,11 @@
     }
 
     public RuntimeWire getRuntimeWire() {
-        return reference.getRuntimeWire(binding);
+        if (reference != null) {
+            return reference.getRuntimeWire(binding);
+        } else {
+            return null;
+        }
     }
     
     protected void bind(RuntimeWire wire) {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
Sun Sep  2 23:39:28 2007
@@ -48,7 +48,7 @@
 
     public void resolveTarget() {
         Message msgContext = ThreadMessageContext.getMessageContext();
-        wire = selectCallbackWire(msgContext, wires);
+        wire = selectCallbackWire(msgContext);
         if (wire == null) {
             //FIXME: need better exception
             throw new RuntimeException("No callback wire found for " + msgContext.getFrom().getURI());
@@ -69,7 +69,7 @@
         }
     }
 
-    public static RuntimeWire selectCallbackWire(Message msgContext, List<RuntimeWire>
wires) {
+    public RuntimeWire selectCallbackWire(Message msgContext) {
         EndpointReference from = msgContext.getFrom();
         if (from == null) {
             return null;

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
Sun Sep  2 23:39:28 2007
@@ -82,7 +82,7 @@
     public <T> T createCallbackProxy(Class<T> interfaze, final List<RuntimeWire>
wires) throws ProxyCreationException {
         Enhancer enhancer = new Enhancer();
         enhancer.setSuperclass(interfaze);
-        enhancer.setCallback(new CglibMethodInterceptor<T>(wires));
+        enhancer.setCallback(new CglibMethodInterceptor<T>(interfaze, wires));
         Object proxy = enhancer.create();
         return interfaze.cast(proxy);
     }
@@ -121,8 +121,9 @@
             invocationHandler = new JDKInvocationHandler(messageFactory, serviceRef);
         }
 
-        public CglibMethodInterceptor(List<RuntimeWire> wires) {
-            invocationHandler = new JDKCallbackInvocationHandler(messageFactory, wires);
+        public CglibMethodInterceptor(Class<T> interfaze, List<RuntimeWire> wires)
{
+            CallbackWireObjectFactory wireFactory = new CallbackWireObjectFactory(interfaze,
CglibProxyFactory.this, wires);
+            invocationHandler = new JDKCallbackInvocationHandler(messageFactory, wireFactory);
         }
 
         /**

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKCallbackInvocationHandler.java
Sun Sep  2 23:39:28 2007
@@ -40,11 +40,10 @@
  */
 public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
     private static final long serialVersionUID = -3350283555825935609L;
-    private transient List<RuntimeWire> wires;
 
-    public JDKCallbackInvocationHandler(MessageFactory messageFactory, List<RuntimeWire>
wires) {
-        super(messageFactory, (CallableReference<?>) null);
-        this.wires = wires;
+    public JDKCallbackInvocationHandler(MessageFactory messageFactory,
+                                        CallbackWireObjectFactory wireFactory) {
+        super(messageFactory, wireFactory);
         this.fixedWire = false;
     }
 
@@ -63,7 +62,7 @@
 
         // wire not pre-selected, so select a wire now to be used for the callback
         Message msgContext = ThreadMessageContext.getMessageContext();
-        RuntimeWire wire = CallbackWireObjectFactory.selectCallbackWire(msgContext, wires);
+        RuntimeWire wire = ((CallbackWireObjectFactory)callableReference).selectCallbackWire(msgContext);
         if (wire == null) {
             //FIXME: need better exception
             throw new RuntimeException("No callback wire found for " + msgContext.getFrom().getURI());
@@ -96,6 +95,7 @@
         }
         
         callbackID = msgContext.getCorrelationID();
+        ((CallbackWireObjectFactory)callableReference).attachCallbackID(callbackID);
         setEndpoint(msgContext.getFrom());
         
         

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java?rev=572238&r1=572237&r2=572238&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
Sun Sep  2 23:39:28 2007
@@ -67,7 +67,8 @@
 
     public <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire>
wires) throws ProxyCreationException {
         ClassLoader cl = interfaze.getClassLoader();
-        JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory,
wires);
+        CallbackWireObjectFactory wireFactory = new CallbackWireObjectFactory(interfaze,
this, wires);
+        JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory,
wireFactory);
         return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler));
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message