Results 1 to 2 of 2

Thread: Overriding entire bean definition

  1. #1

    Default 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. #2
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •