use of org.apache.camel.CamelContextAware in project camel by apache.
the class ExchangePropertyLanguageAutoConfiguration method configureExchangePropertyLanguage.
@Bean(name = "exchangeProperty-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ExchangePropertyLanguage.class)
public ExchangePropertyLanguage configureExchangePropertyLanguage(CamelContext camelContext, ExchangePropertyLanguageConfiguration configuration) throws Exception {
ExchangePropertyLanguage language = new ExchangePropertyLanguage();
if (CamelContextAware.class.isAssignableFrom(ExchangePropertyLanguage.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 JibxDataFormatAutoConfiguration method configureJibxDataFormatFactory.
@Bean(name = "jibx-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JibxDataFormat.class)
public DataFormatFactory configureJibxDataFormatFactory(final CamelContext camelContext, final JibxDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JibxDataFormat dataformat = new JibxDataFormat();
if (CamelContextAware.class.isAssignableFrom(JibxDataFormat.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 UniVocityTsvDataFormatAutoConfiguration method configureUniVocityTsvDataFormatFactory.
@Bean(name = "univocity-tsv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityTsvDataFormat.class)
public DataFormatFactory configureUniVocityTsvDataFormatFactory(final CamelContext camelContext, final UniVocityTsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
UniVocityTsvDataFormat dataformat = new UniVocityTsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(UniVocityTsvDataFormat.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 XmlBeansDataFormatAutoConfiguration method configureXmlBeansDataFormatFactory.
@Bean(name = "xmlBeans-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlBeansDataFormat.class)
public DataFormatFactory configureXmlBeansDataFormatFactory(final CamelContext camelContext, final XmlBeansDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlBeansDataFormat dataformat = new XmlBeansDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlBeansDataFormat.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 SnakeYAMLDataFormatAutoConfiguration method configureSnakeYAMLDataFormatFactory.
@Bean(name = "yaml-snakeyaml-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SnakeYAMLDataFormat.class)
public DataFormatFactory configureSnakeYAMLDataFormatFactory(final CamelContext camelContext, final SnakeYAMLDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
SnakeYAMLDataFormat dataformat = new SnakeYAMLDataFormat();
if (CamelContextAware.class.isAssignableFrom(SnakeYAMLDataFormat.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