You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2007/02/14 00:00:08 UTC

svn commit: r507284 - in /incubator/tuscany/java/sca/kernel/core/src: main/java/org/apache/tuscany/core/wire/ test/java/org/apache/tuscany/core/wire/

Author: jmarino
Date: Tue Feb 13 15:00:07 2007
New Revision: 507284

URL: http://svn.apache.org/viewvc?view=rev&rev=507284
Log:
add new InvocaationChain implementation

Added:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java   (with props)
Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/AbstractInvocationChain.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/AbstractInvocationChain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/AbstractInvocationChain.java?view=diff&rev=507284&r1=507283&r2=507284
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/AbstractInvocationChain.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/AbstractInvocationChain.java Tue Feb 13 15:00:07 2007
@@ -27,6 +27,7 @@
  *
  *
  * @version $Rev$ $Date$
+ * @deprecated
  */
 public abstract class AbstractInvocationChain implements InvocationChain {
     protected Operation operation;

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java?view=auto&rev=507284
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java Tue Feb 13 15:00:07 2007
@@ -0,0 +1,95 @@
+/*
+ * 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.core.wire;
+
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.model.Operation;
+
+/**
+ * Default implementation of an invocation chain
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationChainImpl implements InvocationChain {
+    protected Operation operation;
+    protected TargetInvoker targetInvoker;
+    protected Interceptor interceptorChainHead;
+    protected Interceptor interceptorChainTail;
+
+    public InvocationChainImpl(Operation operation) {
+        assert operation != null;
+        this.operation = operation;
+    }
+
+    public Operation getOperation() {
+        return operation;
+    }
+
+    public void setTargetInvoker(TargetInvoker invoker) {
+        this.targetInvoker = invoker;
+    }
+
+    public TargetInvoker getTargetInvoker() {
+        return targetInvoker;
+    }
+
+    public void addInterceptor(Interceptor interceptor) {
+        if (interceptorChainHead == null) {
+            interceptorChainHead = interceptor;
+        } else {
+            interceptorChainTail.setNext(interceptor);
+        }
+        interceptorChainTail = interceptor;
+    }
+
+    public void addInterceptor(int index, Interceptor interceptor) {
+        int i = 0;
+        Interceptor next = interceptorChainHead;
+        Interceptor prev = null;
+        while (next != null && i < index) {
+            prev = next;
+            next = next.getNext();
+            i++;
+        }
+        if (i == index) {
+            if (prev != null) {
+                prev.setNext(interceptor);
+            } else {
+                interceptorChainHead = interceptor;
+            }
+            interceptor.setNext(next);
+            if (next == null) {
+                interceptorChainTail = interceptor;
+            }
+        } else {
+            throw new ArrayIndexOutOfBoundsException(index);
+        }
+    }
+
+    public Interceptor getHeadInterceptor() {
+        return interceptorChainHead;
+    }
+
+    public Interceptor getTailInterceptor() {
+        return interceptorChainTail;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java?view=diff&rev=507284&r1=507283&r2=507284
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java Tue Feb 13 15:00:07 2007
@@ -23,6 +23,7 @@
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.Interceptor;
 import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.InvocationChain;
 
 import junit.framework.TestCase;
 
@@ -32,7 +33,7 @@
 public class InvocationChainImplTestCase extends TestCase {
 
     public void testInsertAtPos() throws Exception {
-        MockChain chain = new MockChain(new Operation<Type>("foo", null, null, null));
+        InvocationChain chain = new InvocationChainImpl(new Operation<Type>("foo", null, null, null));
         Interceptor inter3 = new MockInterceptor();
         Interceptor inter2 = new MockInterceptor();
         Interceptor inter1 = new MockInterceptor();
@@ -46,7 +47,7 @@
     }
 
     public void testInsertAtEnd() throws Exception {
-        MockChain chain = new MockChain(new Operation<Type>("foo", null, null, null));
+        InvocationChain chain = new InvocationChainImpl(new Operation<Type>("foo", null, null, null));
         Interceptor inter2 = new MockInterceptor();
         Interceptor inter1 = new MockInterceptor();
         chain.addInterceptor(0, inter1);
@@ -56,17 +57,6 @@
         assertEquals(inter2, head.getNext());
         assertEquals(inter2, chain.getTailInterceptor());
 
-    }
-
-    private class MockChain extends AbstractInvocationChain {
-
-        public MockChain(Operation operation) {
-            super(operation);
-        }
-
-        public void prepare() {
-
-        }
     }
 
     private class MockInterceptor implements Interceptor {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org