use of org.apache.camel.CamelContextAware in project camel by apache.
the class AvroDataFormatAutoConfiguration method configureAvroDataFormatFactory.
@Bean(name = "avro-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AvroDataFormat.class)
public DataFormatFactory configureAvroDataFormatFactory(final CamelContext camelContext, final AvroDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
AvroDataFormat dataformat = new AvroDataFormat();
if (CamelContextAware.class.isAssignableFrom(AvroDataFormat.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 RssDataFormatAutoConfiguration method configureRssDataFormatFactory.
@Bean(name = "rss-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(RssDataFormat.class)
public DataFormatFactory configureRssDataFormatFactory(final CamelContext camelContext, final RssDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
RssDataFormat dataformat = new RssDataFormat();
if (CamelContextAware.class.isAssignableFrom(RssDataFormat.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 XQueryLanguageAutoConfiguration method configureXQueryLanguage.
@Bean(name = "xquery-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XQueryLanguage.class)
public XQueryLanguage configureXQueryLanguage(CamelContext camelContext, XQueryLanguageConfiguration configuration) throws Exception {
XQueryLanguage language = new XQueryLanguage();
if (CamelContextAware.class.isAssignableFrom(XQueryLanguage.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 JavaScriptLanguageAutoConfiguration method configureJavaScriptLanguage.
@Bean(name = "javaScript-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JavaScriptLanguage.class)
public JavaScriptLanguage configureJavaScriptLanguage(CamelContext camelContext, JavaScriptLanguageConfiguration configuration) throws Exception {
JavaScriptLanguage language = new JavaScriptLanguage();
if (CamelContextAware.class.isAssignableFrom(JavaScriptLanguage.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 XmlJsonDataFormatAutoConfiguration method configureXmlJsonDataFormatFactory.
@Bean(name = "xmljson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlJsonDataFormat.class)
public DataFormatFactory configureXmlJsonDataFormatFactory(final CamelContext camelContext, final XmlJsonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlJsonDataFormat dataformat = new XmlJsonDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlJsonDataFormat.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