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;
}
};
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class CsvDataFormatAutoConfiguration method configureCsvDataFormatFactory.
@Bean(name = "csv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CsvDataFormat.class)
public DataFormatFactory configureCsvDataFormatFactory(final CamelContext camelContext, final CsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CsvDataFormat dataformat = new CsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(CsvDataFormat.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 HipchatComponentAutoConfiguration method configureHipchatComponent.
@Lazy
@Bean(name = "hipchat-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(HipchatComponent.class)
public HipchatComponent configureHipchatComponent(CamelContext camelContext) throws Exception {
HipchatComponent component = new HipchatComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class HttpComponentAutoConfiguration method configureHttpComponent.
@Lazy
@Bean(name = { "http-component", "https-component" })
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(HttpComponent.class)
public HttpComponent configureHttpComponent(CamelContext camelContext, HttpComponentConfiguration configuration) throws Exception {
HttpComponent component = new HttpComponent();
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 HttpComponentAutoConfiguration method configureHttpComponent.
@Lazy
@Bean(name = "http4-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(HttpComponent.class)
public HttpComponent configureHttpComponent(CamelContext camelContext, HttpComponentConfiguration configuration) throws Exception {
HttpComponent component = new HttpComponent();
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