use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class BindyFixedLengthDataFormatAutoConfiguration method configureBindyFixedLengthDataFormatFactory.
@Bean(name = "bindy-fixed-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BindyFixedLengthDataFormat.class)
public DataFormatFactory configureBindyFixedLengthDataFormatFactory(final CamelContext camelContext, final BindyFixedLengthDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BindyFixedLengthDataFormat dataformat = new BindyFixedLengthDataFormat();
if (CamelContextAware.class.isAssignableFrom(BindyFixedLengthDataFormat.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 BindyKeyValuePairDataFormatAutoConfiguration method configureBindyKeyValuePairDataFormatFactory.
@Bean(name = "bindy-kvp-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BindyKeyValuePairDataFormat.class)
public DataFormatFactory configureBindyKeyValuePairDataFormatFactory(final CamelContext camelContext, final BindyKeyValuePairDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BindyKeyValuePairDataFormat dataformat = new BindyKeyValuePairDataFormat();
if (CamelContextAware.class.isAssignableFrom(BindyKeyValuePairDataFormat.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 BoonDataFormatAutoConfiguration method configureBoonDataFormatFactory.
@Bean(name = "boon-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BoonDataFormat.class)
public DataFormatFactory configureBoonDataFormatFactory(final CamelContext camelContext, final BoonDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
BoonDataFormat dataformat = new BoonDataFormat();
if (CamelContextAware.class.isAssignableFrom(BoonDataFormat.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 BoxComponentAutoConfiguration method configureBoxComponent.
@Lazy
@Bean(name = "box-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BoxComponent.class)
public BoxComponent configureBoxComponent(CamelContext camelContext, BoxComponentConfiguration configuration) throws Exception {
BoxComponent component = new BoxComponent();
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 AvroComponentAutoConfiguration method configureAvroComponent.
@Lazy
@Bean(name = "avro-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(AvroComponent.class)
public AvroComponent configureAvroComponent(CamelContext camelContext, AvroComponentConfiguration configuration) throws Exception {
AvroComponent component = new AvroComponent();
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