Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Issue using camel split(stax())

$
0
0
I have an issue using camel split with stax (2.12.1) where the
"StAXJAXBIteratorExpression" is not able to match the xml elements to the
jaxb provided class:

The route looks like this where splitClass is PricingProgramEnrollment

.split(stax(splitClass, false))

The jaxb class with annotations looks like:

XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "PricingProgramEnrollmentType", propOrder = {
"userEnrollments"
})
@XmlRootElement(name = "pricingProgramEnrollment")
public class PricingProgramEnrollment
implements Serializable

The xml is :

<?xml version="1.0" encoding="UTF-8" ?>
<pricingProgramEnrollments
xmlns="http://platform.tendrilinc.com/tnop/extension/ems"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://platform.tendrilinc.com/ems/pricing
../../resource/extensions/pricing.xsd">

<pricingProgramEnrollment programName="cheap_energy1">

<userEnrollment accountId="test_enrollments"
effectiveDate="2013-01-01T00:00:00.000" />
</pricingProgramEnrollment>

</pricingProgramEnrollments>

Looking to the stax component code that matches the the tag names with the
provided jaxb class I see that it uses XmlType.class first for the the
matching tag name. and XmlRootElement.class if XmlType.class is not pressent
or empty string. My jaxb class has both annotations and the stax code
selects XmlType to do the matching and that does not match the
<pricingProgramEnrollment> in the xml. Is this a bug should XmlRootElement
should be the first choice? What is the purpose to match XmlType?

public final class StAXUtil {
private static final Map<Class;?>, String> TAG_NAMES = new
LRUSoftCache<Class;?>, String>(1000);

private StAXUtil() {
// no-op

public static String getTagName(Class<?> handled) {
if (TAG_NAMES.containsKey(handled)) {
return TAG_NAMES.get(handled);

XmlType xmlType = handled.getAnnotation(XmlType.class);
if (xmlType != null & xmlType.name() != null &
xmlType.name().trim().length() > 0) {
TAG_NAMES.put(handled, xmlType.name());
return xmlType.name();
} else {
XmlRootElement xmlRoot =
handled.getAnnotation(XmlRootElement.class);
if (xmlRoot != null & xmlRoot.name() != null &
xmlRoot.name().trim().length() > 0) {
TAG_NAMES.put(handled, xmlRoot.name());
return xmlRoot.name();

throw new IllegalArgumentException("XML name not found for " +
handled.getName());

Thanks,

-Marcel Casado

Viewing all articles
Browse latest Browse all 5648

Trending Articles