Jun 2nd, 2006, 03:08 PM
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.
Jun 2nd, 2006, 03:46 PM
The default behavior I believe is child overriding parent, but you can specify merge="true" to make spring combine them.
Jun 5th, 2006, 03:46 PM
How I am suppose to do it?
Originally Posted by manifoldronin
I tried to use 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.
Jun 5th, 2006, 10:20 PM
Ah, sorry, I took it for granted that you were using 2.0.
Jun 19th, 2006, 08:46 AM
So, is there a way to do this in the 1.X version? Anyone? Anyone?
Jun 19th, 2006, 09:00 AM
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.