summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-12-03 15:12:43 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-12-03 15:12:43 +0000
commit4183a83ecf503fa893e723f54758375f53278ea3 (patch)
treea7a7022be9c71ed18082f9de9c74a238b2cb1405 /sca-java-2.x
parentd77052b43fd48e8d7e04aa8c5c08633ec09c24a1 (diff)
TUSCANY-3801 - add an async interceptor interface to chain can be navigated backwards. Also add an implementation that can hold generic interceptor implementation that to date, for the forward chain, has been repeated in each interceptor.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java40
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java74
2 files changed, 114 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
new file mode 100644
index 0000000000..3819147526
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.invocation;
+
+/**
+ * Allows asynchronous wires to be navigated in reverse in order for the
+ * reponse to be processed.
+ *
+ */
+public interface InterceptorAsync extends Interceptor, InvokerAsync {
+
+ /**
+ * Sets the previous invoker
+ * @param next The previous invoker
+ */
+ void setPrevious(InvokerAsync previous);
+
+ /**
+ * Returns the previous invoker or null
+ * @return The previous Invoker
+ */
+ InvokerAsync getPrevious();
+
+}
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
new file mode 100644
index 0000000000..0c42a523a6
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.core.invocation;
+
+
+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;
+
+/**
+ * A base class that holds the mechanics for representing
+ * chained interceptors and for driving processing up and
+ * down the chain.
+ *
+ */
+public abstract class InterceptorAsyncImpl implements InterceptorAsync {
+
+ protected InvokerAsync next;
+ protected InvokerAsync previous;
+
+ public Invoker getNext() {
+ return (Invoker)next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = (InvokerAsync)next;
+ }
+
+ public InvokerAsync getPrevious() {
+ return previous;
+ }
+
+ public void setPrevious(InvokerAsync previous) {
+ this.previous = previous;
+ }
+
+ public Message invoke(Message msg) {
+ msg = processRequest(msg);
+ Message resultMsg = getNext().invoke(msg);
+ resultMsg = processResponse(resultMsg);
+ return resultMsg;
+ }
+
+ public void invokeAsyncRequest(Message msg) {
+ msg = processRequest(msg);
+ ((InvokerAsync)getNext()).invokeAsyncRequest(msg);
+ }
+
+ public Message invokeAsyncResponse(Message msg) {
+ msg = processResponse(msg);
+ if (getPrevious() != null){
+ return ((InvokerAsync)getPrevious()).invokeAsyncResponse(msg);
+ }
+ return msg;
+ }
+}