use of org.apache.camel.CamelContextAware in project camel by apache.
the class CastorDataFormatAutoConfiguration method configureCastorDataFormatFactory.
@Bean(name = "castor-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CastorDataFormat.class)
public DataFormatFactory configureCastorDataFormatFactory(final CamelContext camelContext, final CastorDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CastorDataFormat dataformat = new CastorDataFormat();
if (CamelContextAware.class.isAssignableFrom(CastorDataFormat.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 BarcodeDataFormatAutoConfiguration method configureBarcodeDataFormatFactory.
@Bean(name = "barcode-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BarcodeDataFormat.class)
public DataFormatFactory configureBarcodeDataFormatFactory(final CamelContext camelContext, final BarcodeDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BarcodeDataFormat dataformat = new BarcodeDataFormat();
if (CamelContextAware.class.isAssignableFrom(BarcodeDataFormat.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 OgnlLanguageAutoConfiguration method configureOgnlLanguage.
@Bean(name = "ognl-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(OgnlLanguage.class)
public OgnlLanguage configureOgnlLanguage(CamelContext camelContext, OgnlLanguageConfiguration configuration) throws Exception {
OgnlLanguage language = new OgnlLanguage();
if (CamelContextAware.class.isAssignableFrom(OgnlLanguage.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 MvelLanguageAutoConfiguration method configureMvelLanguage.
@Bean(name = "mvel-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MvelLanguage.class)
public MvelLanguage configureMvelLanguage(CamelContext camelContext, MvelLanguageConfiguration configuration) throws Exception {
MvelLanguage language = new MvelLanguage();
if (CamelContextAware.class.isAssignableFrom(MvelLanguage.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 RubyLanguageAutoConfiguration method configureRubyLanguage.
@Bean(name = "ruby-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(RubyLanguage.class)
public RubyLanguage configureRubyLanguage(CamelContext camelContext, RubyLanguageConfiguration configuration) throws Exception {
RubyLanguage language = new RubyLanguage();
if (CamelContextAware.class.isAssignableFrom(RubyLanguage.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