summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java242
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java142
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java594
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java359
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java363
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/TuscanyInterfaceContractImpl.java38
6 files changed, 1738 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
new file mode 100644
index 0000000000..8d84e0352e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
@@ -0,0 +1,242 @@
+/*
+ * 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 java.lang.ref.WeakReference;
+import java.lang.reflect.Type;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+
+/**
+ * Representation of the type of data associated with an operation. Data is
+ * represented in two forms: the physical form used by the runtime and a logical
+ * form used by the assembly. The physical form is a Java Type because the
+ * runtime is written in Java. This may be the same form used by the application
+ * but it may not; for example, an application that is performing stream
+ * processing may want a physical form such as an
+ * {@link java.io.InputStream InputStream} to semantically operate on application
+ * data such as a purchase order. The logical description is that used by the
+ * assembly model and is an identifier into some well-known type space; examples
+ * may be a Java type represented by its Class or an XML type represented by its
+ * QName. Every data type may also contain metadata describing the expected
+ * data; for example, it could specify a preferred data binding technology or
+ * the size of a typical instance.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public class DataTypeImpl<L> implements DataType<L> {
+ private String dataBinding;
+ private WeakReference<Class<?>> physical;
+ private WeakReference<Type> genericType;
+ private L logical;
+ private Map<Class<?>, Object> metaDataMap;
+
+ /**
+ * Construct a data type specifying the physical and logical types.
+ *
+ * @param physical the physical class used by the runtime
+ * @param logical the logical type
+ * @see #getLogical()
+ */
+ public DataTypeImpl(Class<?> physical, L logical) {
+ this(null, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, L logical) {
+ this(dataBinding, physical, physical, logical);
+ }
+
+ /**
+ * @param dataBinding
+ * @param physical
+ * @param genericType
+ * @param logical
+ */
+ public DataTypeImpl(String dataBinding, Class<?> physical, Type genericType, L logical) {
+ super();
+ this.dataBinding = dataBinding;
+ this.physical = new WeakReference<Class<?>>(physical);
+ this.genericType = new WeakReference<Type>(genericType);
+ this.logical = logical;
+ }
+
+ /**
+ * Returns the physical type used by the runtime.
+ *
+ * @return the physical type used by the runtime
+ */
+ public Class<?> getPhysical() {
+ return physical.get();
+ }
+
+ /**
+ * @param physical the physical to set
+ */
+ public void setPhysical(Class<?> physical) {
+ this.physical = new WeakReference<Class<?>>(physical);
+ }
+
+ /**
+ * Get the java generic type
+ * @return The java generic type
+ */
+ public Type getGenericType() {
+ return genericType.get();
+ }
+
+ /**
+ * Set the java generic type
+ * @param genericType
+ */
+ public void setGenericType(Type genericType) {
+ this.genericType = new WeakReference<Type>(genericType);
+ }
+
+ /**
+ * Returns the logical identifier used by the assembly. The type of this
+ * value identifies the logical type system in use. Known values are:
+ * <ul>
+ * <li>a java.lang.reflect.Type identifies a Java type by name and
+ * ClassLoader; this includes Java Classes as they are specializations of
+ * Type</li>
+ * <li>a javax.xml.namespace.QName identifies an XML type by local name and
+ * namespace</li>
+ * </ul>
+ *
+ * @return the logical type name
+ */
+ public L getLogical() {
+ return logical;
+ }
+
+ /**
+ * @param logical the logical to set
+ */
+ public void setLogical(L logical) {
+ this.logical = logical;
+ }
+
+ public String getDataBinding() {
+ return dataBinding;
+ }
+
+ /**
+ * @param dataBinding the dataBinding to set
+ */
+ public void setDataBinding(String dataBinding) {
+ this.dataBinding = dataBinding;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder( 256 );
+ b.append( "DataType[" );
+ b.append( "dataBinding=" + ((dataBinding==null) ? "null" : dataBinding) );
+ b.append( ", genericType=" + ((genericType==null || genericType.get() == null) ? "null" : genericType) );
+ b.append( ", physical=" + ((physical==null || physical.get() == null) ? "null" : physical) );
+ b.append( ", logical=" + ((logical==null) ? "null" : logical) );
+ b.append( ", metaData size=" + ((metaDataMap==null) ? "0" : metaDataMap.size()) );
+ b.append( "]" );
+ return b.toString();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ DataTypeImpl copy = (DataTypeImpl)super.clone();
+
+ //
+ // When using a DataTypeImpl with java:array databinding,
+ // 'logical' will be another DataTypeImpl. Doing only
+ // a shallow copy means that resetting the databinding will
+ // have an unexpected side effect on the original. Though
+ // we could special case the java:array-databinding case,
+ // instead do it more generally when the logical is another
+ // DataType.
+ //
+ if (logical instanceof DataType) {
+ DataType logicalDT = (DataType)logical;
+ copy.logical = logicalDT.clone();
+ }
+ return copy;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((dataBinding == null) ? 0 : dataBinding.hashCode());
+ result = prime * result + ((genericType == null || genericType.get() == null) ? 0 : genericType.hashCode());
+ result = prime * result + ((logical == null) ? 0 : logical.hashCode());
+ result = prime * result + ((physical == null || physical.get() == null) ? 0 : physical.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final DataTypeImpl other = (DataTypeImpl)obj;
+ if (dataBinding == null) {
+ if (other.dataBinding != null)
+ return false;
+ } else if (!dataBinding.equals(other.dataBinding))
+ return false;
+ if (genericType == null || genericType.get() == null) {
+ if (other.genericType != null && other.genericType.get() != null)
+ return false;
+ } else if (!genericType.get().equals(other.genericType.get()))
+ return false;
+ if (logical == null) {
+ if (other.logical != null)
+ return false;
+ } else if (!logical.equals(other.logical))
+ return false;
+ if (physical == null || physical.get() == null) {
+ if (other.physical != null && other.physical.get() != null)
+ return false;
+ } else if (!physical.get().equals(other.physical.get()))
+ return false;
+ return true;
+ }
+
+ public <T> T getMetaData(Class<T> type) {
+ return metaDataMap == null ? null : type.cast(metaDataMap.get(type));
+ }
+
+ public <T> void setMetaData(Class<T> type, T metaData) {
+ if (metaDataMap == null) {
+ metaDataMap = new ConcurrentHashMap<Class<?>, Object>();
+ }
+ metaDataMap.put(type, metaData);
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
new file mode 100644
index 0000000000..692dc4743c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
@@ -0,0 +1,142 @@
+/*
+ * 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 org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents an interface contract. InterfaceContractImpl
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class InterfaceContractImpl implements InterfaceContract {
+ private Interface callInterface;
+ private Interface callbackInterface;
+
+ public Interface getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ public Interface getInterface() {
+ return callInterface;
+ }
+
+ public void setCallbackInterface(Interface callbackInterface) {
+ this.callbackInterface = callbackInterface;
+ }
+
+ public void setInterface(Interface callInterface) {
+ this.callInterface = callInterface;
+ }
+
+ public InterfaceContract makeUnidirectional(boolean isCallback) {
+ if (!isCallback && callbackInterface == null)
+ return this; // already a unidirectional forward interface contract
+
+ if (isCallback && callInterface == null)
+ return this; // already a unidirectional callback interface contract
+
+ // contract is bidirectional, so create a new unidirectional contract
+ try {
+ InterfaceContract newContract = clone();
+ if (!isCallback) {
+ newContract.setCallbackInterface(null); // create unidirectional forward interface contract
+ } else {
+ 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;
+ }
+
+ // By default there is no normalized contract
+ // as only Java needs it
+ public InterfaceContract getNormalizedWSDLContract() {
+ return null;
+ }
+
+ // By default there is no normalized contract
+ // as only Java needs it
+ public void setNormalizedWSDLContract(
+ InterfaceContract wsdlInterfaceContract) {
+ // do nothing
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
new file mode 100644
index 0000000000..d04c8b4d97
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -0,0 +1,594 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ContractBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.Audit;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractMapperImpl implements InterfaceContractMapper {
+
+ protected ExtensionPointRegistry registry;
+ protected BuilderExtensionPoint builders;
+ protected ContractBuilder contractBuilder;
+
+ public InterfaceContractMapperImpl(ExtensionPointRegistry registry){
+ this.registry = registry;
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue) {
+ return isCompatible(source, target, passByValue, null);
+ }
+
+ public boolean isCompatible(DataType source, DataType target, boolean passByValue, Audit audit) {
+ if (source == target) {
+ return true;
+ }
+ if (!passByValue) {
+ if (source == null || target == null) {
+ if (audit != null){
+ audit.append("One of either the source or target data types is null for");
+ }
+ return false;
+ }
+ // For local case
+ return target.getPhysical().isAssignableFrom(source.getPhysical());
+ } else {
+ // For remote interfaces where the target is represented with WSDL
+ // the source will have been converted to WSDL so we rely on JAXB mappings
+ // being the same in both cases and just compare the type names directly.
+ // TODO - is this right?
+ XMLType sourceLogicalType = null;
+
+ // There is some nesting of data types (when GeneratedDataTypes or arrays are used) so
+ // dig a bit deeper to find the real data type. Use a loop since for a multidimensional
+ // array, we might need to go more than one level deep.
+ while (source.getLogical() instanceof DataType<?>) {
+ source = (DataType<?>)source.getLogical();
+ }
+ sourceLogicalType = (XMLType)source.getLogical();
+
+ XMLType targetLogicalType = null;
+ while (target.getLogical() instanceof DataType<?>) {
+ target = (DataType<?>)target.getLogical();
+ }
+ targetLogicalType = (XMLType)target.getLogical();
+
+ // The logical type is null in some cases. This is when the
+ // runtime can't determine the XML type for a particular type, for
+ // example for a non-JAXB Java bean. This makes interface checking
+ // rather lenient with errors being detected at runtime
+ if (sourceLogicalType.getTypeName() == null ||
+ targetLogicalType.getTypeName() == null) {
+ return true;
+ }
+
+ boolean match = sourceLogicalType.getTypeName().equals(targetLogicalType.getTypeName());
+
+ if (!match){
+
+ QName anyType = new QName("http://www.w3.org/2001/XMLSchema", "anyType");
+ if (sourceLogicalType.getTypeName().equals(anyType) ||
+ targetLogicalType.getTypeName().equals(anyType)){
+ // special case where a Java interface uses a generic type, e.g.
+ // public OMElement getGreetings(OMElement om)
+ // while the provided WSDL uses a specific type. So we assume
+ // that xsd:anyType matched anything
+ match = true;
+ } else {
+ if (audit != null){
+ audit.append("Operation argument types source = " +
+ sourceLogicalType.getTypeName() +
+ " target = " +
+ targetLogicalType.getTypeName() +
+ " don't match for");
+ }
+ }
+ }
+
+ return match;
+ }
+
+ }
+
+ /**
+ * Check that two interface contracts are equal. The contracts are equal if the two contracts have the
+ * same set of operations, with each operation having the same signature, both for forward and callback
+ * interfaces
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(InterfaceContract source, InterfaceContract target) {
+ ExtensionType ext = source.getInterface().getExtensionType();
+ InterfaceContract sourceContract = null;
+
+ // Are the forward interfaces equal?
+ if (isMutuallyCompatible(source.getInterface(), target.getInterface())) {
+ // Is there a Callback interface?
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ } else {
+ if (isMutuallyCompatible(source.getCallbackInterface(), target.getCallbackInterface())) {
+ return true;
+ } // end if
+ } // end if
+ } // end if
+ return false;
+ } // end method isEqual
+
+ /**
+ * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the
+ * same set of operations, with each operation having the same signature.
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean isMutuallyCompatible(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ } // end if
+ if (source == null || target == null) {
+ return false;
+ } // end if
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+ if (source.getOperations().size() != target.getOperations().size()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ } // end method isEqual
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue) {
+ return isCompatible(source, target, compatibilityType, true, null);
+ }
+
+ public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue, Audit audit) {
+ if (source == target) {
+ return true;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ // Check name
+ if (!source.getName().equals(target.getName())) {
+ if (audit != null){
+ audit.append("operation names are not the same source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ if (audit != null){
+ audit.append("Interfaces have different remote settings source = " +
+ source.getName() +
+ " target = " +
+ target.getName());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ if (source.isNonBlocking() != target.isNonBlocking()) {
+ if (audit != null){
+ audit.append("operations one-way not the same, source = " +
+ source.isNonBlocking() +
+ " target = " +
+ target.isNonBlocking());
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ boolean passByValue = (source.getInterface().isRemotable()) && byValue;
+
+ // FIXME: We need to deal with wrapped<-->unwrapped conversion
+
+ List<DataType> sourceOutputType = source.getOutputType().getLogical();
+ List<DataType> targetOutputType = target.getOutputType().getLogical();
+
+ List<DataType> sourceInputType = source.getInputType().getLogical();
+ List<DataType> targetInputType = target.getInputType().getLogical();
+
+ if (source.isInputWrapperStyle() && source.getInputWrapper() != null) {
+ sourceInputType = source.getInputWrapper().getUnwrappedType().getLogical();
+ }
+
+ if (source.isOutputWrapperStyle() && source.getOutputWrapper() != null) {
+ sourceOutputType = source.getOutputWrapper().getUnwrappedType().getLogical();
+ }
+
+ if (target.isInputWrapperStyle() && target.getInputWrapper() != null) {
+ targetInputType = target.getInputWrapper().getUnwrappedType().getLogical();
+ }
+
+ if (target.isOutputWrapperStyle() && target.getOutputWrapper() != null) {
+ targetOutputType = target.getOutputWrapper().getUnwrappedType().getLogical();
+ }
+
+ if ( sourceOutputType.size() != targetOutputType.size()) {
+ if (audit != null){
+ audit.append("different number of output types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ for ( int i=0; i < sourceOutputType.size(); i++) {
+ if (!isCompatible(targetOutputType.get(i), sourceOutputType.get(i), passByValue, audit)) {
+ if (audit != null){
+ audit.append(" output types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+ }
+
+ if (sourceInputType.size() != targetInputType.size()) {
+ if (audit != null){
+ audit.append("different number of input types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ int size = sourceInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), passByValue, audit)) {
+ if (audit != null){
+ audit.append(" input types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+ }
+
+ // Check fault types
+ for (DataType targetFaultType : target.getFaultTypes()) {
+ // Source fault types must be the same or superset of target fault
+ // types
+ boolean found = true;
+ for (DataType sourceFaultType : source.getFaultTypes()) {
+ found = false;
+ if (isCompatible(targetFaultType, sourceFaultType, passByValue, audit)) {
+ // Target fault type can be covered by the source fault type
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (audit != null){
+ audit.append("Fault types incompatible");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+ public boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, false);
+ }
+
+ public boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType) {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+
+ @Override
+ public boolean isCompatibleWithoutUnwrapByValue(Operation source, Operation target, Compatibility compatibilityType) {
+ if (!source.isInputWrapperStyle() == target.isInputWrapperStyle()) {
+ return false;
+ } else if (!source.isOutputWrapperStyle() == target.isOutputWrapperStyle()) {
+ return false;
+ } else {
+ return isCompatible(source, target, compatibilityType, true);
+ }
+ }
+
+ // FIXME: How to improve the performance for the lookup
+ private Operation getOperation(List<Operation> operations, String name) {
+ for (Operation op : operations) {
+ if (op.getName().equals(name)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ /*
+ * this variant of the checkCompatibility method is intended to supersede the one without an audit argument
+ * Presence of both method variants indicates a state of partial development
+ */
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent,
+ Audit audit)
+ throws IncompatibleInterfaceContractException {
+
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.getInterface() == target.getInterface()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent, audit);
+ }
+
+ if (source.getInterface() == null || target.getInterface() == null) {
+ return false;
+ }
+
+ if (source.getInterface().isDynamic()
+ || target.getInterface().isDynamic()) {
+ return ignoreCallback
+ || isCallbackCompatible(source, target, silent, audit);
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface()
+ .isRemotable()) {
+ if (!silent) {
+ audit.append("Remotable settings do not match: "+ source + "," + target); // TODO see if serialization is sufficient
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Remotable settings do not match", source, target);
+
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getInterface().getOperations()) {
+ Operation targetOperation = map(target.getInterface(), operation);
+ if (targetOperation == null) {
+ if (!silent) {
+ audit.append("Operation " + operation.getName()+ " not found on target");
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Operation " + operation.getName()
+ + " not found on target", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ if (!silent) {
+ if (audit == null)
+ audit = new Audit();
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET, true, audit)) {
+ audit.append("Operations called " + operation.getName()+ " are not compatible");
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException(
+ "Operations called " + operation.getName()
+ + " are not compatible " + audit, source,
+ target);
+ }
+ } else {
+ if (!isCompatible(operation, targetOperation,
+ Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ }
+
+ return ignoreCallback || isCallbackCompatible(source, target, silent, audit);
+ }
+
+ /*
+ * The old checkCompatibility operation without auditing. This just delegates to the new one for the time
+ * being while there are still calls that don't provide and audit object. In the medium term when the calls have
+ * been converted to sue the new opetion directly this should be removed.
+ */
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ Compatibility compatibility,
+ boolean ignoreCallback,
+ boolean silent)
+ throws IncompatibleInterfaceContractException {
+
+ // create dummy audit object.
+ Audit audit = new Audit();
+
+ return checkCompatibility(source,
+ target,
+ compatibility,
+ ignoreCallback,
+ silent,
+ audit);
+ }
+
+
+
+ protected boolean isCallbackCompatible(InterfaceContract source, InterfaceContract target, boolean silent, Audit audit)
+ throws IncompatibleInterfaceContractException {
+ if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) {
+ return true;
+ }
+ if (source.getCallbackInterface() == null || target.getCallbackInterface() == null) {
+ if (!silent) {
+ audit.append("Callback interface doesn't match as one of the callback interfaces is null");
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException("Callback interface doesn't match as one of the callback interfaces is null", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ for (Operation operation : source.getCallbackInterface().getOperations()) {
+ Operation targetOperation =
+ getOperation(target.getCallbackInterface().getOperations(), operation.getName());
+ if (targetOperation == null) {
+ if (!silent) {
+ audit.append("Callback operation not found on target " + operation.getName());
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException("Callback operation not found on target", source,
+ target, null, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ if (!source.getCallbackInterface().isRemotable()) {
+ // FIXME: for remotable operation, only compare name for now
+ if (!operation.equals(targetOperation)) {
+ if (!silent) {
+ audit.append("Target callback operation is not compatible " + operation.getName());
+ audit.appendSeperator();
+ throw new IncompatibleInterfaceContractException("Target callback operation is not compatible",
+ source, target, operation, targetOperation);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public boolean isCompatibleSubset(Interface source, Interface target) {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+ if (source == null || target == null) {
+ return false;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ if (source.isRemotable() != target.isRemotable()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, Compatibility.SUBSET)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /*
+ * the variant of isCompatibleSubset with the audit parameter is intended to supersede the other
+ * -- the presence of both indicates a partial development state
+ */
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target, Audit audit) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false, audit);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ public boolean isCompatibleSubset(InterfaceContract source, InterfaceContract target) {
+
+ try {
+ return checkCompatibility(source, target, Compatibility.SUBSET, false, false);
+ } catch (IncompatibleInterfaceContractException e) {
+ return false;
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#map(org.apache.tuscany.sca.interfacedef.Interface,
+ * org.apache.tuscany.sca.interfacedef.Operation)
+ */
+ public Operation map(Interface target, Operation source) {
+ // TODO: How to handle the case that source operation is dynamic?
+ if (target == null || target.isDynamic()) {
+ return source;
+ } else if (target.isRemotable()) {
+ for (Operation op : target.getOperations()) {
+ if (op.getName().equals(source.getName())) {
+ return op;
+ }
+ }
+ return null;
+ } else {
+ for (Operation op : target.getOperations()) {
+ if (isCompatible(source, op, Compatibility.SUBSET)) {
+ return op;
+ }
+ }
+ return null;
+ }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
new file mode 100644
index 0000000000..01ad56117c
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -0,0 +1,359 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class InterfaceImpl implements Interface {
+
+ private Boolean remotable;
+ private boolean remotableSetFromSCDL = false;
+ private boolean conversational;
+ private OperationList operations = new OperationList();
+ private boolean unresolved;
+
+ private ExtensionType type;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ public boolean isRemotable() {
+ boolean value = false;
+ if (remotable != null && remotable.booleanValue()) {
+ value = true;
+ }
+ return value;
+ }
+
+ public void setRemotable(boolean remotable) {
+ this.remotable = Boolean.valueOf(remotable);
+ }
+
+ public boolean isRemotableSet() {
+ return remotable == null ? false : true;
+ }
+
+ @Override
+ public boolean isRemotableSetFromSCDL() {
+ return remotableSetFromSCDL;
+ }
+
+ @Override
+ public void setRemotableSetFromSCDL() {
+ remotableSetFromSCDL = true;
+ }
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the conversational
+ */
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ /**
+ * @param conversational the conversational to set
+ */
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ private class OperationList extends ArrayList<Operation> {
+ private static final long serialVersionUID = -903469106307606099L;
+
+ @Override
+ public Operation set(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ return super.set(index, element);
+ }
+
+ @Override
+ public void add(int index, Operation element) {
+ element.setInterface(InterfaceImpl.this);
+ super.add(index, element);
+ }
+
+ @Override
+ public boolean add(Operation o) {
+ o.setInterface(InterfaceImpl.this);
+ return super.add(o);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(c);
+ }
+
+ @Override
+ public boolean addAll(int index, Collection<? extends Operation> c) {
+ for (Operation op : c) {
+ op.setInterface(InterfaceImpl.this);
+ }
+ return super.addAll(index, c);
+ }
+
+ }
+
+ @Deprecated
+ public void setDefaultDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ if (op.getDataBinding() == null) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ DataType outputType = op.getOutputType();
+ if (outputType != null && outputType.getDataBinding() == null) {
+ outputType.setDataBinding(dataBinding);
+ }
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ DataType ft = (DataType) d.getLogical();
+ if (ft.getDataBinding() == null) {
+ ft.setDataBinding(dataBinding);
+ }
+
+ }
+ }
+ if (op.isInputWrapperStyle()) {
+ WrapperInfo wrapper = op.getInputWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ }
+ }
+ if (op.isOutputWrapperStyle()) {
+ WrapperInfo wrapper = op.getOutputWrapper();
+ if (wrapper != null) {
+ DataType<List<DataType>> unwrappedOutputType = wrapper.getUnwrappedType();
+ if (unwrappedOutputType != null){
+ for (DataType d : unwrappedOutputType.getLogical()) {
+ if (d.getDataBinding() == null) {
+ d.setDataBinding(dataBinding);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void setDataBinding(DataType dataType, String dataBinding) {
+ if ("java:array".equals(dataType.getDataBinding())) {
+ setDataBinding((DataType)dataType.getLogical(), dataBinding);
+ } else {
+ dataType.setDataBinding(dataBinding);
+ }
+ }
+
+ public void resetDataBinding(String dataBinding) {
+ for (Operation op : getOperations()) {
+ op.setDataBinding(dataBinding);
+ DataType<List<DataType>> inputType = op.getInputType();
+ if (inputType != null) {
+ for (DataType d : inputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ List<DataType> outputTypes = op.getOutputType().getLogical();
+ for ( DataType outputType : outputTypes ) {
+ if (outputType != null) {
+ setDataBinding(outputType, dataBinding);
+ }
+ }
+
+ List<DataType> faultTypes = op.getFaultTypes();
+ if (faultTypes != null) {
+ for (DataType d : faultTypes) {
+ setDataBinding(d, dataBinding);
+ setDataBinding((DataType) d.getLogical(), dataBinding);
+ }
+ }
+ if (op.isInputWrapperStyle()) {
+ WrapperInfo inputWrapper = op.getInputWrapper();
+ if (inputWrapper != null) {
+ DataType<List<DataType>> unwrappedInputType = inputWrapper.getUnwrappedType();
+ if (unwrappedInputType != null) {
+ for (DataType d : unwrappedInputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ }
+ }
+ if (op.isOutputWrapperStyle()) {
+ WrapperInfo outputWrapper = op.getOutputWrapper();
+ if (outputWrapper != null) {
+ DataType<List<DataType>> unwrappedOutputType = outputWrapper.getUnwrappedType();
+ if (unwrappedOutputType != null) {
+ for (DataType d : unwrappedOutputType.getLogical()) {
+ setDataBinding(d, dataBinding);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void resetInterfaceInputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set input types
+ oldOperation.setInputType(newOperation.getInputType());
+
+ // set wrapper
+ if (newOperation.isInputWrapperStyle()) {
+ oldOperation.setInputWrapperStyle(true);
+ oldOperation.setInputWrapper(newOperation.getInputWrapper());
+ }
+ }
+ }
+
+ public void resetInterfaceOutputTypes(Interface newInterface){
+ for (int i = 0; i < getOperations().size(); i++) {
+ // only remote interfaces have a data type model defined
+ // and in this case operations cannot be overloaded so match
+ // operations by name
+ Operation oldOperation = getOperations().get(i);
+ Operation newOperation = null;
+
+ for (Operation tmpOperation : newInterface.getOperations()){
+ if (tmpOperation.getName().equals(oldOperation.getName())){
+ newOperation = tmpOperation;
+ }
+ }
+
+ if (newOperation == null){
+ break;
+ }
+
+ // set output types
+ oldOperation.setOutputType(newOperation.getOutputType());
+
+ // set fault types
+ oldOperation.setFaultTypes(newOperation.getFaultTypes());
+
+ // set wrapper
+ if (newOperation.isOutputWrapperStyle()) {
+ oldOperation.setOutputWrapperStyle(true);
+ oldOperation.setOutputWrapper(newOperation.getOutputWrapper());
+ }
+ }
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ @Override
+ public Object 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);
+ }
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+ return copy;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
new file mode 100644
index 0000000000..8d6cbc6d86
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -0,0 +1,363 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.ParameterMode;
+import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents an operation on a service interface.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public class OperationImpl implements Operation {
+
+ private String name;
+ private boolean unresolved;
+ private DataType<List<DataType>> inputType;
+ private List<DataType> faultTypes;
+ private Interface interfaze;
+ private List<ParameterMode> parameterModes = new ArrayList<ParameterMode>();
+ private boolean nonBlocking;
+ private boolean inputWrapperStyle;
+ private boolean outputWrapperStyle;
+ private WrapperInfo inputWrapper;
+ private WrapperInfo outputWrapper;
+ private boolean dynamic;
+ private boolean notSubjectToWrapping;
+
+ private Map<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();
+
+ private Map<QName, List<DataType<XMLType>>> faultBeans;
+
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private ExtensionType type;
+ private DataType<List<DataType>> outputType;
+ private boolean hasArrayWrappedOutput;
+
+ /**
+ * @param name
+ */
+ public OperationImpl() {
+ inputType = new DataTypeImpl<List<DataType>>(IDL_INPUT, Object[].class, new ArrayList<DataType>());
+ outputType = new DataTypeImpl<List<DataType>>(IDL_OUTPUT, Object[].class, new ArrayList<DataType>());
+ faultTypes = new ArrayList<DataType>();
+ faultBeans = new HashMap<QName, List<DataType<XMLType>>>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+ /**
+ * @return the faultTypes
+ */
+ public List<DataType> getFaultTypes() {
+ return faultTypes;
+ }
+
+ /**
+ * @param faultTypes the faultTypes to set
+ */
+ public void setFaultTypes(List<DataType> faultTypes) {
+ this.faultTypes = faultTypes;
+ }
+
+ /**
+ * @return the inputType
+ */
+ public DataType<List<DataType>> getInputType() {
+ return inputType;
+ }
+
+ /**
+ * @param inputType the inputType to set
+ */
+ public void setInputType(DataType<List<DataType>> inputType) {
+ this.inputType = inputType;
+ }
+
+ /**
+ * @return the outputType
+ */
+ public DataType<List<DataType>> getOutputType() {
+ return this.outputType;
+ }
+
+
+ /**
+ * @param outputType the outputType to set
+ */
+ public void setOutputType(DataType<List<DataType>> outputType) {
+ this.outputType = outputType;
+ }
+
+ /**
+ * @return the interface
+ */
+ public Interface getInterface() {
+ return interfaze;
+ }
+
+ /**
+ * @param interfaze the interface to set
+ */
+ public void setInterface(Interface interfaze) {
+ this.interfaze = interfaze;
+ }
+
+ /**
+ * @return the nonBlocking
+ */
+ public boolean isNonBlocking() {
+ return nonBlocking;
+ }
+
+ /**
+ * @param nonBlocking the nonBlocking to set
+ */
+ public void setNonBlocking(boolean nonBlocking) {
+ this.nonBlocking = nonBlocking;
+ }
+
+ /**
+ * @return the wrapperInfo
+ */
+ public WrapperInfo getInputWrapper() {
+ return inputWrapper;
+ }
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ public void setInputWrapper(WrapperInfo wrapperInfo) {
+ this.inputWrapper = wrapperInfo;
+ }
+
+ /**
+ * @return the wrapperInfo
+ */
+ public WrapperInfo getOutputWrapper() {
+ return outputWrapper;
+ }
+
+ /**
+ * @param wrapperInfo the wrapperInfo to set
+ */
+ public void setOutputWrapper(WrapperInfo wrapperInfo) {
+ this.outputWrapper = wrapperInfo;
+ }
+
+ /**
+ * @return the wrapperStyle
+ */
+ public boolean isInputWrapperStyle() {
+ return inputWrapperStyle;
+ }
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ public void setInputWrapperStyle(boolean wrapperStyle) {
+ this.inputWrapperStyle = wrapperStyle;
+ }
+
+ /**
+ * @return the wrapperStyle
+ */
+ public boolean isOutputWrapperStyle() {
+ return outputWrapperStyle;
+ }
+
+ /**
+ * @param wrapperStyle the wrapperStyle to set
+ */
+ public void setOutputWrapperStyle(boolean wrapperStyle) {
+ this.outputWrapperStyle = wrapperStyle;
+ }
+
+ public String getDataBinding() {
+ if (inputWrapper != null){
+ return inputWrapper.getDataBinding();
+ }
+ if (outputWrapper != null){
+ return outputWrapper.getDataBinding();
+ }
+ return null;
+ }
+
+ public void setDataBinding(String dataBinding) {
+ if (inputWrapper != null) {
+ inputWrapper.setDataBinding(dataBinding);
+ }
+ if (outputWrapper != null) {
+ outputWrapper.setDataBinding(dataBinding);
+ }
+ }
+
+ public boolean isDynamic() {
+ return dynamic;
+ }
+
+ public void setDynamic(boolean b) {
+ this.dynamic = b;
+ }
+
+ public Map<QName, List<DataType<XMLType>>> getFaultBeans() {
+ return faultBeans;
+ }
+
+ public void setFaultBeans(Map<QName, List<DataType<XMLType>>> faultBeans) {
+ this.faultBeans = faultBeans;
+ }
+
+ @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 ( outputType != null ) {
+ List<DataType> clonedLogicalOutputTypes = new ArrayList<DataType>();
+ for ( DataType t : outputType.getLogical()) {
+ if ( t == null ) {
+ clonedLogicalOutputTypes.add(null);
+ } else {
+ DataType type = (DataType) t.clone();
+ clonedLogicalOutputTypes.add(type);
+ }
+ }
+ DataType<List<DataType>> clonedOutputType =
+ new DataTypeImpl<List<DataType>>(outputType.getPhysical(), clonedLogicalOutputTypes);
+ clonedOutputType.setDataBinding(outputType.getDataBinding());
+ copy.outputType = clonedOutputType;
+ }
+
+ copy.attributes = new ConcurrentHashMap<Object, Object>();
+ copy.attributes.putAll(attributes);
+
+ // [rfeng] We need to clone the wrapper as it holds the databinding information
+ if (inputWrapper != null) {
+ copy.inputWrapper = (WrapperInfo)inputWrapper.clone();
+ }
+
+ if (outputWrapper != null) {
+ copy.outputWrapper = (WrapperInfo)outputWrapper.clone();
+ }
+
+ return copy;
+ }
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public ExtensionType getExtensionType() {
+ return type;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public Map<Object, Object> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Indicates if this operation is an async server style of operation
+ * @return true if the operation is async server style
+ */
+ public boolean isAsyncServer() {
+ return false;
+ }
+
+ public List<ParameterMode> getParameterModes() {
+ return this.parameterModes;
+ }
+
+ public boolean hasArrayWrappedOutput() {
+ return this.hasArrayWrappedOutput;
+ }
+
+ public void setHasArrayWrappedOutput(boolean value) {
+ this.hasArrayWrappedOutput = value;
+ }
+
+ public void setNotSubjectToWrapping(boolean notSubjectToWrapping) {
+ this.notSubjectToWrapping = notSubjectToWrapping;
+ }
+
+ public boolean isNotSubjectToWrapping() {
+ return notSubjectToWrapping;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/TuscanyInterfaceContractImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/TuscanyInterfaceContractImpl.java
new file mode 100644
index 0000000000..778af15331
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/TuscanyInterfaceContractImpl.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+
+/**
+ * Represents a Java interface contract.
+ *
+ * @version $Rev: 1149451 $ $Date: 2011-07-22 05:12:56 +0100 (Fri, 22 Jul 2011) $
+ */
+public class TuscanyInterfaceContractImpl extends InterfaceContractImpl {
+
+
+ public TuscanyInterfaceContractImpl() {
+ }
+
+ @Override
+ public TuscanyInterfaceContractImpl clone() throws CloneNotSupportedException {
+ return (TuscanyInterfaceContractImpl) super.clone();
+ }
+
+}