diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-09 11:56:11 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-09 11:56:11 +0000 |
commit | 21c4fe09a85c35932b3240f3a4141849e80496da (patch) | |
tree | 1a3a6d9cb787b42995551fcde9715d7cb1a3cf47 /sca-java-2.x/trunk | |
parent | 8d8b0bab043fad2f4773c40cff8c2a1e6d935df6 (diff) |
TUSCANY-3801 - Make the async invoker creation signature more consistent with the invoke creation signature
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043910 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
5 files changed, 22 insertions, 16 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java index 1ddf015568..2941483ede 100644 --- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java +++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java @@ -45,13 +45,12 @@ public interface ImplementationAsyncProvider extends ImplementationProvider { * createInvoker is that the Endpoint is passed in so that the invoker can
* engineer the async response
*
- * @param endpoint the endoint at the head of this invocation chain
* @param service The component service
* @param operation The operation that the interceptor will handle
* @return An invoker that handles the invocation logic, null should be
* returned if no invoker is required
*/
- InvokerAsyncRequest createAsyncInvoker(Endpoint endpoint, RuntimeComponentService service, Operation operation);
+ InvokerAsyncRequest createAsyncInvoker(RuntimeComponentService service, Operation operation);
/**
* TUSCANY-3801
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 e353af92e2..f4408429df 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 @@ -713,7 +713,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint } } else if (isAsyncInvocation() && provider instanceof ImplementationAsyncProvider){ - invoker = (Invoker)((ImplementationAsyncProvider)provider).createAsyncInvoker(this, (RuntimeComponentService)service, operation); + invoker = (Invoker)((ImplementationAsyncProvider)provider).createAsyncInvoker((RuntimeComponentService)service, operation); } else { invoker = provider.createInvoker((RuntimeComponentService)service, operation); } 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 4b2e72ac6b..f894290b3e 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 @@ -39,6 +39,7 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.runtime.Invocable; import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.apache.tuscany.sca.work.WorkScheduler; +import org.oasisopen.sca.ServiceRuntimeException; /** * Invoker for a endpoint or endpoint reference @@ -120,14 +121,23 @@ public class RuntimeInvoker implements Invoker{ */ public void invokeAsync(Message msg) { if (invocable instanceof Endpoint) { - msg.setTo((Endpoint)invocable); + Endpoint ep = (Endpoint)invocable; + msg.setTo(ep); + if (!ep.isAsyncInvocation()){ + throw new ServiceRuntimeException("Calling invokeAsync on a non-async endpoint - " + + ep); + } } else if (invocable instanceof EndpointReference) { RuntimeEndpointReference epr = (RuntimeEndpointReference)invocable; + if (!epr.isAsyncInvocation()){ + throw new ServiceRuntimeException("Calling invokeAsync on a non-async endpoint reference - " + + epr); + } if (epr.isOutOfDate()) { epr.rebuild(); } - msg.setFrom((EndpointReference)invocable); - msg.setTo(((EndpointReference)invocable).getTargetEndpoint()); + msg.setFrom(epr); + msg.setTo(epr.getTargetEndpoint()); } Operation operation = msg.getOperation(); @@ -153,8 +163,10 @@ public class RuntimeInvoker implements Invoker{ // temporary fix to swallow the dummy exception that's // thrown back to get past the response chain processing. if (!(ex instanceof AsyncResponseException)){ - // TODO send the exception in through the + // send the exception in through the // async response processing path + msg.setFaultBody(ex); + invokeAsyncResponse(msg); } } } finally { diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java index 8387285e3d..10eb78f6c8 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.Map; import org.apache.tuscany.sca.assembly.ComponentReference; -import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.interfacedef.Interface; @@ -88,17 +87,15 @@ class SampleAsyncProvider implements ImplementationAsyncProvider { } public Invoker createInvoker(final RuntimeComponentService s, final Operation op) { - // TODO - we're passing EP into the WSDL invoker so this isn't going to work - // properly for sync calls - return (Invoker)createAsyncInvoker(null, s, op); + return (Invoker)createAsyncInvoker(s, op); } - public InvokerAsyncRequest createAsyncInvoker(Endpoint endpoint, final RuntimeComponentService s, final Operation op) { + public InvokerAsyncRequest createAsyncInvoker(final RuntimeComponentService s, final Operation op) { try { // Creating an invoker for a Java or WSDL-typed implementation if(op instanceof JavaOperation) return new SampleJavaInvoker((JavaOperation)op, impl.clazz, instance); - return new SampleWSDLInvoker(endpoint, (WSDLOperation)op, impl.clazz, instance); + return new SampleWSDLInvoker((WSDLOperation)op, impl.clazz, instance); } catch(Exception e) { throw new RuntimeException(e); } 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 b0d9c07d86..26412ab281 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 @@ -36,13 +36,11 @@ import org.w3c.dom.Element; * @version $Rev$ $Date$ */ class SampleWSDLInvoker extends InterceptorAsyncImpl { - final Endpoint endpoint; final String name; final Object instance; final Method method; - SampleWSDLInvoker(Endpoint endpoint, final WSDLOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException { - this.endpoint = endpoint; + SampleWSDLInvoker(final WSDLOperation op, final Class<?> clazz, final Object instance) throws SecurityException, NoSuchMethodException { this.name = op.getName(); this.instance = instance; this.method = clazz.getMethod("call", String.class, Element.class); |