use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class ZipDataFormatAutoConfiguration method configureZipDataFormatFactory.
@Bean(name = "zip-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ZipDataFormat.class)
public DataFormatFactory configureZipDataFormatFactory(final CamelContext camelContext, final ZipDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
ZipDataFormat dataformat = new ZipDataFormat();
if (CamelContextAware.class.isAssignableFrom(ZipDataFormat.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.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class BeanLanguageAutoConfiguration method configureBeanLanguage.
@Bean(name = "bean-language")
@Scope("prototype")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanLanguage.class)
public BeanLanguage configureBeanLanguage(CamelContext camelContext, BeanLanguageConfiguration configuration) throws Exception {
BeanLanguage language = new BeanLanguage();
if (CamelContextAware.class.isAssignableFrom(BeanLanguage.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.springframework.boot.autoconfigure.condition.ConditionalOnClass 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.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class FopComponentAutoConfiguration method configureFopComponent.
@Lazy
@Bean(name = "fop-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FopComponent.class)
public FopComponent configureFopComponent(CamelContext camelContext) throws Exception {
FopComponent component = new FopComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class FreemarkerComponentAutoConfiguration method configureFreemarkerComponent.
@Lazy
@Bean(name = "freemarker-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FreemarkerComponent.class)
public FreemarkerComponent configureFreemarkerComponent(CamelContext camelContext, FreemarkerComponentConfiguration configuration) throws Exception {
FreemarkerComponent component = new FreemarkerComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
if (paramClass.getName().endsWith("NestedConfiguration")) {
Class nestedClass = null;
try {
nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
HashMap<String, Object> nestedParameters = new HashMap<>();
IntrospectionSupport.getProperties(value, nestedParameters, null, false);
Object nestedProperty = nestedClass.newInstance();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
entry.setValue(nestedProperty);
} catch (NoSuchFieldException e) {
}
}
}
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
return component;
}
Aggregations