use of org.apache.camel.dataformat.xmljson.XmlJsonDataFormat in project camel by apache.
the class XmlJsonDataFormatAutoConfiguration method configureXmlJsonDataFormatFactory.
@Bean(name = "xmljson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlJsonDataFormat.class)
public DataFormatFactory configureXmlJsonDataFormatFactory(final CamelContext camelContext, final XmlJsonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlJsonDataFormat dataformat = new XmlJsonDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlJsonDataFormat.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