Announcement Announcement Module
Collapse
No announcement yet.
Extending PropertiesBeanDefinitionReader for factory methods Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending PropertiesBeanDefinitionReader for factory methods

    Hi all,

    I would like to extend the default behavior of PropertiesBeanDefinitionReader so it can support a factory method property of a bean. The properties of a bean would look like this with highlighted in bold the type property I would like to support:

    MyBean.(class)=MyClass
    MyBean(factory-method) = getInstance
    MyBean.testMessage = Test

    Having looked through the source code for PropertiesBeanDefinitionReader it seems overriding registerBeanDefinition(String beanName, Map<?, ?> map, String prefix, String resourceDescription) is what is needed. At the end of this method it will set the BeanDefinition properties as follows:

    try {

    AbstractBeanDefinition bd = BeanDefinitionReaderUtils.createBeanDefinition(
    parent, className, getBeanClassLoader());

    bd.setScope(scope);
    bd.setAbstract(isAbstract);

    bd.setLazyInit(lazyInit);
    bd.setConstructorArgumentValues(cas);
    bd.setPropertyValues(pvs);
    getRegistry().registerBeanDefinition(beanName, bd);

    }

    I need to modify this so it includes bd.setFactoryMethodName(factoryMethodName). Will it be ok for me to the override registerBeanDefinition so it has the exact code as its super class except a few lines to support the factory method or will there be any licensing restrictions? I don't think there will be any I just want to make sure.

    Has anyone else done something similar to this?

    Thanks,

    Sachman
Working...
X