diff options
author | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-26 01:18:02 +0000 |
---|---|---|
committer | scottkurz <scottkurz@13f79535-47bb-0310-9956-ffa450edef68> | 2011-01-26 01:18:02 +0000 |
commit | dac345d5480d52c4071c22fbdeba605dc1236cc0 (patch) | |
tree | c63f2f6803ec3f22357558d58f55ddfe3e753af6 /sca-java-2.x/trunk/modules/interface-java | |
parent | 875e50908c2630d263661af492654cd44bef2d65 (diff) |
Fix more issues with multiple outputs.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1063548 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-java')
2 files changed, 19 insertions, 22 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java index 0d1e832faf..1ffe9530b7 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java @@ -259,6 +259,8 @@ public class JavaInterfaceIntrospectorImpl { JavaOperation operation = new JavaOperationImpl(); operation.setName(name); + // Given details of Holder mapping, it's easier to handle output first. + List<DataType> outputDataTypes = new ArrayList<DataType>(); XMLType xmlReturnType = new XMLType(new QName(ns, "return"), null); DataType<XMLType> returnDataType = null; if (returnType == void.class) { @@ -267,12 +269,11 @@ public class JavaInterfaceIntrospectorImpl { returnDataType = new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method.getGenericReturnType(), xmlReturnType); operation.setReturnTypeVoid(false); + outputDataTypes.add(returnDataType); } // Handle Input Types List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length); - List<Type> genericHolderTypes = new ArrayList<Type>(); - List<Class<?>> physicalHolderTypes = new ArrayList<Class<?>>(); Type[] genericParamTypes = method.getGenericParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { Class<?> paramType = parameterTypes[i]; @@ -284,35 +285,17 @@ public class JavaInterfaceIntrospectorImpl { // Holder pattern. Physical types of Holder<T> classes are updated to <T> to aid in transformations. if ( Holder.class == paramType) { hasMultipleOutputs = true; - genericHolderTypes.add(genericParamTypes[i]); Type firstActual = getFirstActualType( genericParamTypes[ i ] ); if ( firstActual != null ) { - physicalHolderTypes.add((Class<?>)firstActual); xmlDataType.setPhysical( (Class<?>)firstActual ); mode = ParameterMode.INOUT; - } else { - physicalHolderTypes.add(xmlDataType.getPhysical()); - } + } + outputDataTypes.add(xmlDataType); } paramDataTypes.add( xmlDataType); operation.getParameterModes().add(mode); } - // Get Output Types, but skip over void return type - List<DataType> outputDataTypes = new ArrayList<DataType>(); - if (!operation.hasReturnTypeVoid()) { - outputDataTypes.add(returnDataType); - } - - // Start at 1, for the first holder, since we already accounted for the return type itself - for ( int i=1; i < allOutputTypes.length; i++ ) { - Class<?> paramType = allOutputTypes[i]; - XMLType xmlOutputType = new XMLType(new QName(ns, "out" + i), null); - DataTypeImpl<XMLType> xmlDataType = xmlDataType = new DataTypeImpl<XMLType>( - UNKNOWN_DATABINDING, physicalHolderTypes.get(i-1), genericHolderTypes.get(i-1), xmlOutputType); - outputDataTypes.add(xmlDataType); - } - // Fault types List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length); Type[] genericFaultTypes = method.getGenericExceptionTypes(); diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java index 352cffeef2..922772ab07 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java @@ -27,6 +27,7 @@ import java.util.List; 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.java.JavaInterface; import org.apache.tuscany.sca.interfacedef.java.JavaOperation; @@ -64,6 +65,17 @@ public final class JavaInterfaceUtil { } Interface interface1 = operation.getInterface(); int numParams = operation.getInputType().getLogical().size(); + + // Account for OUT-only in matching. (Should we cache this number in JavaOperation?) + List<ParameterMode> parmModes = operation.getParameterModes(); + int numOutOnlyHolders = 0; + for (ParameterMode mode : parmModes) { + if (mode.equals(ParameterMode.OUT)) { + numOutOnlyHolders++; + } + } + numParams += numOutOnlyHolders; + if (interface1 != null && interface1.isRemotable()) { List<Method> matchingMethods = new ArrayList<Method>(); for (Method m : implClass.getMethods()) { @@ -138,6 +150,7 @@ public final class JavaInterfaceUtil { /** * @Deprecated */ + //TODO - account for Holder(s) private static Class<?>[] getPhysicalTypes(Operation operation) { DataType<List<DataType>> inputType = operation.getInputType(); if (inputType == null) { @@ -178,6 +191,7 @@ public final class JavaInterfaceUtil { * * @return true if the operation matches, false if does not */ + //TODO - account for Holder(s) private static boolean match(Operation operation, Method method) { Class<?>[] params = method.getParameterTypes(); DataType<List<DataType>> inputType = operation.getInputType(); |