Author: mmusaji
Date: 2013-03-06 10:45:31 -0500 (Wed, 06 Mar 2013)
New Revision: 17387
Modified:
thirdparty/cxf/branches/cxf-2.2.12/
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
Log:
[JBPAPP-10650] Added fix to make sure collections using generics are reflected correctly
in the WSDL
Property changes on: thirdparty/cxf/branches/cxf-2.2.12
___________________________________________________________________
Modified: svn:mergeinfo
- /thirdparty/cxf/branches/cxf-2.2.12-patch02_JBPAPP-10129:16821-17233
+ /thirdparty/cxf/branches/cxf-2.2.12-patch-02_JBPAPP-10651:17344
/thirdparty/cxf/branches/cxf-2.2.12-patch02_JBPAPP-10129:16821-17233
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java 2013-03-06
15:36:26 UTC (rev 17386)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java 2013-03-06
15:45:31 UTC (rev 17387)
@@ -572,6 +572,12 @@
for (Field f : Utils.getFields(cls, accessType)) {
//map field
Type type = Utils.getFieldType(f);
+ //we want to return the right type for collections so if we get null
+ //from the return type we check if it's ParameterizedType and get the
+ //generic return type.
+ if((type==null) && (f.getGenericType() instanceof ParameterizedType))
{
+ type = f.getGenericType();
+ }
JAXBBeanInfo beanInfo = getBeanInfo(type);
if (beanInfo != null) {
addElement(elementList, beanInfo, new QName(namespace, f.getName()),
isArray(type));
@@ -580,6 +586,12 @@
for (Method m : Utils.getGetters(cls, accessType)) {
//map method
Type type = Utils.getMethodReturnType(m);
+ //we want to return the right type for collections so if we get null
+ //from the return type we check if it's ParameterizedType and get the
+ //generic return type.
+ if((type==null) && (m.getGenericReturnType() instanceof
ParameterizedType)) {
+ type = m.getGenericReturnType();
+ }
JAXBBeanInfo beanInfo = getBeanInfo(type);
if (beanInfo != null) {
int idx = m.getName().startsWith("get") ? 3 : 2;
Modified:
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
===================================================================
---
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java 2013-03-06
15:36:26 UTC (rev 17386)
+++
thirdparty/cxf/branches/cxf-2.2.12/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java 2013-03-06
15:45:31 UTC (rev 17387)
@@ -204,14 +204,27 @@
static Class<?> getFieldType(Field f) {
XmlJavaTypeAdapter adapter = getFieldXJTA(f);
+ if(adapter==null) {
+ if(f.getGenericType() instanceof ParameterizedType) {
+ return null;
+ }
+ }
Class<?> adapterType = getTypeFromXmlAdapter(adapter);
return adapterType != null ? adapterType : f.getType();
}
static Class<?> getMethodReturnType(Method m) {
- XmlJavaTypeAdapter adapter = getMethodXJTA(m);
- Class<?> adapterType = getTypeFromXmlAdapter(adapter);
- return adapterType != null ? adapterType : m.getReturnType();
+ XmlJavaTypeAdapter adapter = getMethodXJTA(m);
+ //if there is no adapter, yet we have a collection make sure
+ //we return the Generic type; if there is an annotation let the
+ //adapter handle what gets populated
+ if(adapter==null) {
+ if(m.getGenericReturnType() instanceof ParameterizedType) {
+ return null;
+ }
+ }
+ Class<?> adapterType = getTypeFromXmlAdapter(adapter);
+ return adapterType != null ? adapterType : m.getReturnType();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
Show replies by date