use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class PropertiesComponentAutoConfiguration method configurePropertiesComponent.
@Lazy
@Bean(name = "properties-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(PropertiesComponent.class)
public PropertiesComponent configurePropertiesComponent(CamelContext camelContext, PropertiesComponentConfiguration configuration) throws Exception {
PropertiesComponent component = new PropertiesComponent();
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.ConditionalOnMissingBean in project camel by apache.
the class RestComponentAutoConfiguration method configureRestComponent.
@Lazy
@Bean(name = "rest-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(RestComponent.class)
public RestComponent configureRestComponent(CamelContext camelContext, RestComponentConfiguration configuration) throws Exception {
RestComponent component = new RestComponent();
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.ConditionalOnMissingBean in project camel by apache.
the class BrowseComponentAutoConfiguration method configureBrowseComponent.
@Lazy
@Bean(name = "browse-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BrowseComponent.class)
public BrowseComponent configureBrowseComponent(CamelContext camelContext) throws Exception {
BrowseComponent component = new BrowseComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class ControlBusComponentAutoConfiguration method configureControlBusComponent.
@Lazy
@Bean(name = "controlbus-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ControlBusComponent.class)
public ControlBusComponent configureControlBusComponent(CamelContext camelContext) throws Exception {
ControlBusComponent component = new ControlBusComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class DataFormatComponentAutoConfiguration method configureDataFormatComponent.
@Lazy
@Bean(name = "dataformat-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DataFormatComponent.class)
public DataFormatComponent configureDataFormatComponent(CamelContext camelContext) throws Exception {
DataFormatComponent component = new DataFormatComponent();
component.setCamelContext(camelContext);
return component;
}
Aggregations