use of org.apache.camel.CamelContextAware in project camel by apache.
the class TarFileDataFormatAutoConfiguration method configureTarFileDataFormatFactory.
@Bean(name = "tarfile-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TarFileDataFormat.class)
public DataFormatFactory configureTarFileDataFormatFactory(final CamelContext camelContext, final TarFileDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
TarFileDataFormat dataformat = new TarFileDataFormat();
if (CamelContextAware.class.isAssignableFrom(TarFileDataFormat.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.CamelContextAware in project camel by apache.
the class UniVocityCsvDataFormatAutoConfiguration method configureUniVocityCsvDataFormatFactory.
@Bean(name = "univocity-csv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityCsvDataFormat.class)
public DataFormatFactory configureUniVocityCsvDataFormatFactory(final CamelContext camelContext, final UniVocityCsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
UniVocityCsvDataFormat dataformat = new UniVocityCsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(UniVocityCsvDataFormat.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.CamelContextAware 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.CamelContextAware 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;
}
};
}
use of org.apache.camel.CamelContextAware in project camel by apache.
the class StringDataFormatAutoConfiguration method configureStringDataFormatFactory.
@Bean(name = "string-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(StringDataFormat.class)
public DataFormatFactory configureStringDataFormatFactory(final CamelContext camelContext, final StringDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
StringDataFormat dataformat = new StringDataFormat();
if (CamelContextAware.class.isAssignableFrom(StringDataFormat.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