diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-09 11:58:51 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-09 11:58:51 +0000 |
commit | 7e15f24294c313940b281faed8df35c94c07e42d (patch) | |
tree | 986e35273e45b3d59ae9838a8fdb20f138cfdc4d /sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java | |
parent | 21c4fe09a85c35932b3240f3a4141849e80496da (diff) |
TUSCANY-3801 - Start adding an async dimension to the implementation extension sample
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1043914 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java')
-rw-r--r-- | sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java b/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java index a6882a0103..0fc8403cf1 100644 --- a/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/impl/SampleWSDLProxy.java +++ b/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/main/java/sample/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,8 +41,14 @@ import sample.api.WSDLReference; class SampleWSDLProxy implements WSDLReference { final RuntimeEndpointReference repr; final Map<String, Operation> ops; + final ExtensionPointRegistry ep; + final MessageFactory mf; + Map<String, Object> asyncMessageMap; - SampleWSDLProxy(EndpointReference epr, Interface wi) { + SampleWSDLProxy(Map<String, Object> asyncMessageMap, EndpointReference epr, Interface wi, ExtensionPointRegistry ep) { + this.asyncMessageMap = asyncMessageMap; + this.ep = ep; + mf = ep.getExtensionPoint(MessageFactory.class); repr = (RuntimeEndpointReference)epr; ops = new HashMap<String, Operation>(); for(Operation o: wi.getOperations()) @@ -54,4 +64,33 @@ 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(new Object[]{e}); + + // We could MESSAGE_ID here if required. If not the infrastructure + // will generate a UUID + String messageID = "myuniqueid"; + message.getHeaders().put(Constants.MESSAGE_ID, messageID); + + // save the message id ready for when we process the response + asyncMessageMap.put(messageID, op); + + // We could add implementation specific headers here if required + //message.getHeaders().put(Constants.???, ???); + + try { + repr.invokeAsync(ops.get(op), message); + } catch (Throwable ex) { + ex.printStackTrace(); + } + + // if we don't provide a message id we can get the one the + // infrastructure generates + //String messageID = (String) message.getHeaders().get(Constants.MESSAGE_ID); + //asyncMessageMap.put(messageID, op); + } } |