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