use of org.apache.camel.converter.xmlbeans.XmlBeansDataFormat in project camel by apache.
the class XmlBeansDataFormatAutoConfiguration method configureXmlBeansDataFormatFactory.
@Bean(name = "xmlBeans-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlBeansDataFormat.class)
public DataFormatFactory configureXmlBeansDataFormatFactory(final CamelContext camelContext, final XmlBeansDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlBeansDataFormat dataformat = new XmlBeansDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlBeansDataFormat.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