use of org.apache.camel.CamelContextAware in project camel by apache.
the class HessianDataFormatAutoConfiguration method configureHessianDataFormatFactory.
@Bean(name = "hessian-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(HessianDataFormat.class)
public DataFormatFactory configureHessianDataFormatFactory(final CamelContext camelContext, final HessianDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
HessianDataFormat dataformat = new HessianDataFormat();
if (CamelContextAware.class.isAssignableFrom(HessianDataFormat.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 HL7DataFormatAutoConfiguration method configureHL7DataFormatFactory.
@Bean(name = "hl7-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(HL7DataFormat.class)
public DataFormatFactory configureHL7DataFormatFactory(final CamelContext camelContext, final HL7DataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
HL7DataFormat dataformat = new HL7DataFormat();
if (CamelContextAware.class.isAssignableFrom(HL7DataFormat.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 TerserLanguageAutoConfiguration method configureTerserLanguage.
@Bean(name = "terser-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TerserLanguage.class)
public TerserLanguage configureTerserLanguage(CamelContext camelContext, TerserLanguageConfiguration configuration) throws Exception {
TerserLanguage language = new TerserLanguage();
if (CamelContextAware.class.isAssignableFrom(TerserLanguage.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 JaxbDataFormatAutoConfiguration method configureJaxbDataFormatFactory.
@Bean(name = "jaxb-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JaxbDataFormat.class)
public DataFormatFactory configureJaxbDataFormatFactory(final CamelContext camelContext, final JaxbDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JaxbDataFormat dataformat = new JaxbDataFormat();
if (CamelContextAware.class.isAssignableFrom(JaxbDataFormat.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 MimeMultipartDataFormatAutoConfiguration method configureMimeMultipartDataFormatFactory.
@Bean(name = "mime-multipart-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MimeMultipartDataFormat.class)
public DataFormatFactory configureMimeMultipartDataFormatFactory(final CamelContext camelContext, final MimeMultipartDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
MimeMultipartDataFormat dataformat = new MimeMultipartDataFormat();
if (CamelContextAware.class.isAssignableFrom(MimeMultipartDataFormat.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