tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r564960 - in /incubator/tuscany/java/sca/modules: binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/ binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/ binding-ws/src/main/java/org/apache/tuscany/sca/bindin...
Date Sat, 11 Aug 2007 19:47:21 GMT
Author: antelder
Date: Sat Aug 11 12:47:19 2007
New Revision: 564960

URL: http://svn.apache.org/viewvc?view=rev&rev=564960
Log:
TUSCANY-1496, apply patch from Simon Nash for support for some more advanced callback use cases and some code clean up

Modified:
    incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2OneWayBindingInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
    incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
    incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.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/DefaultProxyFactoryExtensionPoint.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/JDKInvocationHandler.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/CglibProxyFactory.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java

Modified: incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/RuntimeSCAServiceBindingProvider.java Sat Aug 11 12:47:19 2007
@@ -39,7 +39,6 @@
 public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider2 {
 
     private RuntimeComponentService service;
-    private boolean started = false;
 
     public RuntimeSCAServiceBindingProvider(RuntimeComponent component,
                                             RuntimeComponentService service,
@@ -56,39 +55,10 @@
     }
 
     public Invoker createCallbackInvoker(Operation operation) {
-        return new RuntimeSCABindingInvoker();
+        throw new UnsupportedOperationException();
     }
 
     public void start() {
-        if (started) {
-            return;
-        } else {
-            started = true;
-        }
-        for (RuntimeWire sourceWire : service.getCallbackWires()) {
-            if (sourceWire.getTarget().getBinding() instanceof SCABinding) {
-                EndpointReference source = sourceWire.getSource();
-                if (source != null) {
-                    RuntimeComponentReference reference = (RuntimeComponentReference)source.getContract();
-                    if (reference != null) { // a hard-wired callback
-                        Binding refBinding = source.getBinding();
-                        RuntimeWire targetWire = reference.getRuntimeWire(refBinding);
-                        for (InvocationChain sourceChain : sourceWire.getCallbackInvocationChains()) {
-                            InvocationChain targetChain =
-                                reference.getCallbackInvocationChain(refBinding, sourceChain.getTargetOperation());
-                            if (targetChain != null) {
-                                ((Interceptor)sourceChain.getTailInvoker()).setNext(targetChain.getHeadInvoker());
-                                sourceChain.setTargetOperation(targetChain.getSourceOperation());
-                            } else {
-                                throw new RuntimeException(
-                                                           "Incompatible operations for source and target callback wires");
-                            }
-                        }
-                        sourceWire.getSource().setInterfaceContract(targetWire.getTarget().getInterfaceContract());
-                    }
-                }
-            }
-        }
     }
 
     public void stop() {

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/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/axis2/Axis2BindingInvoker.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java Sat Aug 11 12:47:19 2007
@@ -36,7 +36,6 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
 import org.apache.tuscany.sca.interfacedef.ConversationSequence;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.Message;
@@ -66,10 +65,8 @@
 
     public Message invoke(Message msg) {
         try {
-
-            Object resp = invokeTarget(msg.getBody(), msg.getConversationSequence(), msg.getConversationID());
+            Object resp = invokeTarget(msg);
             msg.setBody(resp);
-
         } catch (InvocationTargetException e) {
             msg.setFaultBody(e.getCause());
         } catch (Throwable e) {
@@ -79,12 +76,9 @@
         return msg;
     }
 
-    protected Object invokeTarget(final Object payload, final ConversationSequence sequence, String conversationId)
-        throws InvocationTargetException {
+    protected Object invokeTarget(Message msg) throws InvocationTargetException {
         try {
-
-            Object[] args = (Object[])payload;
-            OperationClient operationClient = createOperationClient(args, conversationId);
+            OperationClient operationClient = createOperationClient(msg);
 
             // ensure connections are tracked so that they can be closed by the reference binding
             MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
@@ -105,8 +99,9 @@
     }
 
     @SuppressWarnings("deprecation")
-    protected OperationClient createOperationClient(Object[] args, String conversationId) throws AxisFault {
+    protected OperationClient createOperationClient(Message msg) throws AxisFault {
         SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+        Object[] args = (Object[])msg.getBody();
         if (args != null && args.length > 0) {
             SOAPBody body = env.getBody();
             for (Object bc : args) {
@@ -124,6 +119,7 @@
         // Axis2 operationClients can not be shared so create a new one for each request
         OperationClient operationClient = serviceClient.createClient(wsdlOperationName);
 
+        String conversationId = msg.getConversationID();
         if (conversationId != null && conversationId.length() != 0) {
             EndpointReference fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
             fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId);
@@ -141,14 +137,18 @@
         }
 
         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) {
-            org.apache.tuscany.sca.runtime.EndpointReference ep = ThreadMessageContext.getMessageContext().getTo();
+            org.apache.tuscany.sca.runtime.EndpointReference ep = msg.getTo();
             if (ep != null) {
                 requestMC.setTo(new EndpointReference(ep.getURI()));
             } else {
                 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?

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2OneWayBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2OneWayBindingInvoker.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2OneWayBindingInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2OneWayBindingInvoker.java Sat Aug 11 12:47:19 2007
@@ -31,6 +31,7 @@
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.invocation.Message;
 
 public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker {
 
@@ -42,12 +43,9 @@
         super(serviceClient, wsdlOperationName, options, soapFactory);
     }
 
-    protected Object invokeTarget(final Object payload, final ConversationSequence sequence, String conversationId)
-                             throws InvocationTargetException {
+    protected Object invokeTarget(Message msg) throws InvocationTargetException {
         try {
-            Object[] args = (Object[]) payload;
-
-            OperationClient operationClient = createOperationClient(args, conversationId);
+            OperationClient operationClient = createOperationClient(msg);
 
             // ensure connections are tracked so that they can be closed by the reference binding
             MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/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/axis2/Axis2ReferenceBindingProvider.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java Sat Aug 11 12:47:19 2007
@@ -36,8 +36,6 @@
     private RuntimeComponentReference reference;
     private WebServiceBinding wsBinding;
     private Axis2ServiceClient axisClient;
-    private Axis2ServiceProvider axisProvider;
-    private WebServiceBinding callbackBinding;
 
     public Axis2ReferenceBindingProvider(RuntimeComponent component,
                                          RuntimeComponentReference reference,
@@ -50,7 +48,7 @@
 
         InterfaceContract contract = wsBinding.getBindingInterfaceContract();
         if (contract == null) {
-            contract = reference.getInterfaceContract().makeUnidirectional(wsBinding.isCallback());
+            contract = reference.getInterfaceContract().makeUnidirectional(false);
             if ((contract instanceof JavaInterfaceContract)) {
                 contract = Java2WSDLHelper.createWSDLInterfaceContract((JavaInterfaceContract)contract);
             }
@@ -58,75 +56,30 @@
         }
 
         // Set to use the Axiom data binding
-        if (contract.getInterface() != null) {
-            contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
-        }
-        if (contract.getCallbackInterface() != null) {
-            contract.getCallbackInterface().setDefaultDataBinding(OMElement.class.getName());
-        }
+        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
 
-        if (!wsBinding.isCallback()) {
-            // this is a forward binding, so look for a matching callback binding
-            if (reference.getCallback() != null) {
-                for (Binding binding : reference.getCallback().getBindings()) {
-                    if (binding instanceof WebServiceBinding) {
-                        // set the first compatible callback binding
-                        setCallbackBinding((WebServiceBinding)binding);
-                        continue;
-                    }
-                }
-            }
-        } else {
-            // this is a callback binding, so look for all matching forward binding
-            for (Binding binding : reference.getBindings()) {
-                if (reference.getBindingProvider(binding) instanceof Axis2ReferenceBindingProvider) {
-                    // set all compatible forward binding providers for this reference
-                    ((Axis2ReferenceBindingProvider)reference.getBindingProvider(binding))
-                        .setCallbackBinding(wsBinding);
+        // 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;
                 }
             }
         }
 
-        if (!wsBinding.isCallback()) {
-            axisClient =
-                new Axis2ServiceClient(component, reference, wsBinding, servletHost, messageFactory, callbackBinding);
-        } else {
-            // FIXME: need to support callbacks through self-references
-            // For now, don't create a callback service provider for a self-reference
-            // because this modifies the binding URI. This messes up the service callback
-            // wires because the self-reference has the same binding object as the service.
-            if (!reference.getName().startsWith("$self$.")) {
-                axisProvider = new Axis2ServiceProvider(component, reference, wsBinding, servletHost, messageFactory);
-            }
-        }
-    }
-
-    protected void setCallbackBinding(WebServiceBinding callbackBinding) {
-        if (this.callbackBinding == null) {
-            this.callbackBinding = callbackBinding;
-        }
+        axisClient =
+            new Axis2ServiceClient(component, reference, wsBinding, servletHost, messageFactory, callbackBinding);
     }
 
     public void start() {
-        if (!wsBinding.isCallback()) {
-            axisClient.start();
-        } else {
-            // FIXME: need to support callbacks through self-references
-            if (!reference.getName().startsWith("$self$.")) {
-                axisProvider.start();
-            }
-        }
+        axisClient.start();
     }
 
     public void stop() {
-        if (!wsBinding.isCallback()) {
-            axisClient.stop();
-        } else {
-            // FIXME: need to support callbacks through self-references
-            if (!reference.getName().startsWith("$self$.")) {
-                axisProvider.stop();
-            }
-        }
+        axisClient.stop();
     }
 
     public InterfaceContract getBindingInterfaceContract() {
@@ -147,9 +100,6 @@
     }
 
     public Invoker createInvoker(Operation operation) {
-        if (wsBinding.isCallback()) {
-            throw new RuntimeException("Cannot create invoker for a callback binding");
-        }
         return axisClient.createInvoker(operation);
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java Sat Aug 11 12:47:19 2007
@@ -33,7 +33,6 @@
 public class Axis2ServiceBindingProvider implements ServiceBindingProvider2 {
 
     private WebServiceBinding wsBinding;
-    private Axis2ServiceClient axisClient;
     private Axis2ServiceProvider axisProvider;
 
     public Axis2ServiceBindingProvider(RuntimeComponent component,
@@ -46,7 +45,7 @@
 
         InterfaceContract contract = wsBinding.getBindingInterfaceContract();
         if (contract == null) {
-            contract = service.getInterfaceContract().makeUnidirectional(wsBinding.isCallback());
+            contract = service.getInterfaceContract().makeUnidirectional(false);
             if ((contract instanceof JavaInterfaceContract)) {
                 contract = Java2WSDLHelper.createWSDLInterfaceContract((JavaInterfaceContract)contract);
             }
@@ -54,49 +53,17 @@
         }
 
         // Set to use the Axiom data binding
-        if (contract.getInterface() != null) {
-            contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
-        }
-        if (contract.getCallbackInterface() != null) {
-            contract.getCallbackInterface().setDefaultDataBinding(OMElement.class.getName());
-        }
+        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());
 
-        if (!wsBinding.isCallback()) {
-            axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost,
-                                                    messageFactory);
-        } else {
-            // pass null as last parameter because SCDL doesn't allow a callback callback binding
-            // to be specified for a callback binding, i.e., can't have the following:
-            // <service>
-            //   <binding.x/>
-            //   <callback>
-            //     <binding.y/>
-            //     <callback>
-            //       <binding.z/>
-            //     </callback>
-            //   </callback>
-            // </service>
-            // This means that you can't do a callback from a callback (at least not
-            // in s spec-compliant way).
-            axisClient = new Axis2ServiceClient(component, service, wsBinding, servletHost,
-                                                messageFactory, null);
-        }
+        axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory);
     }
 
     public void start() {
-        if (!wsBinding.isCallback()) {
-            axisProvider.start();                                          
-        } else {
-            axisClient.start();
-        }
+        axisProvider.start();                                          
     }
 
     public void stop() {
-        if (!wsBinding.isCallback()) {
-            axisProvider.stop();
-        } else {
-            axisClient.stop();
-        }
+        axisProvider.stop();
     }
 
     public InterfaceContract getBindingInterfaceContract() {
@@ -104,10 +71,7 @@
     }
 
     public Invoker createCallbackInvoker(Operation operation) {
-        if (!wsBinding.isCallback()) {
-            throw new RuntimeException("Cannot create callback invoker for a forward binding");
-        }
-        return axisClient.createInvoker(operation);
+        throw new UnsupportedOperationException();
     }
 
     public boolean supportsAsyncOneWayInvocation() {

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/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/axis2/Axis2ServiceClient.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java Sat Aug 11 12:47:19 2007
@@ -98,10 +98,13 @@
         QName serviceQName = wsBinding.getServiceName();
         String portName = wsBinding.getPortName();
 
-        // If no service is specified in the binding element,
-        // allow for WSDL that only contains a portType for the callback and
-        // not a service and port.  Synthesize a service and port using WSDL4J and
-        // add them to the wsdlDefinition to keep Axis happy.
+        // If no service is specified in the binding element, allow for WSDL that
+        // only contains a portType and not a service and port.  Synthesize a
+        // service and port using WSDL4J and add them to the wsdlDefinition to
+        // keep Axis happy.
+        //FIXME: it would be better to do this for all WSDLs to explictly control the
+        // service and port that Axis will use, rather than just hoping the user has
+        // placed a suitable service and/or port first in the WSDL.
         if (serviceQName == null && wsBinding.getBinding() != null) {
             QName bindingQName = wsBinding.getBindingName();
             Port port = wsdlDefinition.createPort();

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/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/axis2/Axis2ServiceProvider.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java Sat Aug 11 12:47:19 2007
@@ -67,9 +67,6 @@
     private ConfigurationContext configContext;
 
     // TODO: what to do about the base URI?
-    //FIXME: changed from 8080 to 8085 as a hack to work around current limitation that
-    // the base URI must be the same for all servlet mappings in a single ServletHost.
-    // It appears that the code in both http-tomcat and http-jetty has this restriction.
     // 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.
     private static final String BASE_URI = "http://localhost:8085/";
@@ -184,13 +181,8 @@
         }
 
         // for service bindings with multiple services, the default binding URI is the binding name
-        // for callback reference bindings, add a prefix "$callback$." to ensure uniqueness
-        if (bindingURI == null && (wsBinding.isCallback() || component.getServices().size() > 1)) {
-            if (!wsBinding.isCallback()) {
-                bindingURI = URI.create(wsBinding.getName());
-            } else {
-                bindingURI = URI.create("$callback$." + wsBinding.getName());
-            }
+        if (bindingURI == null && component.getServices().size() > 1) {
+            bindingURI = URI.create(wsBinding.getName());
         }
 
         // add any relative binding URI
@@ -311,9 +303,7 @@
 
     protected Operation getOperation(AxisOperation axisOp) {
         String operationName = axisOp.getName().getLocalPart();
-        Interface iface =
-            wsBinding.isCallback() ? wsBinding.getBindingInterfaceContract().getCallbackInterface() : wsBinding
-                .getBindingInterfaceContract().getInterface();
+        Interface iface = wsBinding.getBindingInterfaceContract().getInterface();
         for (Operation op : iface.getOperations()) {
             if (op.getName().equalsIgnoreCase(operationName)) {
                 return op;
@@ -399,11 +389,11 @@
         requestMsg.setBody(args);
 
         if (contract instanceof RuntimeComponentService)
-            requestMsg.setFrom(((RuntimeComponentService)contract).getRuntimeWire(wsBinding).getSource());
+            requestMsg.setTo(((RuntimeComponentService)contract).getRuntimeWire(wsBinding).getTarget());
         else
-            requestMsg.setFrom(((RuntimeComponentReference)contract).getRuntimeWire(wsBinding).getSource());
+            requestMsg.setTo(((RuntimeComponentReference)contract).getRuntimeWire(wsBinding).getTarget());
         if (callbackAddress != null) {
-            requestMsg.setTo(new EndpointReferenceImpl(callbackAddress));
+            requestMsg.setFrom(new EndpointReferenceImpl(callbackAddress));
         }
 
         Message workContext = ThreadMessageContext.getMessageContext();
@@ -416,13 +406,7 @@
                 requestMsg.setConversationID(null);
             }
 
-            Message responseMsg =
-                contract instanceof RuntimeComponentService ? ((RuntimeComponentService)contract).getInvoker(wsBinding,
-                                                                                                             op)
-                    .invoke(requestMsg) : ((RuntimeComponentReference)contract).getCallbackInvocationChain(wsBinding,
-                                                                                                           op)
-                    .getHeadInvoker().invoke(requestMsg);
-
+            Message responseMsg = ((RuntimeComponentService)contract).getInvoker(wsBinding, op).invoke(requestMsg);
             if (responseMsg.isFault()) {
                 throw new InvocationTargetException((Throwable)responseMsg.getBody());
             }
@@ -434,11 +418,7 @@
     }
 
     public boolean isConversational() {
-        if (!wsBinding.isCallback()) {
-            return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
-        } else {
-            return wsBinding.getBindingInterfaceContract().getCallbackInterface().isConversational();
-        }
+        return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java Sat Aug 11 12:47:19 2007
@@ -22,7 +22,7 @@
 import javax.wsdl.Service;
 import javax.xml.namespace.QName;
 
-import org.apache.tuscany.sca.assembly.CallbackBinding;
+import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
 
@@ -32,7 +32,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public interface WebServiceBinding extends CallbackBinding {
+public interface WebServiceBinding extends Binding {
 
     /**
      * Sets the WSDL location. 

Modified: incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java Sat Aug 11 12:47:19 2007
@@ -43,7 +43,6 @@
 public class WebServiceBindingImpl implements WebServiceBinding {
     private String name;
     private String uri;
-    private boolean isCallback;
     private List<PolicySet> policySets = new ArrayList<PolicySet>();
     private List<Intent> requiredIntents = new ArrayList<Intent>();
     private boolean unresolved;
@@ -89,14 +88,6 @@
 
     public void setURI(String uri) {
         this.uri = uri;
-    }
-
-    public boolean isCallback() {
-        return isCallback;
-    }
-
-    public void setCallback(boolean isCallback) {
-        this.isCallback = isCallback;
     }
 
     public List<Intent> getRequiredIntents() {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/CallableReferenceImpl.java Sat Aug 11 12:47:19 2007
@@ -31,7 +31,7 @@
  * @version $Rev$ $Date$
  * @param <B> the type of the business interface
  */
-public abstract class CallableReferenceImpl<B> implements CallableReference<B> {
+public class CallableReferenceImpl<B> implements CallableReference<B> {
     private final Class<B> businessInterface;
     private final ObjectFactory<B> factory;
 

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/ComponentContextImpl.java Sat Aug 11 12:47:19 2007
@@ -19,6 +19,7 @@
 package org.apache.tuscany.sca.core.component;
 
 import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.ComponentContext;
 import org.osoa.sca.RequestContext;
@@ -33,10 +34,13 @@
 public class ComponentContextImpl implements ComponentContext {
     private final ComponentContextProvider component;
     private final RequestContextFactory requestContextFactory;
+    private final ProxyFactory proxyService;
 
-    public ComponentContextImpl(ComponentContextProvider component, RequestContextFactory requestContextFactory) {
+    public ComponentContextImpl(ComponentContextProvider component, RequestContextFactory requestContextFactory,
+                                ProxyFactory proxyService) {
         this.component = component;
         this.requestContextFactory = requestContextFactory;
+        this.proxyService = proxyService;
     }
 
     public String getURI() {
@@ -94,7 +98,7 @@
         if (requestContextFactory != null) {
             return requestContextFactory.createRequestContext();
         } else {
-            return new RequestContextImpl();
+            return new RequestContextImpl(proxyService);
         }
     }
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/component/RequestContextImpl.java Sat Aug 11 12:47:19 2007
@@ -18,14 +18,19 @@
  */
 package org.apache.tuscany.sca.core.component;
 
+import java.util.List;
 import javax.security.auth.Subject;
 
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+import org.apache.tuscany.sca.factory.ObjectFactory;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.RequestContext;
 import org.osoa.sca.ServiceReference;
@@ -35,7 +40,10 @@
  */
 public class RequestContextImpl implements RequestContext {
 
-    public RequestContextImpl() {
+    private ProxyFactory proxyService;
+
+    public RequestContextImpl(ProxyFactory proxyService) {
+        this.proxyService = proxyService;
     }
 
     public Subject getSecuritySubject() {
@@ -59,14 +67,17 @@
     }
 
     public <CB> CallableReference<CB> getCallbackReference() {
-        EndpointReference from = ThreadMessageContext.getMessageContext().getFrom();
-        RuntimeComponentReference service = (RuntimeComponentReference) from.getContract();
-        RuntimeComponent component = (RuntimeComponent) from.getComponent();
-        JavaInterface javaInterface = (JavaInterface) service.getInterfaceContract().getCallbackInterface();
-        if(javaInterface==null) {
+        EndpointReference to = ThreadMessageContext.getMessageContext().getTo();
+        RuntimeComponentService service = (RuntimeComponentService) to.getContract();
+        RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
+        if (callbackReference == null) {
             return null;
         }
-        // FIXME: Creating a self-ref is probably not right
-        return (CallableReference<CB>) component.createSelfReference(javaInterface.getCallbackClass());
+        JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
+        Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
+        List<RuntimeWire> wires = callbackReference.getRuntimeWires();
+        CallbackWireObjectFactory factory = new CallbackWireObjectFactory(javaClass, proxyService, wires);
+        factory.resolveTarget();
+        return (CallableReference<CB>) new CallableReferenceImpl<CB>(javaClass, (ObjectFactory<CB>)factory);
     }
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/AbstractInvocationHandler.java Sat Aug 11 12:47:19 2007
@@ -44,6 +44,7 @@
     protected ConversationImpl conversation;
     private boolean conversationStarted;
     private MessageFactory messageFactory;
+    private EndpointReference endpoint;
 
     protected AbstractInvocationHandler(MessageFactory messageFactory, boolean conversational) {
         this.conversational = conversational;
@@ -53,12 +54,15 @@
     public void setConversation(Conversation conversation){
         this.conversation = (ConversationImpl)conversation;
     }
+
+    public void setEndpoint(EndpointReference endpoint){
+        this.endpoint = endpoint;
+    }
     
     protected Object invoke(InvocationChain chain, Object[] args, RuntimeWire wire) throws Throwable {
 
         Message msgContext = ThreadMessageContext.getMessageContext();
         Object  msgContextConversationId = msgContext.getConversationID();
-        EndpointReference epTo = msgContext.getTo();   
         
         Message msg = messageFactory.createMessage();
                
@@ -134,11 +138,12 @@
         if (wire.getSource() != null) {
             msg.setFrom(wire.getSource().getCallbackEndpoint());
         }
-        if (epTo != null) {
-            msg.setTo(epTo);
+        if (endpoint != null) {
+            msg.setTo(endpoint);
         } else {
             msg.setTo(wire.getTarget());
         }
+
         ThreadMessageContext.setMessageContext(msg);
         try {
             // dispatch the wire down the chain and get the response

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?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- 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 Sat Aug 11 12:47:19 2007
@@ -18,10 +18,15 @@
  */
 package org.apache.tuscany.sca.core.invocation;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.factory.ObjectCreationException;
 import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
 
 /**
@@ -33,6 +38,8 @@
     private ProxyFactory proxyFactory;
     private Class<?> interfaze;
     private List<RuntimeWire> wires;
+    private RuntimeWire resolvedWire;
+    private EndpointReference resolvedEndpoint;
 
     public CallbackWireObjectFactory(Class<?> interfaze, ProxyFactory proxyService, List<RuntimeWire> wires) {
         this.interfaze = interfaze;
@@ -40,8 +47,70 @@
         this.wires = wires;
     }
 
+    public void resolveTarget() {
+        Message msgContext = ThreadMessageContext.getMessageContext();
+        resolvedWire = selectCallbackWire(msgContext, wires);
+        if (resolvedWire == null) {
+            //FIXME: need better exception
+            throw new RuntimeException("No callback wire found for " + msgContext.getFrom().getURI());
+        }
+        resolvedEndpoint = msgContext.getFrom();
+    }
+
     public Object getInstance() throws ObjectCreationException {
-        return proxyFactory.createCallbackProxy(interfaze, wires);
+        if (resolvedWire != null) {
+            // wire and endpoint already resolved, so return a pre-wired proxy
+            return proxyFactory.createProxy(interfaze, resolvedWire, null, resolvedEndpoint);
+        } else {
+            // wire not yet selected, so return a proxy that resolves the target dynamically
+            return proxyFactory.createCallbackProxy(interfaze, wires);
+        }
+     }
+    public static RuntimeWire selectCallbackWire(Message msgContext, List<RuntimeWire> wires) {
+        EndpointReference from = msgContext.getFrom();
+        if (from == null) {
+            return null;
+        }
+
+        //FIXME: need a cache for better performance.  This requires making this
+        // method non-static, which means changing the signature of createCallbackProxy().
+
+        // first choice is wire with matching desination endpoint
+        for (RuntimeWire wire : wires) {
+            if (from.getURI().equals(wire.getTarget().getURI())) {
+                return wire;
+            }
+        }
+
+        // no exact match, so find callback binding with same name as service binding
+        EndpointReference to = msgContext.getTo();
+        if (to == null) {
+            //FIXME: need better exception
+            throw new RuntimeException("Destination for forward call is not available");
+        }
+        for (RuntimeWire wire : wires) {
+            if (wire.getSource().getBinding().getName().equals(to.getBinding().getName())) {
+                //FIXME: need better way to represent dynamic wire
+                if (wire.getTarget().getURI().equals("/")) {  // dynamic wire
+                    return wire;
+                }
+                //FIXME: no dynamic wire, so should attempt to create a static wire 
+            }
+        }
+
+        // no match so far, so find callback binding with same type as service binding
+        for (RuntimeWire wire : wires) {
+            if (wire.getSource().getBinding().getClass() == to.getBinding().getClass()) {
+                //FIXME: need better way to represent dynamic wire
+                if (wire.getTarget().getURI().equals("/")) {  // dynamic wire
+                    return wire;
+                }
+                //FIXME: no dynamic wire, so should attempt to create a static wire 
+            }
+        }
+
+        // no suitable callback wire was found
+        return null;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java Sat Aug 11 12:47:19 2007
@@ -24,6 +24,7 @@
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
 import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.Conversation;
@@ -111,6 +112,20 @@
             return interfaceFactory.createProxy(interfaze, wire, conversation);
         } else {
             return classFactory.createProxy(interfaze, wire, conversation);
+        }
+    }
+
+    /**
+     * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createProxy(java.lang.Class,
+     *      org.apache.tuscany.sca.runtime.RuntimeWire,
+     *      org.osoa.sca.Conversation)
+     */
+    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation, EndpointReference endpoint)
+        throws ProxyCreationException {
+        if (interfaze.isInterface()) {
+            return interfaceFactory.createProxy(interfaze, wire, conversation, endpoint);
+        } else {
+            return classFactory.createProxy(interfaze, wire, conversation, endpoint);
         }
     }
 

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?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- 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 Sat Aug 11 12:47:19 2007
@@ -30,6 +30,7 @@
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
 import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
 import org.apache.tuscany.sca.invocation.MessageFactory;
 import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
@@ -43,25 +44,18 @@
  */
 public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
     private static final long serialVersionUID = -3350283555825935609L;
-    private transient Map<String, RuntimeWire> wires;
+    private transient List<RuntimeWire> wires;
 
     /**
      * Constructor used for deserialization only
      */
     public JDKCallbackInvocationHandler(MessageFactory messageFactory) {
         super(messageFactory, null, null);
-        wires = new HashMap<String, RuntimeWire>();
     }
 
-    public JDKCallbackInvocationHandler(MessageFactory messageFactory, List<RuntimeWire> wireList) {
+    public JDKCallbackInvocationHandler(MessageFactory messageFactory, List<RuntimeWire> wires) {
         super(messageFactory, null, null);
-        this.wires = new HashMap<String, RuntimeWire>();
-        for (RuntimeWire wire : wireList) {
-            wires.put(wire.getTarget().getURI(), wire);
-            InterfaceContract contract = wire.getTarget().getInterfaceContract();
-            this.conversational = contract.getInterface().isConversational();
-            // TODO: doesn't work if mix conv. and non-conv, should never happen 
-        }
+        this.wires = wires;
     }
 
     @SuppressWarnings( {"unchecked"})
@@ -75,16 +69,18 @@
             return hashCode();
             // TODO beter hash algorithm
         }
-        EndpointReference from = ThreadMessageContext.getMessageContext().getFrom();
-        RuntimeWire wire = null;
-        if (from != null) {
-            wire = wires.get(from.getURI());
-        }
+
+        // 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);
         if (wire == null) {
             //FIXME: need better exception
-            throw new RuntimeException("Wire for callback cannot be found");
+            throw new RuntimeException("No callback wire found for " + msgContext.getFrom().getURI());
         }
+        setConversational(wire);
+        setEndpoint(msgContext.getFrom());
 
+        //FIXME: can we use the same code as JDKInvocationHandler to select the chain? 
         InvocationChain chain = getInvocationChain(method, wire);
         if (chain == null) {
             throw new IllegalArgumentException("No matching operation is found: " + method);

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java Sat Aug 11 12:47:19 2007
@@ -42,11 +42,11 @@
         super(messageFactory, false);
         this.wire = wire;
         if (wire != null) {
-            init(proxyInterface, wire);
+            setConversational(wire);
         }
     }
 
-    private void init(Class<?> interfaze, RuntimeWire wire) {
+    protected void setConversational(RuntimeWire wire) {
         InterfaceContract contract = wire.getSource().getInterfaceContract();
         this.conversational = contract.getInterface().isConversational();
     }
@@ -65,6 +65,10 @@
             return equals(Proxy.getInvocationHandler(obj));
         } else if (Object.class.equals(method.getDeclaringClass()) && "hashCode".equals(method.getName())) {
             return hashCode();
+        }
+        if (wire == null) {
+            //FIXME: need better exception
+            throw new RuntimeException("Destination for callback is not known");
         }
         InvocationChain chain = getInvocationChain(method, wire);
         if (chain == null) {

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyService.java Sat Aug 11 12:47:19 2007
@@ -24,6 +24,7 @@
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
 import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.Conversation;
@@ -52,14 +53,20 @@
      * share conversation state so sets the conversaton object to null
      */
     public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
-        return createProxy(interfaze, wire, null);
+        return createProxy(interfaze, wire, null, null);
     }
     
     public <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation) throws ProxyCreationException {
+        return createProxy(interfaze, wire, conversation, null);
+    }
+    
+    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation, EndpointReference endpoint)
+                             throws ProxyCreationException {
         assert interfaze != null;
         assert wire != null;
         JDKInvocationHandler handler = new JDKInvocationHandler(messageFactory, interfaze, wire);
         handler.setConversation(conversation);
+        handler.setEndpoint(endpoint);
         ClassLoader cl = interfaze.getClassLoader();
         return interfaze.cast(Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler));
     }    

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java Sat Aug 11 12:47:19 2007
@@ -20,6 +20,7 @@
 
 import java.util.List;
 
+import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.Conversation;
@@ -36,7 +37,8 @@
      * Creates a Java proxy for the given wire
      *
      * @param interfaze the interface the proxy implements
-     * @param wire      the wire to proxy @return the proxy
+     * @param wire      the wire to proxy
+     * @return the proxy
      * @throws ProxyCreationException
      */
     <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException;
@@ -46,10 +48,27 @@
      * a conversation object to represent conversational state
      *
      * @param interfaze the interface the proxy implements
-     * @param wire      the wire to proxy @return the proxy
+     * @param wire      the wire to proxy
+     * @param conversation the conversation object
+     * @return the proxy
      * @throws ProxyCreationException
      */
     <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation) throws ProxyCreationException;
+
+    /**
+     * Creates a Java proxy for the given wire and accepts
+     * a conversation object to represent conversational state and an
+     * endpoint that should be used instead of the wire's target endpoint
+     *
+     * @param interfaze the interface the proxy implements
+     * @param wire      the wire to proxy
+     * @param conversation the conversation object
+     * @param endpoint the target endpoint
+     * @return the proxy
+     * @throws ProxyCreationException
+     */
+    <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation, EndpointReference endpoint)
+                     throws ProxyCreationException;
 
     /**
      * Creates a Java proxy for the service contract callback

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/CompositeActivatorImpl.java Sat Aug 11 12:47:19 2007
@@ -63,6 +63,8 @@
  */
 public class CompositeActivatorImpl implements CompositeActivator {
 
+    private String CALLBACK_PREFIX = "$callback$.";
+
     private final InterfaceContractMapper interfaceContractMapper;
     private final ScopeRegistry scopeRegistry;
     private final WorkScheduler workScheduler;
@@ -400,7 +402,7 @@
      * @param binding
      * @return
      */
-    private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding, boolean isCallback) {
+    private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) {
         InterfaceContract interfaceContract = reference.getInterfaceContract();
         ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
         if (provider != null) {
@@ -409,7 +411,7 @@
                 interfaceContract = bindingContract;
             }
         }
-        return interfaceContract.makeUnidirectional(isCallback);
+        return interfaceContract.makeUnidirectional(false);
     }
 
     /**
@@ -444,8 +446,7 @@
                          binding,
                          targetComponentService,
                          targetComponent,
-                         targetBinding,
-                         false);
+                         targetBinding);
 
         // if static forward wire (not from self-reference), try to create a static callback wire 
         if (targetComponentService != null && !reference.getName().startsWith("$self$.")) {
@@ -480,8 +481,7 @@
                                      callbackBinding,
                                      reference.getCallbackService(),
                                      component,
-                                     callbackServiceBinding,
-                                     false);
+                                     callbackServiceBinding);
                 } else {
                     // no end-to-end match, so do not create a static callback wire
                 }
@@ -511,29 +511,40 @@
      * @param referenceBinding
      * @param service
      * @param serviceBinding
-     * @param isCallback
      */
     private RuntimeWire addReferenceWire(ComponentReference reference,
                                          Component refComponent,
                                          Binding refBinding,
                                          ComponentService service,
                                          Component serviceComponent,
-                                         Binding serviceBinding,
-                                         boolean isCallback) {
+                                         Binding serviceBinding) {
         RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
-        InterfaceContract bindingContract = getInterfaceContract(reference, refBinding, isCallback);
+        InterfaceContract bindingContract = getInterfaceContract(reference, refBinding);
     
         // Use the interface contract of the reference on the component type
         Reference componentTypeRef = reference.getReference();
         InterfaceContract sourceContract =
             componentTypeRef == null ? reference.getInterfaceContract() : componentTypeRef.getInterfaceContract();
-        sourceContract = sourceContract.makeUnidirectional(isCallback);
+        sourceContract = sourceContract.makeUnidirectional(false);
 
         EndpointReference wireSource =
             new EndpointReferenceImpl((RuntimeComponent)refComponent, reference, refBinding, sourceContract);
         ComponentService callbackService = reference.getCallbackService();
         if (callbackService != null) {
-            Binding callbackBinding = callbackService.getBinding(refBinding.getClass());
+            // select a reference callback binding to pass with invocations on this wire
+            Binding callbackBinding = null;
+            for (Binding binding : callbackService.getBindings()) {
+                // first look for a callback binding whose name matches the reference binding name
+                if (binding.getName().equals(refBinding.getName()) ||
+                    binding.getName().equals(CALLBACK_PREFIX + refBinding.getName())) {
+                    callbackBinding = binding;
+                    break;
+                }
+            }
+            // if no callback binding found, try again based on reference binding type
+            if (callbackBinding == null) {
+                callbackBinding = callbackService.getBinding(refBinding.getClass());
+            }
             InterfaceContract callbackContract = callbackService.getInterfaceContract();
             EndpointReference callbackEndpoint = new EndpointReferenceImpl(
                     (RuntimeComponent)refComponent, callbackService, callbackBinding, callbackContract);
@@ -544,28 +555,14 @@
             new EndpointReferenceImpl((RuntimeComponent)serviceComponent, service, serviceBinding, bindingContract);
     
         RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
-        if (!isCallback) {
-            for (Operation operation : sourceContract.getInterface().getOperations()) {
-                Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
-                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
-                if (operation.isNonBlocking()) {
-                    addNonBlockingInterceptor(reference, refBinding, chain);
-                }
-                addBindingInterceptor(reference, refBinding, chain, operation);
-                wire.getInvocationChains().add(chain);
-            }
-        } else {
-            for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
-                Operation targetOperation =
-                    interfaceContractMapper.map(sourceContract.getCallbackInterface(), operation);
-                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
-                if (!reference.getName().startsWith("$self$.")) {
-                    addImplementationInterceptor(refComponent, null, chain, targetOperation, true);
-                } else {
-                    //FIXME: need to invoke the callback object
-                }
-                wire.addCallbackInvocationChain(chain);
+        for (Operation operation : sourceContract.getInterface().getOperations()) {
+            Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
+            InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+            if (operation.isNonBlocking()) {
+                addNonBlockingInterceptor(reference, refBinding, chain);
             }
+            addBindingInterceptor(reference, refBinding, chain, operation);
+            wire.getInvocationChains().add(chain);
         }
         runtimeRef.getRuntimeWires().add(wire);
         return wire;
@@ -589,7 +586,7 @@
      * @param binding
      * @return
      */
-    private InterfaceContract getInterfaceContract(ComponentService service, Binding binding, boolean isCallback) {
+    private InterfaceContract getInterfaceContract(ComponentService service, Binding binding) {
         InterfaceContract interfaceContract = service.getInterfaceContract();
 
         ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
@@ -599,7 +596,7 @@
                 interfaceContract = bindingContract;
             }
         }
-        return interfaceContract.makeUnidirectional(isCallback);
+        return interfaceContract.makeUnidirectional(false);
     }
 
     /**
@@ -613,15 +610,7 @@
         if (!(service instanceof RuntimeComponentService)) {
             return;
         }
-        RuntimeWire wire = addServiceWire(service, component, binding, null, null, binding, false);
-    
-        //FIXME: need to decide if this is the best way to create the source URI
-        // The source URI is used by JDKCallbackInvocationHandler to find the callback wire
-        // corresponding to the forward wire that was used to invoke the service.
-        // This only works if the source URI is the same for the matched pair of forward and
-        // callback wires.  The binding name seems a reasonable key to use for this match,
-        // as it allows the user to control which callback binding should be selected.
-        //wire.getSource().setURI(binding.getName());
+        RuntimeWire wire = addServiceWire(service, component, binding, null, null, binding);
     }
 
     /**
@@ -646,15 +635,13 @@
      * @param serviceBinding
      * @param reference
      * @param referenceBinding
-     * @param isCallback
      */
     private RuntimeWire addServiceWire(ComponentService service,
                                        Component serviceComponent,
                                        Binding serviceBinding,
                                        ComponentReference reference,
                                        Component refComponent,
-                                       Binding refBinding,
-                                       boolean isCallback) {
+                                       Binding refBinding) {
         RuntimeComponentService runtimeService = (RuntimeComponentService)service;
     
         // FIXME: [rfeng] We might need a better way to get the impl interface contract
@@ -662,9 +649,9 @@
         if (targetService == null) {
             targetService = service;
         }
-        InterfaceContract targetContract = targetService.getInterfaceContract().makeUnidirectional(isCallback);
+        InterfaceContract targetContract = targetService.getInterfaceContract().makeUnidirectional(false);
 
-        InterfaceContract sourceContract = getInterfaceContract(service, serviceBinding, isCallback);
+        InterfaceContract sourceContract = getInterfaceContract(service, serviceBinding);
     
         EndpointReference wireSource =
             new EndpointReferenceImpl((RuntimeComponent)refComponent, (RuntimeComponentReference)reference, refBinding,
@@ -676,29 +663,13 @@
     
         RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
     
-        if (sourceContract.getInterface() != null) {
-            for (Operation operation : sourceContract.getInterface().getOperations()) {
-                Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
-                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
-                addImplementationInterceptor(serviceComponent, service, chain, targetOperation, false);
-                wire.getInvocationChains().add(chain);
-            }
-            runtimeService.getRuntimeWires().add(wire);
-        }
-    
-        if (sourceContract.getCallbackInterface() != null) {
-            for (Operation operation : targetContract.getCallbackInterface().getOperations()) {
-                Operation targetOperation =
-                    interfaceContractMapper.map(sourceContract.getCallbackInterface(), operation);
-                InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
-                if (operation.isNonBlocking()) {
-                    addNonBlockingCallbackInterceptor(service, serviceBinding, chain);
-                }
-                addBindingCallbackInterceptor(service, serviceBinding, chain, operation);
-                wire.addCallbackInvocationChain(chain);
-            }
-            runtimeService.getCallbackWires().add(wire);
+        for (Operation operation : sourceContract.getInterface().getOperations()) {
+            Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
+            InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
+            addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
+            wire.getInvocationChains().add(chain);
         }
+        runtimeService.getRuntimeWires().add(wire);
     
         return wire;
     }
@@ -712,7 +683,6 @@
         RuntimeComponentService runtimeService = (RuntimeComponentService)service;
 
         runtimeService.getRuntimeWires().clear();
-        runtimeService.getCallbackWires().clear();
     }
 
     /**
@@ -722,21 +692,15 @@
      * @param service
      * @param chain
      * @param operation
-     * @param isCallback
      */
     private void addImplementationInterceptor(Component component,
                                               ComponentService service,
                                               InvocationChain chain,
-                                              Operation operation,
-                                              boolean isCallback) {
+                                              Operation operation) {
         ImplementationProvider provider = ((RuntimeComponent)component).getImplementationProvider();
         if (provider != null) {
             Invoker invoker = null;
-            if (!isCallback) {
-                invoker = provider.createInvoker((RuntimeComponentService)service, operation);
-            } else {
-                invoker = provider.createCallbackInvoker(operation);
-            }
+            invoker = provider.createInvoker((RuntimeComponentService)service, operation);
             chain.addInvoker(invoker);
         }
     }
@@ -793,55 +757,6 @@
             }
             if (!supportsAsyncOneWayInvocation) {
                 chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
-            }
-        }
-    }
-
-    /**
-     * Add a non-blocking interceptor if the service binding needs it
-     * 
-     * @param service
-     * @param binding
-     * @param chain
-     */
-    private void addNonBlockingCallbackInterceptor(ComponentService service, Binding binding, InvocationChain chain) {
-        ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
-        if (provider != null) {
-            boolean supportsAsyncOneWayInvocation = false;
-            if (provider instanceof ServiceBindingProvider2) {
-                supportsAsyncOneWayInvocation = ((ServiceBindingProvider2)provider).supportsAsyncOneWayInvocation();
-            } else {
-                // must be an old provider that doesn't have this method
-            }
-            if (!supportsAsyncOneWayInvocation) {
-                chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
-            }
-        }
-    }
-
-    /**
-     * Add the interceptor for callbacks through a binding
-     * 
-     * @param component
-     * @param service
-     * @param binding
-     * @param chain
-     * @param operation
-     */
-    private void addBindingCallbackInterceptor(ComponentService service,
-                                               Binding binding,
-                                               InvocationChain chain,
-                                               Operation operation) {
-        ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
-        if (provider != null) {
-            Invoker invoker = null;
-            if (provider instanceof ServiceBindingProvider2) {
-                invoker = ((ServiceBindingProvider2)provider).createCallbackInvoker(operation);
-            } else {
-                // must be an old provider that does not support callbacks
-            }
-            if (invoker != null) {
-                chain.addInvoker(invoker);
             }
         }
     }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java Sat Aug 11 12:47:19 2007
@@ -20,6 +20,7 @@
 
 import org.apache.tuscany.sca.context.RequestContextFactory;
 import org.apache.tuscany.sca.core.component.RequestContextImpl;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.factory.ObjectCreationException;
 import org.apache.tuscany.sca.factory.ObjectFactory;
 import org.osoa.sca.RequestContext;
@@ -33,16 +34,22 @@
  */
 public class RequestContextObjectFactory implements ObjectFactory<RequestContext> {
     private RequestContextFactory factory;
+    private ProxyFactory proxyService;
 
     public RequestContextObjectFactory(RequestContextFactory factory) {
+        this(factory, null);
+    }
+
+    public RequestContextObjectFactory(RequestContextFactory factory, ProxyFactory proxyService) {
         this.factory = factory;
+        this.proxyService = proxyService;
     }
 
     public RequestContext getInstance() throws ObjectCreationException {
         if (factory != null) {
             return factory.createRequestContext();
         } else {
-            return new RequestContextImpl();
+            return new RequestContextImpl(proxyService);
         }
     }
 }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/CglibProxyFactory.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/CglibProxyFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/CglibProxyFactory.java Sat Aug 11 12:47:19 2007
@@ -35,6 +35,7 @@
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl;
 import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeWire;
 import org.osoa.sca.CallableReference;
 import org.osoa.sca.Conversation;
@@ -60,15 +61,19 @@
     }
 
     public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
-        return createProxy(interfaze, wire, null);
+        return createProxy(interfaze, wire, null, null);
     }
 
+    public <T> T createProxy(Class<T> interfaze, RuntimeWire wire, Conversation conversation) throws ProxyCreationException {
+        return createProxy(interfaze, wire, conversation, null);
+    }
+    
     /**
      * create the proxy with cglib. use the same JDKInvocationHandler as
      * JDKProxyService.
      */
-    public <T> T createProxy(final Class<T> interfaze, final RuntimeWire wire, final Conversation conversation)
-        throws ProxyCreationException {
+    public <T> T createProxy(final Class<T> interfaze, final RuntimeWire wire, final Conversation conversation,
+                             final EndpointReference endpoint) throws ProxyCreationException {
         Enhancer enhancer = new Enhancer();
         enhancer.setSuperclass(interfaze);
         enhancer.setCallback(new MethodInterceptor() {
@@ -76,6 +81,7 @@
                 throws Throwable {
                 JDKInvocationHandler invocationHandler = new JDKInvocationHandler(messageFactory, interfaze, wire);
                 invocationHandler.setConversation(conversation);
+                invocationHandler.setEndpoint(endpoint);
                 Object result = invocationHandler.invoke(proxy, method, args);
                 return result;
             }

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentInfo.java Sat Aug 11 12:47:19 2007
@@ -102,14 +102,14 @@
                              RequestContextFactory requestContextFactory) {
         super();
         this.configuration = configuration;
+        this.proxyService = configuration.getProxyFactory();
         if (componentContextFactory != null) {
             this.componentContext = componentContextFactory.createComponentContext(component, requestContextFactory);
         } else {
-            this.componentContext = new ComponentContextImpl(this, requestContextFactory);
+            this.componentContext = new ComponentContextImpl(this, requestContextFactory, this.proxyService);
         }
         this.groupId = configuration.getGroupId();
         this.component = component;
-        this.proxyService = configuration.getProxyFactory();
         this.dataBindingRegistry = dataBindingExtensionPoint;
         this.propertyValueFactory = propertyValueObjectFactory;
         this.componentContextFactory = componentContextFactory;

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java?view=diff&rev=564960&r1=564959&r2=564960
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java Sat Aug 11 12:47:19 2007
@@ -100,14 +100,14 @@
             }
 
             componentInfo.configureProperties(component.getProperties());
-            handleResources(implementation);
+            handleResources(implementation, proxyService);
         } catch (Exception e) {
             throw new IllegalStateException(e);
         }
 
     }
 
-    private void handleResources(JavaImplementation componentType) {
+    private void handleResources(JavaImplementation componentType, ProxyFactory proxyService) {
         for (JavaResourceImpl resource : componentType.getResources().values()) {
             String name = resource.getName();
 
@@ -118,7 +118,7 @@
                 if (ComponentContext.class.equals(type)) {
                     objectFactory = new PojoComponentContextFactory(componentInfo);
                 } else if (RequestContext.class.equals(type)) {
-                    objectFactory = new RequestContextObjectFactory(requestContextFactory);
+                    objectFactory = new RequestContextObjectFactory(requestContextFactory, proxyService);
                 } else if (String.class.equals(type)) {
                     objectFactory = new PojoComponentNameFactory(componentInfo);
                 } else {



---------------------------------------------------------------------
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