use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class KinesisComponentAutoConfiguration method configureKinesisComponent.
@Lazy
@Bean(name = "aws-kinesis-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(KinesisComponent.class)
public KinesisComponent configureKinesisComponent(CamelContext camelContext) throws Exception {
KinesisComponent component = new KinesisComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class CacheComponentAutoConfiguration method configureCacheComponent.
@Lazy
@Bean(name = "cache-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CacheComponent.class)
public CacheComponent configureCacheComponent(CamelContext camelContext, CacheComponentConfiguration configuration) throws Exception {
CacheComponent component = new CacheComponent();
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 CastorDataFormatAutoConfiguration method configureCastorDataFormatFactory.
@Bean(name = "castor-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CastorDataFormat.class)
public DataFormatFactory configureCastorDataFormatFactory(final CamelContext camelContext, final CastorDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
CastorDataFormat dataformat = new CastorDataFormat();
if (CamelContextAware.class.isAssignableFrom(CastorDataFormat.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.ConditionalOnMissingBean in project camel by apache.
the class ChronicleEngineComponentAutoConfiguration method configureChronicleEngineComponent.
@Lazy
@Bean(name = "chronicle-engine-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ChronicleEngineComponent.class)
public ChronicleEngineComponent configureChronicleEngineComponent(CamelContext camelContext) throws Exception {
ChronicleEngineComponent component = new ChronicleEngineComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class CMISComponentAutoConfiguration method configureCMISComponent.
@Lazy
@Bean(name = "cmis-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(CMISComponent.class)
public CMISComponent configureCMISComponent(CamelContext camelContext, CMISComponentConfiguration configuration) throws Exception {
CMISComponent component = new CMISComponent();
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