use of org.apache.camel.component.jacksonxml.JacksonXMLDataFormat in project camel by apache.
the class JacksonXMLDataFormatAutoConfiguration method configureJacksonXMLDataFormatFactory.
@Bean(name = "jacksonxml-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonXMLDataFormat.class)
public DataFormatFactory configureJacksonXMLDataFormatFactory(final CamelContext camelContext, final JacksonXMLDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JacksonXMLDataFormat dataformat = new JacksonXMLDataFormat();
if (CamelContextAware.class.isAssignableFrom(JacksonXMLDataFormat.class)) {
CamelContextAware contextAware = CamelContextAware.class.cast(dataformat);
if (contextAware != null) {
contextAware.setCamelContext(camelContext);
}
}
try {
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), dataformat, parameters);
} catch (Exception e) {
throw new RuntimeCamelException(e);
}
return dataformat;
}
};
}
Aggregations