DataFormatDefinition dformatDefinition = m.getDataFormatType();
if ( dformatDefinition == null ) {
String ref = m.getRef();
if ( "json".equals( ref ) ) {
dformatDefinition = new XStreamDataFormat();
((XStreamDataFormat)dformatDefinition).setDriver( "json" );
} else if ( "xstream".equals( ref ) ) {
dformatDefinition = new XStreamDataFormat();
} else if ( "jaxb".equals( ref ) ) {
dformatDefinition = new JaxbDataFormat();
} else {
dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
}
}
// always clone before changing
dformatDefinition = new FastCloner().deepClone( dformatDefinition );
if ( dformatDefinition instanceof JaxbDataFormat ) {
dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );
} else if ( dformatDefinition instanceof XStreamDataFormat ) {
XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
if ( "json".equals( xstreamDataFormat.getDriver() )) {
dformatDefinition = XStreamJson.newJSonMarshaller( xstreamDataFormat );;
} else {
dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );
}
}
m.setDataFormatType( dformatDefinition ); // repoint the marshaller, if it was cloned
} else if ( child instanceof UnmarshalDefinition ) {
UnmarshalDefinition m = (UnmarshalDefinition) child;
DataFormatDefinition dformatDefinition = m.getDataFormatType();
if ( dformatDefinition == null ) {
String ref = m.getRef();
if ( "json".equals( ref ) ) {
dformatDefinition = new XStreamDataFormat();
((XStreamDataFormat)dformatDefinition).setDriver( "json" );
} else if ( "xstream".equals( ref ) ) {
dformatDefinition = new XStreamDataFormat();
} else if ( "jaxb".equals( ref ) ) {
dformatDefinition = new JaxbDataFormat();
} else {
dformatDefinition = routeContext.getCamelContext().resolveDataFormatDefinition(ref);
}
}
// always clone before changing
dformatDefinition = new FastCloner().deepClone( dformatDefinition );
// Augment the Jaxb DataFormatDefinition, but clone first so we don't alter the original.
if ( dformatDefinition instanceof JaxbDataFormat ) {
dformatDefinition = augmentJaxbDataFormatDefinition( (JaxbDataFormat) dformatDefinition );
} else if ( dformatDefinition instanceof XStreamDataFormat ) {
XStreamDataFormat xstreamDataFormat = ( XStreamDataFormat )dformatDefinition;
if ( "json".equals( xstreamDataFormat.getDriver() )) {
dformatDefinition = XStreamJson.newJSonMarshaller( xstreamDataFormat );;
} else {
dformatDefinition = XStreamXml.newXStreamMarshaller( (XStreamDataFormat) dformatDefinition );
}
}