|
From: <rod...@in...> - 2003-05-28 11:40:32
|
JP suggested: <bean class="MyClass" id="foos" singleton="false> <property name="foo">FOO</property> <property name="foo2" value="FOO2"/> <property name="foo3" refid="foo3"/> <property name="foo4"> <data>FOO4.1</data> <data value="FOO4.2"/> <data refid="foo4.3"/> </property> </bean> The problem I see here is that there are 3 ways of defining literals: - in the body of the property element (as before) - in a value attribute. I don't think this is a good idea, as attributes can only hold simple strings without getting into nasty escaping. - in a <data> element, which is necessary anyway for a collection. Juergen makes a good point about mixed collections of references and string data (which of course would be converted to objects). Initially I thought this was unlikely, but I realised it has quite a few uses (with the AOP proxy factory, for example), and the <value> subelement I suggested handles it. (It's already implemented: see collections.xml in beanfactory.xml tests.) The most consistent approach IMHO is: <bean class="MyClass" id="foos" singleton="false> <property name="foo"><value>FOO</value></property> <property name="foo3"> <ref refid="foo3"/> </property> <property name="foo4"> <value>FOO4.1</value> <value>FOO4.2</value> <ref refid="foo4.3"/> </property> </bean> Always consistent: always at least one value or ref subelement of a property elt; <value> contains only text data; ref body must be empty. Slightly more verbose, but probably easier to author with an XML editor (even the basic Eclipse XML editor I use most of the time). I don't care whether it's called value or data, or anything else...any ideas? Regards, Rod |