JAXB transformation fails when ObjectFactory does not produce JAXBElement<?>
----------------------------------------------------------------------------
Key: SWITCHYARD-410
URL:
https://issues.jboss.org/browse/SWITCHYARD-410
Project: SwitchYard
Issue Type: Bug
Components: transformation
Reporter: Keith Babo
Assignee: Tom Fennelly
Fix For: 0.2
JAXBUnmarshalTransformer assumes that the return type for unmarshal will always be a
JAXBElement type, but this is not always true. Take the following generated JAXB
ObjectFactory:
{noformat}
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema
derived classes for package: org.switchyard.demo.openshift
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link Order }
*
*/
public Order createOrder() {
return new Order();
}
/**
* Create an instance of {@link OrderAck }
*
*/
public OrderAck createOrderAck() {
return new OrderAck();
}
}
{noformat}
The above creates a ClassCastException in the transformation code. Suggest a slight tweak
to the logic in JAXBUnmarshalTransformer :
{noformat}
Object unmarshalledObject = unmarshaller.unmarshal(message.getContent(Source.class));
if (unmarshalledObject instanceof JAXBElement) {
message.setContent(((JAXBElement)unmarshalledObject).getValue());
} else {
message.setContent(unmarshalledObject);
}
{noformat}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira