diff options
author | beckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-11 22:14:15 +0000 |
---|---|---|
committer | beckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-11 22:14:15 +0000 |
commit | 06411d4f4afcb69eafa24cadad267eb6681ddaa2 (patch) | |
tree | 11847614377caa655975d65becf85a2f79eb4fa6 /branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca | |
parent | 77e0d936ff50694b2c450ab74a4490f2462bc93f (diff) |
TUSCANY-2332 Web services Holder support
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@733526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java index 126b435989..fe99adccec 100644 --- a/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java +++ b/branches/sca-java-1.x/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java @@ -224,14 +224,26 @@ public class JavaInterfaceIntrospectorImpl { DataType<XMLType> returnDataType = returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method .getGenericReturnType(), xmlReturnType); + + // Input types List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length); Type[] genericParamTypes = method.getGenericParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { Class paramType = parameterTypes[i]; XMLType xmlParamType = new XMLType(new QName(ns, "arg" + i), null); - paramDataTypes.add(new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, paramType, genericParamTypes[i], - xmlParamType)); + DataTypeImpl<XMLType> xmlDataType = new DataTypeImpl<XMLType>( + UNKNOWN_DATABINDING, paramType, genericParamTypes[i],xmlParamType); + // Holder pattern. Physical types of Holder<T> classes are updated to <T> to aid in transformations. + if ( isHolder( paramType )) { + Type firstActual = getFirstActualType( genericParamTypes[ i ] ); + if ( firstActual != null ) { + xmlDataType.setPhysical( (Class<?>)firstActual ); + } + } + paramDataTypes.add( xmlDataType); } + + // Fault types List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length); Type[] genericFaultTypes = method.getGenericExceptionTypes(); for (int i = 0; i < faultTypes.length; i++) { @@ -263,4 +275,31 @@ public class JavaInterfaceIntrospectorImpl { return operations; } + /** + * Given a Class, tells if it is a Holder by comparing to "javax.xml.ws.Holder" + * @param testClass + * @return boolean whether testClass is Holder type. + */ + protected static boolean isHolder( Class testClass ) { + if ( testClass.getName().startsWith( "javax.xml.ws.Holder" )) { + return true; + } + return false; + } + + /** + * Given a Class<T>, returns T, otherwise null. + * @param testClass + * @return + */ + protected static Type getFirstActualType(Type genericType) { + if (genericType instanceof ParameterizedType) { + ParameterizedType pType = (ParameterizedType)genericType; + Type[] actualTypes = pType.getActualTypeArguments(); + if ((actualTypes != null) && (actualTypes.length > 0)) { + return actualTypes[0]; + } + } + return null; + } } |