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