tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1041858 - in /tuscany/sca-java-2.x/trunk/modules: core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
Date Fri, 03 Dec 2010 15:12:43 GMT
Author: slaws
Date: Fri Dec  3 15:12:43 2010
New Revision: 1041858

URL: http://svn.apache.org/viewvc?rev=1041858&view=rev
Log:
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. 

Added:
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java

Added: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java?rev=1041858&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
(added)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InterceptorAsync.java
Fri Dec  3 15:12:43 2010
@@ -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();
+
+}

Added: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java?rev=1041858&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
(added)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InterceptorAsyncImpl.java
Fri Dec  3 15:12:43 2010
@@ -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;
+    }
+}



Mime
View raw message