You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/19 07:28:27 UTC

svn commit: r557493 - in /incubator/tuscany/java/sca/modules: core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/ interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/ interface-wsdl/src/main/jav...

Author: rfeng
Date: Wed Jul 18 22:28:26 2007
New Revision: 557493

URL: http://svn.apache.org/viewvc?view=rev&rev=557493
Log:
Apply the patch from Matt for TUSCANY-1452. Thanks, Matt.

Added:
    incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java   (with props)
Modified:
    incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java
    incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java
    incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
    incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java
    incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
    incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java

Modified: incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core-spring/src/main/java/org/apache/tuscany/sca/core/spring/implementation/java/impl/BeanJavaInterfaceImpl.java Wed Jul 18 22:28:26 2007
@@ -119,4 +119,9 @@
     public boolean isDynamic() {
         return false;
     }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
 }

Modified: incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java Wed Jul 18 22:28:26 2007
@@ -31,4 +31,9 @@
     protected JavaInterfaceContractImpl() {
     }
 
+    @Override
+    public JavaInterfaceContractImpl clone() throws CloneNotSupportedException {
+        return (JavaInterfaceContractImpl) super.clone();
+    }
+
 }

Modified: incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java Wed Jul 18 22:28:26 2007
@@ -91,4 +91,10 @@
             return false;
         }
     }
+
+    @Override
+    public JavaInterfaceImpl clone() throws CloneNotSupportedException {
+        return (JavaInterfaceImpl) super.clone();
+    }
+
 }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java Wed Jul 18 22:28:26 2007
@@ -39,4 +39,9 @@
     public void setLocation(String location) {
         this.location = location;
     }
+
+    @Override
+    public WSDLInterfaceContractImpl clone() throws CloneNotSupportedException {
+        return (WSDLInterfaceContractImpl) super.clone();
+    }
 }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java Wed Jul 18 22:28:26 2007
@@ -90,4 +90,10 @@
     public void setWsdlDefinition(WSDLDefinition wsdlDefinition) {
         this.wsdlDefinition = wsdlDefinition;
     }
+
+    @Override
+    public WSDLInterfaceImpl clone() throws CloneNotSupportedException {
+        return (WSDLInterfaceImpl) super.clone();
+    }
+
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java Wed Jul 18 22:28:26 2007
@@ -25,7 +25,7 @@
  * support concrete interface type systems, such as Java interfaces, WSDL 1.1
  * portTypes and WSDL 2.0 interfaces.
  */
-public interface Interface {
+public interface Interface extends Cloneable {
 
     /**
      * Returns true if the interface is a remotable interface..
@@ -89,5 +89,10 @@
      * @return true if the Interface is dynamic.
      */
     boolean isDynamic();
+
+    /**
+     * Implementations must support cloning.
+     */
+    Object clone() throws CloneNotSupportedException;
 
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java Wed Jul 18 22:28:26 2007
@@ -73,4 +73,9 @@
      */
     InterfaceContract makeUnidirectional(boolean isCallback);
 
+    /**
+     * Implementations must support cloning.
+     */
+    Object clone() throws CloneNotSupportedException;
+
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java Wed Jul 18 22:28:26 2007
@@ -25,7 +25,7 @@
 /**
  * Represents an operation on a service interface.
  */
-public interface Operation {
+public interface Operation extends Cloneable {
     /**
      * Returns the name of the operation.
      * 
@@ -170,4 +170,9 @@
      * @param b
      */
     void setDynamic(boolean b);
+
+    /**
+     * Implementations must support cloning.
+     */
+    Object clone() throws CloneNotSupportedException;
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java Wed Jul 18 22:28:26 2007
@@ -23,9 +23,8 @@
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 
 /**
- * Represents an interface contract.
- * InterfaceContractImpl
- *
+ * Represents an interface contract. InterfaceContractImpl
+ * 
  * @version $Rev$ $Date$
  */
 public abstract class InterfaceContractImpl implements InterfaceContract {
@@ -50,24 +49,80 @@
 
     public InterfaceContract makeUnidirectional(boolean isCallback) {
         if (!isCallback && callbackInterface == null)
-            return this;  // already a unidirectional forward interface contract
-        
+            return this; // already a unidirectional forward interface contract
+
         if (isCallback && callInterface == null)
-            return this;  // already a unidirectional callback interface contract
+            return this; // already a unidirectional callback interface contract
 
         // contract is bidrectional, so create a new unidirectional contract        
         try {
             InterfaceContract newContract = (InterfaceContract)clone();
             if (!isCallback) {
-                newContract.setCallbackInterface(null);  // create unidirectional forward interface contract
+                newContract.setCallbackInterface(null); // create unidirectional forward interface contract
             } else {
-                newContract.setInterface(null);  // create unidirectional callback interface contract
+                newContract.setInterface(null); // create unidirectional callback interface contract
             }
             return newContract;
         } catch (CloneNotSupportedException e) {
             // will not happen
             return null;
         }
+    }
+
+    @Override
+    public InterfaceContractImpl clone() throws CloneNotSupportedException {
+        InterfaceContractImpl copy = (InterfaceContractImpl)super.clone();
+        if (this.callbackInterface != null) {
+            copy.callbackInterface = (Interface)this.callbackInterface.clone();
+        }
+        if (this.callInterface != null) {
+            copy.callInterface = (Interface)this.callInterface.clone();
+        }
+        return copy;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((callInterface == null) ? 0 : callInterface.hashCode());
+        result = prime * result + ((callbackInterface == null) ? 0 : callbackInterface.hashCode());
+        return result;
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final InterfaceContractImpl other = (InterfaceContractImpl)obj;
+        if (callInterface == null) {
+            if (other.callInterface != null) {
+                return false;
+            }
+        } else if (!callInterface.equals(other.callInterface)) {
+            return false;
+        }
+        if (callbackInterface == null) {
+            if (other.callbackInterface != null) {
+                return false;
+            }
+        } else if (!callbackInterface.equals(other.callbackInterface)) {
+            return false;
+        }
+        return true;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java Wed Jul 18 22:28:26 2007
@@ -161,4 +161,55 @@
         return false;
     }
 
+    @Override
+    public InterfaceImpl clone() throws CloneNotSupportedException {
+        InterfaceImpl copy = (InterfaceImpl) super.clone();
+        copy.operations = new OperationList();
+        for (Operation operation : this.operations) {
+            Operation clonedOperation = (Operation) operation.clone();
+            copy.operations.add(clonedOperation);
+        }
+        return copy;
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (conversational ? 1231 : 1237);
+        result = prime * result + ((operations == null) ? 0 : operations.hashCode());
+        result = prime * result + (remotable ? 1231 : 1237);
+        result = prime * result + (unresolved ? 1231 : 1237);
+        return result;
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final InterfaceImpl other = (InterfaceImpl)obj;
+        if (conversational != other.conversational)
+            return false;
+        if (operations == null) {
+            if (other.operations != null)
+                return false;
+        } else if (!operations.equals(other.operations))
+            return false;
+        if (remotable != other.remotable)
+            return false;
+        if (unresolved != other.unresolved)
+            return false;
+        return true;
+    }
+
 }

Modified: incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java?view=diff&rev=557493&r1=557492&r2=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java Wed Jul 18 22:28:26 2007
@@ -176,11 +176,6 @@
         this.nonBlocking = nonBlocking;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#hashCode()
-     */
     @Override
     public int hashCode() {
         final int PRIME = 31;
@@ -289,6 +284,33 @@
 
     public void setDynamic(boolean b) {
         this.dynamic = b;
+    }
+
+    @Override
+    public OperationImpl clone() throws CloneNotSupportedException {
+        OperationImpl copy = (OperationImpl) super.clone();
+        
+        final List<DataType> clonedFaultTypes = new ArrayList<DataType>(this.faultTypes.size());
+        for (DataType t : this.faultTypes) {
+            clonedFaultTypes.add((DataType) t.clone());
+        }
+        copy.faultTypes = clonedFaultTypes;
+
+        List<DataType> clonedLogicalTypes = new ArrayList<DataType>();
+        for (DataType t : inputType.getLogical()) {
+            DataType type = (DataType) t.clone();
+            clonedLogicalTypes.add(type);
+        }
+        DataType<List<DataType>> clonedInputType =
+            new DataTypeImpl<List<DataType>>(inputType.getPhysical(), clonedLogicalTypes);
+        clonedInputType.setDataBinding(inputType.getDataBinding());
+        copy.inputType = clonedInputType;
+        
+        if(this.outputType!=null) {
+            copy.outputType = (DataType) this.outputType.clone();
+        }
+        
+        return copy;
     }
 
 }

Added: incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java?view=auto&rev=557493
==============================================================================
--- incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java Wed Jul 18 22:28:26 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.interfacedef.impl;
+
+
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractTestCase {
+    private InterfaceContract contract;
+    /**
+     * @throws java.lang.Exception
+     */
+    @Before
+    public void setUp() throws Exception {
+        contract = new MockInterfaceContract();
+        Interface i1 = new MockInterface();
+        contract.setInterface(i1);
+        Operation op1 = new OperationImpl("op1");
+        i1.getOperations().add(op1);
+        Interface i2 = new MockInterface();
+        contract.setCallbackInterface(i2);
+        Operation callbackOp1 = new OperationImpl("callbackOp1");
+        i2.getOperations().add(callbackOp1);
+    }
+    
+    @Test
+    public void testClone() throws Exception {
+        InterfaceContract copy = (InterfaceContract) contract.clone();
+        Assert.assertEquals(contract, copy);
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+    }
+    
+    private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract {
+    }
+
+    private static class MockInterface extends InterfaceImpl implements Interface {
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



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