use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class EtcdComponentAutoConfiguration method configureEtcdComponent.
@Lazy
@Bean(name = "etcd-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(EtcdComponent.class)
public EtcdComponent configureEtcdComponent(CamelContext camelContext) throws Exception {
EtcdComponent component = new EtcdComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class ExecComponentAutoConfiguration method configureExecComponent.
@Lazy
@Bean(name = "exec-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ExecComponent.class)
public ExecComponent configureExecComponent(CamelContext camelContext) throws Exception {
ExecComponent component = new ExecComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class FlatpackComponentAutoConfiguration method configureFlatpackComponent.
@Lazy
@Bean(name = "flatpack-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FlatpackComponent.class)
public FlatpackComponent configureFlatpackComponent(CamelContext camelContext) throws Exception {
FlatpackComponent component = new FlatpackComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class FlatpackDataFormatAutoConfiguration method configureFlatpackDataFormatFactory.
@Bean(name = "flatpack-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(FlatpackDataFormat.class)
public DataFormatFactory configureFlatpackDataFormatFactory(final CamelContext camelContext, final FlatpackDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
FlatpackDataFormat dataformat = new FlatpackDataFormat();
if (CamelContextAware.class.isAssignableFrom(FlatpackDataFormat.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 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;
}
Aggregations