From 471a23dbe35f1389a9fd43ee409ac4bb03d995c4 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 3 Dec 2010 15:22:31 +0000 Subject: TUSCANY-3801 - Update the invocation chain infrastructure, and the enpoints/endpointreferences that call it, to allow async response messages to be processed backwards along the response part of the chain independently of the forward message processing. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041866 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/invocation/InvocationChain.java | 12 +++++ .../tuscany/sca/invocation/InvokerAsync.java | 51 ++++++++++++++++++---- .../org/apache/tuscany/sca/runtime/Invocable.java | 11 ++++- 3 files changed, 65 insertions(+), 9 deletions(-) (limited to 'sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca') diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java index 579e0c3da9..d10a5689d4 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java @@ -105,4 +105,16 @@ public interface InvocationChain { * @param allowsPBR */ void setAllowsPassByReference(boolean allowsPBR); + + /** + * Returns true if this chain must be able to support async + * invocation. This will be as a consequence of the EPR/EP + * detecting the asyncInvocation intent. The flag is set on + * construction and used as an internal guard against non + * async interceptors being added to a chain that expect to + * be able to handle async calls + * + * @return true is the chain supports async invocation. + */ + boolean isAsyncInvocation(); } diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsync.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsync.java index 624e8fdab4..a67a28a931 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsync.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvokerAsync.java @@ -19,21 +19,56 @@ package org.apache.tuscany.sca.invocation; /** - * TUSCANY-3786 - Possibly temporary interface to describe an - * async invocation. Need to make it work end to - * end before committing to this. - * - * Asynchronous mediation associated with a client- or target- side wire. + * TUSCANY-3786 + * + * Interface to describe an invoation where the request processing + * can be performed independently of the response processing. This + * has been instigated to allow async responses to be processed + * independently of the requests that instigated them. Due to the need + * to run the reponse processing interceptors effectively backwards the + * methods defined here are not responsible for finding the next invoker + * in the chain. * */ public interface InvokerAsync { + + /** + * Process the forward message and pass it down the chain + * + * @param msg The request Message + * @return the processed message + * + */ + void invokeAsyncRequest(Message msg); + + /** + * Process response message and pass it back up the chain. + * This returns the message that is processed by the chain + * so that it can be passes onto the appropriate invoker by the caller + * the response path doesn't have an invoker. + * + * @param msg The request Message + * @return the processed message + * + */ + Message invokeAsyncResponse(Message msg); /** - * Process an asynchronous wire + * Process a request message + * + * @param msg The request Message + * @return the processed message + * + */ + Message processRequest(Message msg); + + /** + * Process a response message * - * @param msg The request Message for the wire + * @param msg The request Message + * @return the processed message * */ - void invokeAsync(Message msg); + 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 31260f1afa..cf9b8ac49e 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 @@ -29,6 +29,7 @@ import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.InvokerAsync; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.provider.PolicyProvider; @@ -136,7 +137,15 @@ public interface Invocable { * @return The ticket that can be used to identify this invocation * @throws InvocationTargetException */ - void invokeAsync(Operation operation, Message msg); + void invokeAsync(Operation operation, Message msg) throws Throwable; + // TODO - this shouldn't throw an exception + + /** + * Asynchronously invoke an operation with a context message + * @param tailInvoker the invoker at the end of the chain + * @param msg The request message + */ + void invokeAsyncResponse(InvokerAsync tailInvoker, Message msg); /** * Get a list of policy providers -- cgit v1.2.3