use of org.apache.camel.CamelContextAware in project camel by apache.
the class LZFDataFormatAutoConfiguration method configureLZFDataFormatFactory.
@Bean(name = "lzf-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(LZFDataFormat.class)
public DataFormatFactory configureLZFDataFormatFactory(final CamelContext camelContext, final LZFDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
LZFDataFormat dataformat = new LZFDataFormat();
if (CamelContextAware.class.isAssignableFrom(LZFDataFormat.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 ProtobufDataFormatAutoConfiguration method configureProtobufDataFormatFactory.
@Bean(name = "protobuf-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ProtobufDataFormat.class)
public DataFormatFactory configureProtobufDataFormatFactory(final CamelContext camelContext, final ProtobufDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ProtobufDataFormat dataformat = new ProtobufDataFormat();
if (CamelContextAware.class.isAssignableFrom(ProtobufDataFormat.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 JuelLanguageAutoConfiguration method configureJuelLanguage.
@Bean(name = "el-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JuelLanguage.class)
public JuelLanguage configureJuelLanguage(CamelContext camelContext, JuelLanguageConfiguration configuration) throws Exception {
JuelLanguage language = new JuelLanguage();
if (CamelContextAware.class.isAssignableFrom(JuelLanguage.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;
}
use of org.apache.camel.CamelContextAware in project camel by apache.
the class PhpLanguageAutoConfiguration method configurePhpLanguage.
@Bean(name = "php-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(PhpLanguage.class)
public PhpLanguage configurePhpLanguage(CamelContext camelContext, PhpLanguageConfiguration configuration) throws Exception {
PhpLanguage language = new PhpLanguage();
if (CamelContextAware.class.isAssignableFrom(PhpLanguage.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;
}
use of org.apache.camel.CamelContextAware in project camel by apache.
the class BeanIODataFormatAutoConfiguration method configureBeanIODataFormatFactory.
@Bean(name = "beanio-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanIODataFormat.class)
public DataFormatFactory configureBeanIODataFormatFactory(final CamelContext camelContext, final BeanIODataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BeanIODataFormat dataformat = new BeanIODataFormat();
if (CamelContextAware.class.isAssignableFrom(BeanIODataFormat.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