use of org.apache.camel.CamelContextAware in project camel by apache.
the class CsvDataFormatAutoConfiguration method configureCsvDataFormatFactory.
@Bean(name = "csv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CsvDataFormat.class)
public DataFormatFactory configureCsvDataFormatFactory(final CamelContext camelContext, final CsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CsvDataFormat dataformat = new CsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(CsvDataFormat.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 GsonDataFormatAutoConfiguration method configureGsonDataFormatFactory.
@Bean(name = "json-gson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(GsonDataFormat.class)
public DataFormatFactory configureGsonDataFormatFactory(final CamelContext camelContext, final GsonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
GsonDataFormat dataformat = new GsonDataFormat();
if (CamelContextAware.class.isAssignableFrom(GsonDataFormat.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 GzipDataFormatAutoConfiguration method configureGzipDataFormatFactory.
@Bean(name = "gzip-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(GzipDataFormat.class)
public DataFormatFactory configureGzipDataFormatFactory(final CamelContext camelContext, final GzipDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
GzipDataFormat dataformat = new GzipDataFormat();
if (CamelContextAware.class.isAssignableFrom(GzipDataFormat.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 ZipDataFormatAutoConfiguration method configureZipDataFormatFactory.
@Bean(name = "zip-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ZipDataFormat.class)
public DataFormatFactory configureZipDataFormatFactory(final CamelContext camelContext, final ZipDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ZipDataFormat dataformat = new ZipDataFormat();
if (CamelContextAware.class.isAssignableFrom(ZipDataFormat.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 BeanLanguageAutoConfiguration method configureBeanLanguage.
@Bean(name = "bean-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanLanguage.class)
public BeanLanguage configureBeanLanguage(CamelContext camelContext, BeanLanguageConfiguration configuration) throws Exception {
BeanLanguage language = new BeanLanguage();
if (CamelContextAware.class.isAssignableFrom(BeanLanguage.class)) {
CamelContextAware contextAware = CamelContextAware.class.cast(language);
if (contextAware != null) {
contextAware.setCamelContext(camelContext);
}
}
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), language, parameters);
return language;
}
Aggregations