From d56a64505d24516a9ec86d9eba72ad2adac00651 Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 8 Dec 2010 15:18:12 +0000 Subject: TUSCANY-3801 - Separate off the asyncy response invocation interfaces from the "process" methods I added as a convenience for sharing invoker implementation. Asl get rid of "throws" from Invocable git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043447 13f79535-47bb-0310-9956-ffa450edef68 --- .../provider/SCABindingAsyncResponseInvoker.java | 5 -- .../tuscany/sca/invocation/InterceptorAsync.java | 22 ++++++++ .../sca/invocation/InvokerAsyncRequest.java | 12 ----- .../sca/invocation/InvokerAsyncResponse.java | 11 ---- .../org/apache/tuscany/sca/runtime/Invocable.java | 3 +- .../core/assembly/impl/RuntimeEndpointImpl.java | 2 +- .../impl/RuntimeEndpointReferenceImpl.java | 2 +- .../sca/core/invocation/RuntimeInvoker.java | 60 ++++++---------------- .../impl/SampleAsyncResponseInvoker.java | 5 -- .../java/sampleasync/impl/SampleWSDLInvoker.java | 5 +- 10 files changed, 44 insertions(+), 83 deletions(-) (limited to 'sca-java-2.x') diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingAsyncResponseInvoker.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingAsyncResponseInvoker.java index d502cdd22c..240ba69d62 100644 --- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingAsyncResponseInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingAsyncResponseInvoker.java @@ -38,9 +38,4 @@ public class SCABindingAsyncResponseInvoker implements InvokerAsyncResponse { RuntimeEndpointReference epr = (RuntimeEndpointReference)msg.getFrom(); epr.invokeAsyncResponse(msg); } - - public Message processResponse(Message msg) { - // TODO Auto-generated method stub - return null; - } } \ No newline at end of file diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java index 50bcf13b04..806feccca2 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java @@ -37,4 +37,26 @@ public interface InterceptorAsync extends Interceptor, InvokerAsyncRequest, Invo */ InvokerAsyncResponse getPrevious(); + /** + * Process a request message. Provided so that the synchronous + * and asynchronous patterns can re-use the request message + * processing + * + * @param msg The request Message + * @return the processed message + * + */ + Message processRequest(Message msg); + + /** + * Process a response message. Provided so that the synchronous + * and asynchronous patterns can re-use the response message + * processing + * + * @param msg The request Message + * @return the processed message + * + */ + Message processResponse(Message msg); + } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncRequest.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncRequest.java index 5a53504ffb..48fad02b53 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncRequest.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncRequest.java @@ -36,16 +36,4 @@ public interface InvokerAsyncRequest { */ void invokeAsyncRequest(Message msg); - /** - * Process a request message. Provided so that the synchronous - * and asynchronous patterns can re-use the request message - * processing - * - * @param msg The request Message - * @return the processed message - * - */ - Message processRequest(Message msg); - - } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncResponse.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncResponse.java index 1de12638b6..7eeabb760e 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncResponse.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsyncResponse.java @@ -36,15 +36,4 @@ public interface InvokerAsyncResponse { */ void invokeAsyncResponse(Message msg); - /** - * Process a response message. Provided so that the synchronous - * and asynchronous patterns can re-use the response message - * processing - * - * @param msg The request Message - * @return the processed message - * - */ - Message processResponse(Message msg); - } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java index 9a936bf141..948063f480 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/Invocable.java @@ -136,8 +136,7 @@ public interface Invocable { * @return The ticket that can be used to identify this invocation * @throws InvocationTargetException */ - void invokeAsync(Operation operation, Message msg) throws Throwable; - // TODO - this shouldn't throw an exception + void invokeAsync(Operation operation, Message msg); /** * Asynchronously invoke an operation with a context message diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java index 26fc6722aa..e353af92e2 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java @@ -290,7 +290,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint return invoker.invoke(operation, msg); } - public void invokeAsync(Operation operation, Message msg) throws Throwable { + public void invokeAsync(Operation operation, Message msg){ msg.setOperation(operation); invoker.invokeAsync(msg); } diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java index a854e833ac..ad5c9124fa 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java @@ -243,7 +243,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen return invoker.invoke(operation, msg); } - public void invokeAsync(Operation operation, Message msg) throws Throwable { + public void invokeAsync(Operation operation, Message msg){ msg.setOperation(operation); invoker.invokeAsync(msg); } diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java index 6c9f13ff17..4b2e72ac6b 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java @@ -112,6 +112,12 @@ public class RuntimeInvoker implements Invoker{ } } + /** + * Initiate the sending of the forward part of an asynchronous + * exchange along the request part of the wire. + * + * @param msg the request message + */ public void invokeAsync(Message msg) { if (invocable instanceof Endpoint) { msg.setTo((Endpoint)invocable); @@ -141,25 +147,14 @@ public class RuntimeInvoker implements Invoker{ Message msgContext = ThreadMessageContext.setMessageContext(msg); try { - // TODO - is this the way we'll pass async messages down the chain? - Message resp = null; try { ((InvokerAsyncRequest)headInvoker).invokeAsyncRequest(msg); } catch (Throwable ex) { // temporary fix to swallow the dummy exception that's // thrown back to get past the response chain processing. if (!(ex instanceof AsyncResponseException)){ - // throw ex; - } - } - - // This is async but we check the response in case there is a - // fault reported on the forward request, i.e. before the - // request reaches the binding - if (resp != null){ - Object body = resp.getBody(); - if (resp.isFault()) { - //throw (Throwable)body; + // TODO send the exception in through the + // async response processing path } } } finally { @@ -169,42 +164,17 @@ public class RuntimeInvoker implements Invoker{ return; } + /** + * Initiate the sending of the response part of an asynchronous + * exchange along the response part of the wire. + * + * @param msg the response message + */ public void invokeAsyncResponse(Message msg) { InvocationChain chain = invocable.getInvocationChain(msg.getOperation()); Invoker tailInvoker = chain.getTailInvoker(); - ((InvokerAsyncResponse)tailInvoker).invokeAsyncResponse(msg); - -/* now statically configured - // now get the asyncResponseInvoker - Invoker asyncResponseInvoker = null; - - // We'd want to cache this based on the reference EPR - if (invocable instanceof Endpoint) { - // get it from the binding - RuntimeEndpoint ep = (RuntimeEndpoint)invocable; - ServiceBindingProvider serviceBindingProvider = ep.getBindingProvider(); - if (serviceBindingProvider instanceof EndpointAsyncProvider){ - EndpointAsyncProvider asyncEndpointProvider = (EndpointAsyncProvider)serviceBindingProvider; - asyncResponseInvoker = asyncEndpointProvider.createAsyncResponseInvoker(); - - } else { - // TODO - throw error - } - } else if (invocable instanceof EndpointReference) { - // get it from the implementation - RuntimeEndpointReference epr = (RuntimeEndpointReference)invocable; - ImplementationProvider implementationProvider = ((RuntimeComponent)epr.getComponent()).getImplementationProvider(); - - if (implementationProvider instanceof ImplementationAsyncProvider){ - asyncResponseInvoker = ((ImplementationAsyncProvider)implementationProvider).createAsyncResponseInvoker(asyncResponseMsg.getOperation()); - } else { - // TODO - throw an error - } - } - - asyncResponseInvoker.invoke(asyncResponseMsg); -*/ + ((InvokerAsyncResponse)tailInvoker).invokeAsyncResponse(msg); } } diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncResponseInvoker.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncResponseInvoker.java index 4a5d30d2f4..2a7ad3f5bc 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncResponseInvoker.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncResponseInvoker.java @@ -63,9 +63,4 @@ class SampleAsyncResponseInvoker implements InvokerAsyncResponse { // TODO - need to throw this to somewhere? } } - - public Message processResponse(Message msg) { - // Do nothing as no need to share the processing with synch here. - return null; - } } diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java index b87e6f7d5a..b0d9c07d86 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java @@ -65,7 +65,10 @@ class SampleWSDLInvoker extends InterceptorAsyncImpl { // component implementation itself doesn't get a chance to // do async responses. - ((RuntimeEndpoint)endpoint).invokeAsyncResponse(responseMsg); + // At this point we could serialize the ??? and pick it up again + // later to send the async response + + ((RuntimeEndpoint)msg.getTo()).invokeAsyncResponse(responseMsg); } public Message processRequest(Message msg) { -- cgit v1.2.3