use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class JibxDataFormatAutoConfiguration method configureJibxDataFormatFactory.
@Bean(name = "jibx-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(JibxDataFormat.class)
public DataFormatFactory configureJibxDataFormatFactory(final CamelContext camelContext, final JibxDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
JibxDataFormat dataformat = new JibxDataFormat();
if (CamelContextAware.class.isAssignableFrom(JibxDataFormat.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 DrillComponentAutoConfiguration method configureDrillComponent.
@Lazy
@Bean(name = "drill-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DrillComponent.class)
public DrillComponent configureDrillComponent(CamelContext camelContext) throws Exception {
DrillComponent component = new DrillComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class DropboxComponentAutoConfiguration method configureDropboxComponent.
@Lazy
@Bean(name = "dropbox-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DropboxComponent.class)
public DropboxComponent configureDropboxComponent(CamelContext camelContext) throws Exception {
DropboxComponent component = new DropboxComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class UndertowComponentAutoConfiguration method configureUndertowComponent.
@Lazy
@Bean(name = "undertow-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UndertowComponent.class)
public UndertowComponent configureUndertowComponent(CamelContext camelContext, UndertowComponentConfiguration configuration) throws Exception {
UndertowComponent component = new UndertowComponent();
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 UniVocityTsvDataFormatAutoConfiguration method configureUniVocityTsvDataFormatFactory.
@Bean(name = "univocity-tsv-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(UniVocityTsvDataFormat.class)
public DataFormatFactory configureUniVocityTsvDataFormatFactory(final CamelContext camelContext, final UniVocityTsvDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
UniVocityTsvDataFormat dataformat = new UniVocityTsvDataFormat();
if (CamelContextAware.class.isAssignableFrom(UniVocityTsvDataFormat.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;
}
};
}
Aggregations