Search in sources :

Example 1 with SpringValueDefinition

use of com.ctrip.framework.apollo.spring.property.SpringValueDefinition in project apollo by ctripcorp.

the class SpringValueProcessor method processBeanPropertyValues.

private void processBeanPropertyValues(Object bean, String beanName) {
    Collection<SpringValueDefinition> propertySpringValues = beanName2SpringValueDefinitions.get(beanName);
    if (propertySpringValues == null || propertySpringValues.isEmpty()) {
        return;
    }
    for (SpringValueDefinition definition : propertySpringValues) {
        try {
            PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(bean.getClass(), definition.getPropertyName());
            Method method = pd.getWriteMethod();
            if (method == null) {
                continue;
            }
            SpringValue springValue = new SpringValue(definition.getKey(), definition.getPlaceholder(), bean, beanName, method, false);
            springValueRegistry.register(beanFactory, definition.getKey(), springValue);
            logger.debug("Monitoring {}", springValue);
        } catch (Throwable ex) {
            logger.error("Failed to enable auto update feature for {}.{}", bean.getClass(), definition.getPropertyName());
        }
    }
    // clear
    beanName2SpringValueDefinitions.removeAll(beanName);
}
Also used : SpringValue(com.ctrip.framework.apollo.spring.property.SpringValue) SpringValueDefinition(com.ctrip.framework.apollo.spring.property.SpringValueDefinition) PropertyDescriptor(java.beans.PropertyDescriptor) Method(java.lang.reflect.Method)

Aggregations

SpringValue (com.ctrip.framework.apollo.spring.property.SpringValue)1 SpringValueDefinition (com.ctrip.framework.apollo.spring.property.SpringValueDefinition)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 Method (java.lang.reflect.Method)1