Author: jason.greene(a)jboss.com
Date: 2007-02-28 21:29:01 -0500 (Wed, 28 Feb 2007)
New Revision: 2487
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
Log:
Fix CTS regression that was introduced in change 2253.
Also add all caps comment to hopefully prevent the code from being removed again
This obviates the change in 2294 which only solved one side-effect
Modified: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-03-01
02:26:47 UTC (rev 2486)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2007-03-01
02:29:01 UTC (rev 2487)
@@ -71,7 +71,7 @@
Result result = null;
try
{
- Class javaType = deriveType(value);
+ Class javaType = deriveType(value, xmlType, serContext.getTypeMapping());
JAXBContextCache contextCache = JAXBContextCache.getContextCache();
JAXBContext jaxbContext = contextCache.getInstance(javaType);
@@ -95,19 +95,17 @@
return result;
}
-
- private Class deriveType(Object value)
+
+ private Class deriveType(Object value, QName xmlType, TypeMappingImpl typeMapping)
throws BindingException
{
- // It needs to be a valid JAXB type
- // Therefore we don't need to look into our TypeMapping
- Class javaType = value.getClass();
+ // DO NOT REMOVE TYPE MAPPING CODE!!!
+ // We must pass the base type to JAXB so that xsi:type is serialized
+ List<Class> possibleJavaTypes = typeMapping.getJavaTypes(xmlType);
+ for(Class type : possibleJavaTypes)
+ if(JavaUtils.isAssignableFrom(type, value.getClass()))
+ return type;
- // Filter known interface types
- // Implementation classes will cause JAXB to fail
- if (XMLGregorianCalendar.class.isAssignableFrom(javaType))
- javaType = XMLGregorianCalendar.class;
-
- return javaType;
+ throw new BindingException("Unable to resolve target java type");
}
// 4.21 Conformance (Marshalling failure): If an error occurs when using the supplied
JAXBContext to marshall
Show replies by date