summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/unreleased
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/unreleased')
-rw-r--r--sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncProvider.java8
-rw-r--r--sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleAsyncResponseInvoker.java21
-rw-r--r--sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java13
-rw-r--r--sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleWSDLInvoker.java2
4 files changed, 29 insertions, 15 deletions
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 146d027df8..8387285e3d 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
@@ -33,6 +33,8 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsyncRequest;
+import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.provider.ImplementationAsyncProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -88,10 +90,10 @@ 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 createAsyncInvoker(null, s, op);
+ return (Invoker)createAsyncInvoker(null, s, op);
}
- public Invoker createAsyncInvoker(Endpoint endpoint, final RuntimeComponentService s, final Operation op) {
+ public InvokerAsyncRequest createAsyncInvoker(Endpoint endpoint, final RuntimeComponentService s, final Operation op) {
try {
// Creating an invoker for a Java or WSDL-typed implementation
if(op instanceof JavaOperation)
@@ -102,7 +104,7 @@ class SampleAsyncProvider implements ImplementationAsyncProvider {
}
}
- public Invoker createAsyncResponseInvoker(Operation operation) {
+ public InvokerAsyncResponse createAsyncResponseInvoker(Operation operation) {
return new SampleAsyncResponseInvoker(asyncMessageMap, operation, impl.clazz, instance);
}
}
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 c73fdbc7e3..4a5d30d2f4 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
@@ -24,8 +24,7 @@ import java.util.Map;
import org.apache.tuscany.sca.core.invocation.Constants;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
-import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.invocation.Message;
import org.w3c.dom.Element;
@@ -35,7 +34,7 @@ import org.w3c.dom.Element;
*
* @version $Rev$ $Date$
*/
-class SampleAsyncResponseInvoker implements Invoker {
+class SampleAsyncResponseInvoker implements InvokerAsyncResponse {
final String name;
final Object instance;
final Operation op;
@@ -48,21 +47,25 @@ class SampleAsyncResponseInvoker implements Invoker {
this.op = op;
}
- public Message invoke(final Message msg) {
+ public void invokeAsyncResponse(final Message msg) {
try {
String messageID = (String) msg.getHeaders().get(Constants.MESSAGE_ID);
String forwardOpName = (String)asyncMessageMap.get(messageID);
// process the async response
- //Object reponse = ((Object[])msg.getBody())[0];
- Object reponse = msg.getBody();
+ //Object response = ((Object[])msg.getBody())[0];
+ Object response = msg.getBody();
Method method = instance.getClass().getMethod(forwardOpName + "Callback", Element.class);
- method.invoke(instance, reponse);
+ method.invoke(instance, response);
} catch(Exception e) {
e.printStackTrace();
- msg.setFaultBody(e.getCause());
+ // TODO - need to throw this to somewhere?
}
- return msg;
+ }
+
+ 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/SampleJavaInvoker.java b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java
index 437d141be0..063fe166eb 100644
--- a/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java
+++ b/sca-java-2.x/trunk/unreleased/samples/implementation-sample-async/src/main/java/sampleasync/impl/SampleJavaInvoker.java
@@ -23,6 +23,8 @@ import java.lang.reflect.Method;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsyncRequest;
+import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
import org.apache.tuscany.sca.invocation.Message;
/**
@@ -30,7 +32,7 @@ import org.apache.tuscany.sca.invocation.Message;
*
* @version $Rev$ $Date$
*/
-class SampleJavaInvoker implements Invoker {
+class SampleJavaInvoker implements Invoker, InvokerAsyncRequest {
final Object instance;
final Method method;
@@ -40,6 +42,15 @@ class SampleJavaInvoker implements Invoker {
}
public Message invoke(final Message msg) {
+ return processRequest(msg);
+ }
+
+ public void invokeAsyncRequest(Message msg) {
+ processRequest(msg);
+ // TODO - need to do something about exceptions
+ }
+
+ public Message processRequest(Message msg) {
try {
// Call the method that implements the operation
msg.setBody(method.invoke(instance, (Object[])msg.getBody()));
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 4341c053fd..b87e6f7d5a 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
@@ -24,9 +24,7 @@ import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.invocation.InterceptorAsyncImpl;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
-import org.apache.tuscany.sca.invocation.InterceptorAsync;
import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.InvokerAsync;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.w3c.dom.Element;