Java Code Examples for org.springframework.beans.factory.support.ManagedArray

Following code examples demonstrate how to use org.springframework.beans.factory.support.ManagedArrayfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.beans.factory.support.ManagedArrayand various code implementation of this class.

    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {

        BeanDefinition bd = BeanDefinitionBuilder.genericBeanDefinition(ResourceBundleMessageSource.class)
            .addPropertyValue("alwaysUseMessageFormat", true)
            .addPropertyValue("basename", I18N_PROPERTIES_BASENAME)
            .addPropertyValue("defaultEncoding", "UTF-8")
            .getBeanDefinition();

        String beanName = AbstractApplicationContext.MESSAGE_SOURCE_BEAN_NAME;

        if (registry.containsBeanDefinition(beanName)) {

            BeanDefinition original = registry.getBeanDefinition(beanName);
            registry.removeBeanDefinition(beanName);

            ManagedArray array = new ManagedArray(MessageSource.class.getName(), 2);
            array.add(original);
            array.add(bd);

            BeanDefinition composite = BeanDefinitionBuilder.genericBeanDefinition(CompositeMessageSource.class)
                .addConstructorArgValue(array)
                .getBeanDefinition();

            registry.registerBeanDefinition(beanName, composite);

        } else {
            registry.registerBeanDefinition(beanName, bd);
        }
    } 


Advertisement
Javadoc
Tag collection class used to hold managed array elements, which may include runtime bean references

(to be resolved into bean objects). @author Juergen Hoeller @since 3.0

Read More
Advertisement