diff options
Diffstat (limited to 'sca-java-2.x')
6 files changed, 42 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/api/WSDLReference.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/api/WSDLReference.java index cad8478a2a..185383d3b3 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/api/WSDLReference.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/api/WSDLReference.java @@ -24,5 +24,6 @@ import org.w3c.dom.Element; public interface WSDLReference { Element call(String op, Element e); + void callAsync(String op, Element e); } diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/impl/SampleWSDLProxy.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/impl/SampleWSDLProxy.java index a6882a0103..0d000ae071 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/impl/SampleWSDLProxy.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sample/impl/SampleWSDLProxy.java @@ -54,4 +54,9 @@ class SampleWSDLProxy implements WSDLReference { throw new RuntimeException(ex); } } + + @Override + public void callAsync(String op, Element e) { + return; + } } 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 f87e468320..9538a88a67 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 @@ -22,6 +22,7 @@ package sampleasync.impl; import java.lang.reflect.Field; import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; @@ -42,12 +43,14 @@ class SampleAsyncProvider implements ImplementationProvider { final RuntimeComponent comp; final SampleAsyncImplementation impl; final ProxyFactory pxf; + final ExtensionPointRegistry ep; Object instance; - SampleAsyncProvider(final RuntimeComponent comp, final SampleAsyncImplementation impl, ProxyFactory pf) { + SampleAsyncProvider(final RuntimeComponent comp, final SampleAsyncImplementation impl, ProxyFactory pf, ExtensionPointRegistry ep) { this.comp = comp; this.impl = impl; this.pxf = pf; + this.ep = ep; } public void start() { @@ -63,7 +66,7 @@ class SampleAsyncProvider implements ImplementationProvider { if(i instanceof JavaInterface) f.set(instance, pxf.createProxy(comp.getComponentContext().getServiceReference(f.getType(), r.getName()))); else - f.set(instance, new SampleWSDLProxy(r.getEndpointReferences().get(0), i)); + f.set(instance, new SampleWSDLProxy(r.getEndpointReferences().get(0), i, ep)); } } 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/SampleAsyncProviderFactory.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java index 1a7dad9eb4..2170313eec 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProviderFactory.java @@ -33,13 +33,15 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent; */ public class SampleAsyncProviderFactory implements ImplementationProviderFactory<SampleAsyncImplementation> { final ProxyFactory pxf; + final ExtensionPointRegistry ep; public SampleAsyncProviderFactory(final ExtensionPointRegistry ep) { + this.ep = ep; pxf = ExtensibleProxyFactory.getInstance(ep); } public ImplementationProvider createImplementationProvider(final RuntimeComponent comp, final SampleAsyncImplementation impl) { - return new SampleAsyncProvider(comp, impl, pxf); + return new SampleAsyncProvider(comp, impl, pxf, ep); } public Class<SampleAsyncImplementation> getModelType() { 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 5611928573..0c1051b58c 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 @@ -45,6 +45,7 @@ class SampleWSDLInvoker implements Invoker { public Message invoke(final Message msg) { try { + //AsyncHeader asyncHeader = (String) message.getHeaders().get("ASYNC-HEADER"); // Invoke the generic call method msg.setBody(method.invoke(instance, name, ((Object[])msg.getBody())[0])); } catch(Exception e) { diff --git a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java index ff84db1d1a..19d518e44c 100644 --- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java +++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLProxy.java @@ -24,8 +24,12 @@ import java.util.HashMap; import java.util.Map; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.invocation.Constants; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; import org.w3c.dom.Element; @@ -37,14 +41,19 @@ import sample.api.WSDLReference; class SampleWSDLProxy implements WSDLReference { final RuntimeEndpointReference repr; final Map<String, Operation> ops; + final ExtensionPointRegistry ep; + final MessageFactory mf; - SampleWSDLProxy(EndpointReference epr, Interface wi) { + SampleWSDLProxy(EndpointReference epr, Interface wi, ExtensionPointRegistry ep) { + this.ep = ep; + mf = ep.getExtensionPoint(MessageFactory.class); + repr = (RuntimeEndpointReference)epr; ops = new HashMap<String, Operation>(); for(Operation o: wi.getOperations()) ops.put(o.getName(), o); } - + @Override public Element call(String op, Element e) { try { @@ -54,4 +63,20 @@ class SampleWSDLProxy implements WSDLReference { throw new RuntimeException(ex); } } + + @Override + public void callAsync(String op, Element e) { + // Asynchronously invoke the named operation on the endpoint reference + Message message = mf.createMessage(); + message.setBody(message); + + // We could add implementation specific headers here if required + + repr.invokeAsync(ops.get(op), message); + + String messageID = (String) message.getHeaders().get(Constants.MESSAGE_ID); + + // save the message id ready for when we process the response + + } } |