Announcement Announcement Module
Collapse
No announcement yet.
Overriding entire bean definition Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Overriding entire bean definition

    I have an application in which I create an XmlBeanFactory. I create an XmlBeanReader which I used to loadBeanDefinitions() from several more files that vary depending on that the contents of that first file.

    What I want to do is define some default beans by name in that first file

    <bean id="thing_i_need"/>

    and have one of those subsequent files just also contain a

    <bean id="thing_i_need"/>

    which redefines that bean.

    Effectively, this would be the same if I had some kind of XML merging function which overwrote things at the <bean> level and I merged each document in that root document one by one.

    Is this possible?

    If an XmlBeanReader reads the same bean id in two files will it throw?

  • #2
    Hello,

    yes this is possible. The last bean definition will override the first bean definition. So you have to take care while loading the applicationcontext, to laod it in the correct sequence

    defaultBeans.xml, specialBeans.xml.

    Note you can also use hierarchies in the beanfactory (parent/child beanfactoryies). Then the child beandefinition willl override the parent bean definition.

    rgds
    agim

    Comment

    Working...
    X