use of org.apache.camel.component.johnzon.JohnzonDataFormat in project camel by apache.
the class JohnzonDataFormatAutoConfiguration method configureJohnzonDataFormatFactory.
@Bean(name = "json-johnzon-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JohnzonDataFormat.class)
public DataFormatFactory configureJohnzonDataFormatFactory(final CamelContext camelContext, final JohnzonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JohnzonDataFormat dataformat = new JohnzonDataFormat();
if (CamelContextAware.class.isAssignableFrom(JohnzonDataFormat.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