use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class VelocityComponentAutoConfiguration method configureVelocityComponent.
@Lazy
@Bean(name = "velocity-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(VelocityComponent.class)
public VelocityComponent configureVelocityComponent(CamelContext camelContext, VelocityComponentConfiguration configuration) throws Exception {
VelocityComponent component = new VelocityComponent();
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 VertxComponentAutoConfiguration method configureVertxComponent.
@Lazy
@Bean(name = "vertx-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(VertxComponent.class)
public VertxComponent configureVertxComponent(CamelContext camelContext, VertxComponentConfiguration configuration) throws Exception {
VertxComponent component = new VertxComponent();
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 WeatherComponentAutoConfiguration method configureWeatherComponent.
@Lazy
@Bean(name = "weather-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(WeatherComponent.class)
public WeatherComponent configureWeatherComponent(CamelContext camelContext) throws Exception {
WeatherComponent component = new WeatherComponent();
component.setCamelContext(camelContext);
return component;
}
use of org.springframework.boot.autoconfigure.condition.ConditionalOnClass in project camel by apache.
the class XmlBeansDataFormatAutoConfiguration method configureXmlBeansDataFormatFactory.
@Bean(name = "xmlBeans-dataformat-factory")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(XmlBeansDataFormat.class)
public DataFormatFactory configureXmlBeansDataFormatFactory(final CamelContext camelContext, final XmlBeansDataFormatConfiguration configuration) {
return new DataFormatFactory() {
public DataFormat newInstance() {
XmlBeansDataFormat dataformat = new XmlBeansDataFormat();
if (CamelContextAware.class.isAssignableFrom(XmlBeansDataFormat.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 MasterComponentAutoConfiguration method configureMasterComponent.
@Lazy
@Bean(name = "zookeeper-master-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(MasterComponent.class)
public MasterComponent configureMasterComponent(CamelContext camelContext, MasterComponentConfiguration configuration) throws Exception {
MasterComponent component = new MasterComponent();
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