use of org.apache.camel.CamelContextAware in project camel by apache.
the class JacksonDataFormatAutoConfiguration method configureJacksonDataFormatFactory.
@Bean(name = "json-jackson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonDataFormat.class)
public DataFormatFactory configureJacksonDataFormatFactory(final CamelContext camelContext, final JacksonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JacksonDataFormat dataformat = new JacksonDataFormat();
if (CamelContextAware.class.isAssignableFrom(JacksonDataFormat.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 JacksonXMLDataFormatAutoConfiguration method configureJacksonXMLDataFormatFactory.
@Bean(name = "jacksonxml-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonXMLDataFormat.class)
public DataFormatFactory configureJacksonXMLDataFormatFactory(final CamelContext camelContext, final JacksonXMLDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JacksonXMLDataFormat dataformat = new JacksonXMLDataFormat();
if (CamelContextAware.class.isAssignableFrom(JacksonXMLDataFormat.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 FlatpackDataFormatAutoConfiguration method configureFlatpackDataFormatFactory.
@Bean(name = "flatpack-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FlatpackDataFormat.class)
public DataFormatFactory configureFlatpackDataFormatFactory(final CamelContext camelContext, final FlatpackDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
FlatpackDataFormat dataformat = new FlatpackDataFormat();
if (CamelContextAware.class.isAssignableFrom(FlatpackDataFormat.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 XMLTokenizeLanguageAutoConfiguration method configureXMLTokenizeLanguage.
@Bean(name = "xtokenize-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XMLTokenizeLanguage.class)
public XMLTokenizeLanguage configureXMLTokenizeLanguage(CamelContext camelContext, XMLTokenizeLanguageConfiguration configuration) throws Exception {
XMLTokenizeLanguage language = new XMLTokenizeLanguage();
if (CamelContextAware.class.isAssignableFrom(XMLTokenizeLanguage.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 CryptoDataFormatAutoConfiguration method configureCryptoDataFormatFactory.
@Bean(name = "crypto-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CryptoDataFormat.class)
public DataFormatFactory configureCryptoDataFormatFactory(final CamelContext camelContext, final CryptoDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CryptoDataFormat dataformat = new CryptoDataFormat();
if (CamelContextAware.class.isAssignableFrom(CryptoDataFormat.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