Example usage for org.springframework.beans ConfigurablePropertyAccessor setPropertyValue

List of usage examples for org.springframework.beans ConfigurablePropertyAccessor setPropertyValue

Introduction

In this page you can find the example usage for org.springframework.beans ConfigurablePropertyAccessor setPropertyValue.

Prototype

void setPropertyValue(String propertyName, @Nullable Object value) throws BeansException;

Source Link

Document

Set the specified value as current property value.

Usage

From source file:org.lightadmin.core.config.bootstrap.RepositoriesFactoryBean.java

private Repositories configureRepositories(Repositories repositories) {
    ConfigurablePropertyAccessor configurablePropertyAccessor = forDirectFieldAccess(repositories);
    ListableBeanFactory beanFactory = (ListableBeanFactory) getBeanFactory();
    configurablePropertyAccessor.setPropertyValue("beanFactory", beanFactory);
    configurablePropertyAccessor.setPropertyValue("repositoryBeanNames", repositoryBeanNames(beanFactory));
    configurablePropertyAccessor.setPropertyValue("repositoryFactoryInfos",
            repositoryFactoryInfos(beanFactory));
    return repositories;
}

From source file:org.brushingbits.jnap.validation.constraints.AbstractConstraintValidator.java

/**
 * This method copies all the annotation properties to fields with the same name.
 * /*from w w  w .  j a v  a  2s  . c  om*/
 * @param constraintAnnotation This constraint annotation.
 * @see PropertyAccessorFactory
 */
protected void bindParameters(A constraintAnnotation) {
    Class<?> annotationClass = constraintAnnotation.getClass();
    Method[] methods = annotationClass.getDeclaredMethods();
    ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(this);
    try {
        for (Method method : methods) {
            String methodName = method.getName();
            if (accessor.isWritableProperty(methodName)) {
                accessor.setPropertyValue(methodName,
                        method.invoke(constraintAnnotation, ArrayUtils.EMPTY_OBJECT_ARRAY));
            }
        }
    } catch (Exception e) {
        ReflectionUtils.handleReflectionException(e);
    }
}