use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class IronMQComponentAutoConfiguration method configureIronMQComponent.
@Lazy
@Bean(name = "ironmq-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(IronMQComponent.class)
public IronMQComponent configureIronMQComponent(CamelContext camelContext) throws Exception {
IronMQComponent component = new IronMQComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean in project camel by apache.
the class JacksonDataFormatAutoConfiguration method configureJacksonDataFormatFactory.
@Bean(name = "json-jackson-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonDataFormat.class)
public DataFormatFactory configureJacksonDataFormatFactory(final CamelContext camelContext, final JacksonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JacksonDataFormat dataformat = new JacksonDataFormat();
if (CamelContextAware.class.isAssignableFrom(JacksonDataFormat.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 JacksonXMLDataFormatAutoConfiguration method configureJacksonXMLDataFormatFactory.
@Bean(name = "jacksonxml-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JacksonXMLDataFormat.class)
public DataFormatFactory configureJacksonXMLDataFormatFactory(final CamelContext camelContext, final JacksonXMLDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JacksonXMLDataFormat dataformat = new JacksonXMLDataFormat();
if (CamelContextAware.class.isAssignableFrom(JacksonXMLDataFormat.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 ElasticsearchComponentAutoConfiguration method configureElasticsearchComponent.
@Lazy
@Bean(name = "elasticsearch-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ElasticsearchComponent.class)
public ElasticsearchComponent configureElasticsearchComponent(CamelContext camelContext, ElasticsearchComponentConfiguration configuration) throws Exception {
ElasticsearchComponent component = new ElasticsearchComponent();
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 ElasticsearchComponentAutoConfiguration method configureElasticsearchComponent.
@Lazy
@Bean(name = "elasticsearch5-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(ElasticsearchComponent.class)
public ElasticsearchComponent configureElasticsearchComponent(CamelContext camelContext) throws Exception {
ElasticsearchComponent component = new ElasticsearchComponent();
component.setCamelContext(camelContext);
return component;
}
Aggregations