use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class FlinkComponentAutoConfiguration method configureFlinkComponent.
@Lazy
@Bean(name = "flink-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FlinkComponent.class)
public FlinkComponent configureFlinkComponent(CamelContext camelContext, FlinkComponentConfiguration configuration) throws Exception {
FlinkComponent component = new FlinkComponent();
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;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass 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.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class CouchbaseComponentAutoConfiguration method configureCouchbaseComponent.
@Lazy
@Bean(name = "couchbase-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CouchbaseComponent.class)
public CouchbaseComponent configureCouchbaseComponent(CamelContext camelContext) throws Exception {
CouchbaseComponent component = new CouchbaseComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class CouchDbComponentAutoConfiguration method configureCouchDbComponent.
@Lazy
@Bean(name = "couchdb-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CouchDbComponent.class)
public CouchDbComponent configureCouchDbComponent(CamelContext camelContext) throws Exception {
CouchDbComponent component = new CouchDbComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class DigitalSignatureComponentAutoConfiguration method configureDigitalSignatureComponent.
@Lazy
@Bean(name = "crypto-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DigitalSignatureComponent.class)
public DigitalSignatureComponent configureDigitalSignatureComponent(CamelContext camelContext, DigitalSignatureComponentConfiguration configuration) throws Exception {
DigitalSignatureComponent component = new DigitalSignatureComponent();
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