use of org.apache.camel.spi.DataFormatFactory in project camel by apache.
the class UniVocityFixedWidthDataFormatAutoConfiguration method configureUniVocityFixedWidthDataFormatFactory.
@Bean(name = "univocity-fixed-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityFixedWidthDataFormat.class)
public DataFormatFactory configureUniVocityFixedWidthDataFormatFactory(final CamelContext camelContext, final UniVocityFixedWidthDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
UniVocityFixedWidthDataFormat dataformat = new UniVocityFixedWidthDataFormat();
if (CamelContextAware.class.isAssignableFrom(UniVocityFixedWidthDataFormat.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;
}
};
}
use of org.apache.camel.spi.DataFormatFactory in project camel by apache.
the class OsgiDataFormatResolver method createDataFormat.
public DataFormat createDataFormat(String name, CamelContext context) {
DataFormat dataFormat = null;
// lookup in registry first
DataFormatFactory dataFormatFactory = ResolverHelper.lookupDataFormatFactoryInRegistryWithFallback(context, name);
if (dataFormatFactory != null) {
dataFormat = dataFormatFactory.newInstance();
}
if (dataFormat == null) {
dataFormat = getDataFormat(name, context, true);
}
return dataFormat;
}
Aggregations