use of org.apache.camel.CamelContextAware in project camel by apache.
the class SoapJaxbDataFormatAutoConfiguration method configureSoapJaxbDataFormatFactory.
@Bean(name = "soapjaxb-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SoapJaxbDataFormat.class)
public DataFormatFactory configureSoapJaxbDataFormatFactory(final CamelContext camelContext, final SoapJaxbDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
SoapJaxbDataFormat dataformat = new SoapJaxbDataFormat();
if (CamelContextAware.class.isAssignableFrom(SoapJaxbDataFormat.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 SpelLanguageAutoConfiguration method configureSpelLanguage.
@Bean(name = "spel-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(SpelLanguage.class)
public SpelLanguage configureSpelLanguage(CamelContext camelContext, SpelLanguageConfiguration configuration) throws Exception {
SpelLanguage language = new SpelLanguage();
if (CamelContextAware.class.isAssignableFrom(SpelLanguage.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 XmlRpcDataFormatAutoConfiguration method configureXmlRpcDataFormatFactory.
@Bean(name = "xmlrpc-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlRpcDataFormat.class)
public DataFormatFactory configureXmlRpcDataFormatFactory(final CamelContext camelContext, final XmlRpcDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlRpcDataFormat dataformat = new XmlRpcDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlRpcDataFormat.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 JsonDataFormatAutoConfiguration method configureJsonDataFormatFactory.
@Bean(name = "json-xstream-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JsonDataFormat.class)
public DataFormatFactory configureJsonDataFormatFactory(final CamelContext camelContext, final JsonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JsonDataFormat dataformat = new JsonDataFormat();
if (CamelContextAware.class.isAssignableFrom(JsonDataFormat.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 ZipFileDataFormatAutoConfiguration method configureZipFileDataFormatFactory.
@Bean(name = "zipfile-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ZipFileDataFormat.class)
public DataFormatFactory configureZipFileDataFormatFactory(final CamelContext camelContext, final ZipFileDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ZipFileDataFormat dataformat = new ZipFileDataFormat();
if (CamelContextAware.class.isAssignableFrom(ZipFileDataFormat.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