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;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass 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