summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java')
-rw-r--r--sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java57
1 files changed, 25 insertions, 32 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java
index 9353571cb1..5e6375480e 100644
--- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/main/java/org/apache/tuscany/sca/binding/comet/runtime/CometInvoker.java
@@ -20,43 +20,36 @@
package org.apache.tuscany.sca.binding.comet.runtime;
import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.comet.runtime.handler.CometBindingHandler;
+import org.apache.tuscany.sca.core.invocation.impl.MessageImpl;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
-/**
- * Invoker for a service binding. Invoking is made from client Javascript so no
- * behavior is needed.
- */
public class CometInvoker implements Invoker {
- /**
- * The invoked operation.
- */
- protected Operation operation;
-
- /**
- * The endpoint to which the operation belongs.
- */
- protected EndpointReference endpoint;
-
- /**
- * Default constructor.
- *
- * @param operation the operation
- * @param endpoint the endpoint
- */
- public CometInvoker(final Operation operation, final EndpointReference endpoint) {
- this.operation = operation;
- this.endpoint = endpoint;
- }
-
- /**
- * No behavior.
- */
- @Override
- public Message invoke(final Message msg) {
- return null;
- }
+ protected Operation operation;
+ protected EndpointReference endpoint;
+
+ public CometInvoker(final Operation operation, final EndpointReference endpoint) {
+ this.operation = operation;
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public Message invoke(final Message msg) {
+ String operation = msg.getOperation().getName();
+ CometMessageContext context = msg.getBindingContext();
+ CometBindingHandler handler = context.getCometHandler();
+ Message message = new MessageImpl();
+ if (operation.equals("sendResponse")) {
+ String callbackMethod = context.getCallbackMethod();
+ Object[] body = msg.getBody();
+ handler.respondToClient(callbackMethod, body[0]);
+ } else if (operation.equals("isClientConnected")) {
+ message.setBody(handler.isClientConnected());
+ }
+ return message;
+ }
}