I have a Java object which is able to configure itself given an XML configuration description (it takes other descriptions as well, but I’m interested in the XML at the moment). I’m wondering if I can embed the XML description directly into a Spring application context description. I’m imagining something like:
<bean id='myXMLConfiguredBean' class='com.example.Foo'> <constructor-arg type='xml'> <myconfig xmlns='http://example.com/foo/config'> <bar>42</bar> </myconfig> </constructor-arg> </bean>
but I have no idea if that – or something like it – is possible. I realise I could embed myconfig in a CDATA section, but that seems a bit ugly.
Spring’s XSD allows
<constructor-arg>to contain any XML through:Where the
processContentsattribitutes can have one of three valuesSo, so long as your config XML has a schema, and you import it correctly, this should work.
Then, you would need to register a PropertyEditor for your XML using CustomEditorConfigurer
Hope this helps