use of org.apache.camel.model.HystrixConfigurationCommon in project camel by apache.
the class HystrixAutoConfiguration method addHystrixConfigurations.
@PostConstruct
public void addHystrixConfigurations() {
if (!(beanFactory instanceof ConfigurableBeanFactory)) {
LOGGER.warn("BeanFactory is not of type ConfigurableBeanFactory");
return;
}
final ConfigurableBeanFactory factory = (ConfigurableBeanFactory) beanFactory;
final Map<String, Object> properties = new HashMap<>();
for (Map.Entry<String, HystrixConfigurationCommon> entry : config.getConfigurations().entrySet()) {
// clear the properties map for reuse
properties.clear();
// extract properties
IntrospectionSupport.getProperties(entry.getValue(), properties, null, false);
try {
HystrixConfigurationDefinition definition = new HystrixConfigurationDefinition();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), definition, properties);
// Registry the definition
factory.registerSingleton(entry.getKey(), definition);
} catch (Exception e) {
throw new BeanCreationException(entry.getKey(), e);
}
}
}
Aggregations