diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
7 files changed, 68 insertions, 85 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 542b9d556e..8d80898071 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -753,39 +753,22 @@ public class Interface2WSDLGenerator { Method method = ((JavaOperation)operation).getJavaMethod(); /* - * Making this change, though not understanding: - * - * 1. Whether we can assume JAXWSJavaInterfaceProcessor was already used to process - * - * 2. What the purpose is of calling getElementInfo() when we already have an ElementInfo - * + * Making this change, though not understanding + * whether we can assume JAXWSJavaInterfaceProcessor was already used to process */ if (input) { - Class<?>[] paramTypes = method.getParameterTypes(); - for (int i = 0, inputsSeen = 0; i < paramTypes.length; i++) { - ParameterMode mode = operation.getParameterModes().get(i); - if (!mode.equals(ParameterMode.OUT)) { - DataType dataType = operation.getInputType().getLogical().get(i); - elements.set(inputsSeen, getElementInfo(paramTypes[i], dataType, elements.get(inputsSeen).getQName(), helpers)); - inputsSeen++; - } + List<DataType> inputDTs = operation.getInputType().getLogical(); + for (int i = 0; i < inputDTs.size(); i++) { + DataType nextInput = inputDTs.get(i); + elements.set(i, getElementInfo(nextInput.getPhysical(), nextInput, elements.get(i).getQName(), helpers)); } + } else { - int outputsSeen = 0; - Class<?> returnType = method.getReturnType(); - if (returnType != Void.TYPE) { - DataType dataType = operation.getOutputType().getLogical().get(0); - elements.set(outputsSeen++, getElementInfo(returnType, dataType, elements.get(0).getQName(), helpers)); + List<DataType> outputDTs = operation.getOutputType().getLogical(); + for (int i = 0; i < outputDTs.size(); i++) { + DataType nextOutput = outputDTs.get(i); + elements.set(i, getElementInfo(nextOutput.getPhysical(), nextOutput, elements.get(i).getQName(), helpers)); } - Class<?>[] paramTypes = method.getParameterTypes(); - for (int i = 0; i < paramTypes.length; i++) { - ParameterMode mode = operation.getParameterModes().get(i); - if (!mode.equals(ParameterMode.IN)) { - DataType dataType = operation.getOutputType().getLogical().get(i); - elements.set(outputsSeen, getElementInfo(paramTypes[i], dataType, elements.get(outputsSeen).getQName(), helpers)); - outputsSeen++; - } - } } } return part; diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java index 9fa9038006..f369b491e7 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java @@ -462,9 +462,8 @@ public final class JAXBContextHelper { { for (DataType dt1 : op.getInputType().getLogical()) { dataTypes.add(dt1); - } - DataType dt2 = op.getOutputType(); - if (dt2 != null) { + } + for (DataType dt2 : op.getOutputType().getLogical()) { dataTypes.add(dt2); } } diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java index 6759edc992..0ba35866d9 100644 --- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java +++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java @@ -559,30 +559,26 @@ public class MediatorImpl implements Mediator { List<DataType> inputTypesTarget = targetOperation == null ? null : targetOperation.getInputType().getLogical(); Object[] copy = new Object[data.length]; Map<Object, Object> map = new IdentityHashMap<Object, Object>(); - for (int i = 0, nextIndex = 0; i < inputTypes.size(); i++) { - // Account for OUT-only parameters. Would be more thorough to look at targetOperation - // and ensure it has the same parameter mode, but we'll let that go for now. - ParameterMode mode = sourceOperation.getParameterModes().get(i); - if (!mode.equals(ParameterMode.OUT)) { - Object arg = data[nextIndex]; - if (arg == null) { - copy[nextIndex] = null; + + // OUT-only parameters have already been filtered out of the inputTypes List. + for (int i = 0; i < inputTypes.size(); i++) { + Object arg = data[i]; + if (arg == null) { + copy[i] = null; + } else { + Object copiedArg = map.get(arg); + if (copiedArg != null) { + copy[i] = copiedArg; } else { - Object copiedArg = map.get(arg); - if (copiedArg != null) { - copy[nextIndex] = copiedArg; - } else { - copiedArg = - copy(arg, - inputTypes.get(i), - inputTypesTarget == null ? null : inputTypesTarget.get(i), - sourceOperation, - targetOperation); - map.put(arg, copiedArg); - copy[nextIndex] = copiedArg; - } + copiedArg = + copy(arg, + inputTypes.get(i), + inputTypesTarget == null ? null : inputTypesTarget.get(i), + sourceOperation, + targetOperation); + map.put(arg, copiedArg); + copy[i] = copiedArg; } - nextIndex++; } } return copy; diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java index ef325e4ae9..67bbe32c27 100644 --- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java +++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java @@ -132,14 +132,13 @@ public class JavaImplementationInvoker implements Invoker { // Holder pattern. Any payload parameters <T> which are should be in holders are placed in Holder<T>. // Only check Holder for remotable interfaces if (imethod != null && op.getInterface().isRemotable()) { - List<DataType> inputTypes = op.getInputType().getLogical(); Object[] payloadArray = (Object[])payload; List<Object> payloadList = new ArrayList<Object>(); - for (int i = 0, nextIndex = 0; i < inputTypes.size(); i++) { - ParameterMode mode = op.getParameterModes().get(i); - if (ParameterMode.IN == mode ) { + int nextIndex = 0; + for (ParameterMode mode : op.getParameterModes()) { + if (mode.equals(ParameterMode.IN)) { payloadList.add(payloadArray[nextIndex++]); - } else if (ParameterMode.INOUT == mode ) { + } else if (mode.equals(ParameterMode.INOUT)) { // Promote array params from [<T>] to [Holder<T>] Object item = payloadArray[nextIndex++]; Holder itemHolder = new Holder(item); diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java index 8e65cca7e6..57f2b9c3a1 100644 --- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java @@ -186,11 +186,7 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { } ParameterMode mode = operation.getParameterModes().get(i); } - - // - // Note for BARE mapping this will NOT be WS-I compliant, but let's assume this is not the place to - // worry about non-compliance, and keep on going. - // + WebResult result = method.getAnnotation(WebResult.class); if (result != null) { String ns = getValue(result.targetNamespace(), tns); @@ -351,6 +347,19 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { operation.setWrapper(wrapperInfo); } + + // In both bare and wrapped cases, remove OUT-only parameters from input DataType. + // This is a key point then because it's the last time in which the number of parameters in + // Java matches the number of logical inputs. After this, things will be out of synch, for + // example the number of parameter modes won't match the number of inputs. + List<ParameterMode> parmModes = operation.getParameterModes(); + List<DataType> inputDTs = operation.getInputType().getLogical(); + for (int i = parmModes.size() - 1; i>=0; i--) { + if (parmModes.get(i).equals(ParameterMode.OUT)) { + inputDTs.remove(i); + } + } + } } 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(); |