Search in sources :

Example 1 with HystrixConfigurationCommon

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);
        }
    }
}
Also used : ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) BeanCreationException(org.springframework.beans.factory.BeanCreationException) HashMap(java.util.HashMap) HystrixConfigurationCommon(org.apache.camel.model.HystrixConfigurationCommon) HashMap(java.util.HashMap) Map(java.util.Map) HystrixConfigurationDefinition(org.apache.camel.model.HystrixConfigurationDefinition) BeanCreationException(org.springframework.beans.factory.BeanCreationException) BeansException(org.springframework.beans.BeansException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 HystrixConfigurationCommon (org.apache.camel.model.HystrixConfigurationCommon)1 HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)1 BeansException (org.springframework.beans.BeansException)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 ConfigurableBeanFactory (org.springframework.beans.factory.config.ConfigurableBeanFactory)1