in modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java [203:332]
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;
}