use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class AMQPComponentAutoConfiguration method configureAMQPComponent.
@Lazy
@Bean(name = "amqp-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AMQPComponent.class)
public AMQPComponent configureAMQPComponent(CamelContext camelContext, AMQPComponentConfiguration configuration) throws Exception {
AMQPComponent component = new AMQPComponent();
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 AsteriskComponentAutoConfiguration method configureAsteriskComponent.
@Lazy
@Bean(name = "asterisk-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AsteriskComponent.class)
public AsteriskComponent configureAsteriskComponent(CamelContext camelContext) throws Exception {
AsteriskComponent component = new AsteriskComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class AtmosComponentAutoConfiguration method configureAtmosComponent.
@Lazy
@Bean(name = "atmos-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AtmosComponent.class)
public AtmosComponent configureAtmosComponent(CamelContext camelContext) throws Exception {
AtmosComponent component = new AtmosComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class StubComponentAutoConfiguration method configureStubComponent.
@Lazy
@Bean(name = "stub-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(StubComponent.class)
public StubComponent configureStubComponent(CamelContext camelContext, StubComponentConfiguration configuration) throws Exception {
StubComponent component = new StubComponent();
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 TestComponentAutoConfiguration method configureTestComponent.
@Lazy
@Bean(name = "test-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TestComponent.class)
public TestComponent configureTestComponent(CamelContext camelContext) throws Exception {
TestComponent component = new TestComponent();
component.setCamelContext(camelContext);
return component;
}
Aggregations