Results 1 to 6 of 6

Thread: Inheriting properties

  1. #1

    Default Inheriting properties

    I have an abstract class which define a map type property which has some values (about two dozen entries). Then, I have four concrete classes that uses the same property but must add their own entries to the map (6-8) and override couple of super class entries.
    If I define the same property in parent and child bean definition XML, will it complement parent class map or override it? I.e. do I need to repeat parent class entries for children or not?
    I certainly can write a test for the case, but if someone knows the answer,
    I'll appreciate it.

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    The default behavior I believe is child overriding parent, but you can specify merge="true" to make spring combine them.
    --Jing Xue

  3. #3

    Default

    Quote Originally Posted by manifoldronin
    The default behavior I believe is child overriding parent, but you can specify merge="true" to make spring combine them.
    How I am suppose to do it?
    I tried to use
    Code:
                <map merge="true">
    and it failed XML validation. I looked in DTD file and merge attribute appears only in 2.0 which isn't released yet. I can't use it for production system.

  4. #4
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    Ah, sorry, I took it for granted that you were using 2.0.
    --Jing Xue

  5. #5
    Join Date
    Aug 2005
    Location
    Lexington, KY
    Posts
    36

    Default

    So, is there a way to do this in the 1.X version? Anyone? Anyone?
    Jamie Bisotti

  6. #6
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    In 1.x there is no out-of-the-box support for this feature. However, you can implement it yourself. If I recall correctly I saw some implementation fragments in the forum.

    The point is to declare the map as standalone bean and refer to it from your parent bean. The child bean then refers to a factory bean which refers to that map and an additional map with the extra values. The responsibility of the factory bean is to do the merge and return the merged map.

    Regards,
    Andreas

Posting Permissions

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