summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java23
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java10
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java4
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java15
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java63
-rw-r--r--sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java31
-rw-r--r--sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java2
-rw-r--r--sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java5
8 files changed, 112 insertions, 41 deletions
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 9eade3ba5c..69da9019a8 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
@@ -162,23 +162,24 @@ public class JavaImplementationInvoker implements Invoker {
if (argumentHolderCount > 0) {
- // Holder pattern. Any payload Holder<T> types are returned as the message body.
- List<Object> returnArgs = new ArrayList<Object>();
- returnArgs.add(ret);
+
+ // Holder pattern. Any payload Holder<T> types are returned as part of the message body.
+ Object[] payloadArray = (Object[])payload;
+ ArrayList<Object> result = new ArrayList<Object>();
if (imethod != null) {
- Object[] payloadArray = (Object[])payload;
- for (int i = 0, size = op.getParameterModes().size(); i < size; i++) {
- // System.out.println( "JavaImplementationInvoker.invoke return parameter " + i + " type=" + parameter.getClass().getName() );
+
+ result.add(ret);
+ for (int i = 0, size = op.getParameterModes().size(); i < size; i++) {
if (ParameterMode.IN != op.getParameterModes().get(i)) {
- // Demote array params from Holder<T> to <T>.
- Holder<Object> item = (Holder<Object>)payloadArray[i];
- payloadArray[i] = item.value;
- returnArgs.add(payloadArray[i]);
+ // Demote array params from Holder<T> to <T>.
+ Holder<Object> item = (Holder<Object>)payloadArray[i];
+ payloadArray[i] = item.value;
+ result.add(payloadArray[i]);
}
}
}
- msg.setBody(returnArgs.toArray());
+ msg.setBody(result.toArray());
} else {
msg.setBody(ret);
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java
index a866c5b8e1..a57a0b4678 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java
@@ -82,7 +82,7 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor {
*/
private static boolean isJAXWSAsyncPoolingOperation(Operation operation, Operation asyncOperation) {
- if (asyncOperation.getOutputType() == null || Response.class != asyncOperation.getOutputType().getPhysical()) {
+ if (asyncOperation.getOutputType().getLogical().get(0) == null || Response.class != asyncOperation.getOutputType().getLogical().get(0).getPhysical()) {
// The return type is not Response<T>
return false;
}
@@ -101,8 +101,8 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor {
}
//a return type of Response<R> where R is the return type of M
- DataType<?> operationOutputType = operation.getOutputType();
- DataType<?> asyncOperationOutputType = asyncOperation.getOutputType();
+ DataType<?> operationOutputType = operation.getOutputType().getLogical().get(0);
+ DataType<?> asyncOperationOutputType = asyncOperation.getOutputType().getLogical().get(0);
if (operationOutputType != null && asyncOperationOutputType != null) {
Class<?> asyncReturnTypeClass = (Class<?>)asyncOperationOutputType.getPhysical();
@@ -149,7 +149,7 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor {
*/
private static boolean isJAXWSAsyncCallbackOperation(Operation operation, Operation asyncOperation) {
- if (asyncOperation.getOutputType() == null || Future.class != asyncOperation.getOutputType().getPhysical()) {
+ if (asyncOperation.getOutputType().getLogical().get(0) == null || Future.class != asyncOperation.getOutputType().getLogical().get(0).getPhysical()) {
// The return type is not Future<?>
return false;
}
@@ -173,7 +173,7 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor {
Class<?> asyncLastParameterTypeClass = asyncOperationInputType.get(size).getPhysical();
if (asyncLastParameterTypeClass == AsyncHandler.class) {
//now check the actual type of the AsyncHandler<R> with R
- Class<?> returnType = operation.getOutputType().getPhysical();
+ Class<?> returnType = operation.getOutputType().getLogical().get(0).getPhysical();
Class<?> asyncActualLastParameterTypeClass = Object.class;
if (genericParamType instanceof ParameterizedType) {
ParameterizedType asyncLastParameterType = (ParameterizedType)genericParamType;
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 735f8cf269..74b2b53543 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
@@ -306,8 +306,8 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
name = getValue(name, "return");
QName element = new QName(ns, name);
- if (operation.getOutputType() != null) {
- Object logical = operation.getOutputType().getLogical();
+ if ((operation.getOutputType() != null) && ( operation.getOutputType().getLogical().get(0) != null)) {
+ Object logical = operation.getOutputType().getLogical().get(0).getLogical();
QName type = null;
if (logical instanceof XMLType) {
((XMLType)logical).setElementName(element);
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
index a217f3ea0c..1dcd89ce2a 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
@@ -201,7 +201,7 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
DataType<List<DataType>> requestParams = operation.getInputType();
DataType<List<DataType>> inputType = prepareSyncInputParams( requestParams );
- DataType<XMLType> returnDataType = prepareSyncReturnParam( requestParams );
+ DataType<List<DataType>> returnDataType = prepareSyncReturnParam( requestParams );
List<DataType> faultDataTypes = prepareSyncFaults( operation );
syncOperation.setName(opName);
@@ -246,7 +246,7 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
* @param requestParams - - async method input parameters
* @return - the sync method return parameter
*/
- private DataType<XMLType> prepareSyncReturnParam( DataType<List<DataType>> requestParams ) {
+ private DataType<List<DataType>> prepareSyncReturnParam( DataType<List<DataType>> requestParams ) {
List<DataType> requestLogical = requestParams.getLogical();
int paramCount = requestLogical.size();
@@ -271,7 +271,14 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
DataType<XMLType> returnDataType =
returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, xmlReturnType);
- return returnDataType;
+ ArrayList<DataType> returnTypes = new ArrayList<DataType>();
+ returnTypes.add(returnDataType);
+
+ DataType<List<DataType>> outputType =
+ new DataTypeImpl<List<DataType>>(requestParams.getDataBinding(),
+ requestParams.getPhysical(), returnTypes);
+
+ return outputType;
} // end method prepareSyncReturnParam
/**
@@ -294,7 +301,7 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
// 1) void return type
// 2) name ending in "Async"
// 3) final parameter which is of ResponseDispatch<?> type
- DataType<?> response = operation.getOutputType();
+ DataType<?> response = operation.getOutputType().getLogical().get(0);
if( response != null ) {
if ( response.getPhysical() != void.class ) return false;
} // end if
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 7f33b0545e..a4629333d5 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
@@ -64,6 +64,7 @@ import org.oasisopen.sca.annotation.Remotable;
*/
public class JavaInterfaceIntrospectorImpl {
public static final String IDL_INPUT = "idl:input";
+ public static final String IDL_OUTPUT = "idl:output";
private static final String UNKNOWN_DATABINDING = null;
@@ -185,6 +186,7 @@ public class JavaInterfaceIntrospectorImpl {
List<Operation> operations = new ArrayList<Operation>(methods.length);
Set<String> names = remotable ? new HashSet<String>() : null;
for (Method method : methods) {
+ boolean hasHolders = false;
if (method.getDeclaringClass() == Object.class) {
// Skip the methods on the Object.class
continue;
@@ -202,6 +204,7 @@ public class JavaInterfaceIntrospectorImpl {
getActualTypes(method.getGenericParameterTypes(), method.getParameterTypes(), typeBindings);
Class<?>[] faultTypes =
getActualTypes(method.getGenericExceptionTypes(), method.getExceptionTypes(), typeBindings);
+ Class<?>[] allOutputTypes = getOutputTypes(returnType, parameterTypes);
// For async server interfaces, faults are described using the @AsyncFaults annotation
if( method.isAnnotationPresent(AsyncFault.class) ) {
@@ -230,7 +233,12 @@ public class JavaInterfaceIntrospectorImpl {
DataType<XMLType> returnDataType =
returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method
.getGenericReturnType(), xmlReturnType);
- List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length);
+
+
+ // 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];
@@ -241,16 +249,40 @@ public class JavaInterfaceIntrospectorImpl {
ParameterMode mode = ParameterMode.IN;
// Holder pattern. Physical types of Holder<T> classes are updated to <T> to aid in transformations.
if ( Holder.class == paramType) {
+ hasHolders = 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());
}
}
paramDataTypes.add( xmlDataType);
operation.getParameterModes().add(mode);
}
-
+
+
+ // Get Output Types
+ List<DataType> outputDataTypes = new ArrayList<DataType>(allOutputTypes.length);
+ Type genericReturnType = method.getGenericReturnType();
+
+ for ( int i=0; i <= genericHolderTypes.size(); i++ ) {
+ Class<?> paramType = allOutputTypes[i];
+ XMLType xmlOutputType = new XMLType(new QName(ns, "out" + i), null);
+
+ if ( i == 0 ) {
+ outputDataTypes.add(returnDataType);
+ } else {
+ 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();
@@ -273,18 +305,37 @@ public class JavaInterfaceIntrospectorImpl {
DataType<List<DataType>> inputType =
new DataTypeImpl<List<DataType>>(IDL_INPUT, Object[].class, paramDataTypes);
-
- operation.setInputType(inputType);
- operation.setOutputType(returnDataType);
+ DataType<List<DataType>> outputType =
+ new DataTypeImpl<List<DataType>>(IDL_OUTPUT, Object[].class, outputDataTypes);
+
+ operation.setOutputType(outputType);
+
+ operation.setInputType(inputType);
operation.setFaultTypes(faultDataTypes);
operation.setNonBlocking(nonBlocking);
operation.setJavaMethod(method);
+ operation.setHasHolders(hasHolders);
operations.add(operation);
}
return operations;
}
- /**
+
+ private Class<?>[] getOutputTypes(Class<?> returnType, Class<?>[] parameterTypes) {
+ Class<?>[] returnTypes = new Class<?>[parameterTypes.length + 1];
+ returnTypes[0] = returnType;
+ int idx = 1;
+ for ( Class<?> clazz : parameterTypes ) {
+ if ( Holder.class == clazz )
+ returnTypes[idx++] = clazz;
+ }
+
+ return returnTypes;
+ }
+
+
+
+ /**
* Reads the fault types declared in an @AsyncFault annotation on an async server method
* @param method - the Method
* @return - an array of fault/exception classes
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
index 3fd476c46f..67191cd43d 100644
--- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
+++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
@@ -149,24 +149,35 @@ public class WSDLOperationIntrospectorImpl {
* @throws NotSupportedWSDLException
*/
@SuppressWarnings("unchecked")
- public DataType<XMLType> getOutputType() throws InvalidWSDLException {
+ public DataType<List<DataType>> getOutputType() throws InvalidWSDLException {
if (outputType == null) {
Output output = operation.getOutput();
Message outputMsg = (output == null) ? null : output.getMessage();
- List outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null);
+ operation.getInput();
+ List<Part> outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null);
+ ArrayList<DataType> partTypes = new ArrayList<DataType>();
if (outputParts != null && outputParts.size() > 0) {
- if (outputParts.size() > 1) {
- // We don't support output with multiple parts
- if (logger.isLoggable(Level.WARNING)) {
- logger.warning("Multi-part output is not supported, please use BARE parameter style.");
- }
- // throw new InvalidWSDLException("Multi-part output is not supported");
+// if (outputParts.size() > 1) {
+// // We don't support output with multiple parts
+// if (logger.isLoggable(Level.WARNING)) {
+// logger.warning("Multi-part output is not supported, please use BARE parameter style.");
+// }
+// // throw new InvalidWSDLException("Multi-part output is not supported");
+// }
+ for ( Part part : outputParts ) {
+ DataType partType = new WSDLPart(part, Object.class).getDataType();
+ partTypes.add(partType);
}
- Part part = (Part)outputParts.get(0);
- outputType = new WSDLPart(part, Object.class).getDataType();
+
// outputType.setMetadata(WSDLOperation.class.getName(), this);
+ } else {
+ partTypes.add(null);
}
+
+
+ outputType =
+ new DataTypeImpl<List<DataType>>(dataBinding, Object[].class, partTypes);
}
return outputType;
}
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
index 1e66f7c4e4..5b7a5ec966 100644
--- a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
+++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
@@ -73,7 +73,7 @@ public class WSDLInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
Assert.assertEquals("getLastTradePrice", operation.getName());
DataType<List<DataType>> inputType = operation.getInputType();
Assert.assertEquals(1, inputType.getLogical().size());
- DataType<XMLType> returnType = operation.getOutputType();
+ DataType<List<DataType>> returnType = operation.getOutputType();
Assert.assertNotNull(returnType);
Assert.assertEquals(0, operation.getFaultTypes().size());
// Assert.assertEquals(1,
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
index c4549f8180..f16ab9c73a 100644
--- a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
+++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
@@ -67,9 +67,10 @@ public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase {
DataType<XMLType> type = inputType.getLogical().get(0);
Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), type.getLogical().getElementName());
- DataType<XMLType> outputType = op.getOutputType();
+ DataType<List<DataType>> outputType = op.getOutputType();
+ DataType<XMLType> logical = outputType.getLogical().get(0);
Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"),
- outputType.getLogical().getElementName());
+ logical.getLogical().getElementName());
Assert.assertTrue(op.isWrapperStyle());
DataType<List<DataType>> unwrappedInputType = op.getWrapper().getUnwrappedInputType();