|
|
Using JAXB (or other O/X mapper) to parse bean definitions
Hi all!
I'd like to use JAXB (or some other O/X mapping framework) to parse some of the bean definitions contained in my Spring config.
Since I have seen several similar requests here in the forum, maybe it's time to stop re-inventing the wheel over and over again, and to bundle a solution for this with Spring?
What I have so far is an XML schema extension (with a custom NamespaceHandler) that will allow arbitrary XML content within an lt;jaxb:beangt; element, that will be parsed with JAXB using a JaxbFactoryBean.
While this has been pretty straight-forward, things are getting more complicated when allowing references to quot;normalquot; Spring beans from within the JAXB xml tree:
Code:
lt;jaxb:bean id=quot;myBeanquot; class=quot;com.example.MyBeanquot;gt; lt;jaxb:someChildBean foo=quot;barquot;/gt;lt;!-- this is a JAXB bean --gt; lt;jaxb therBean ref=quot;otherBeanquot;/gt;lt;!-- this is a Spring bean --gt;
lt;/jaxb:beangt;
lt;bean id=quot;otherBeanquot; class=quot;com.example.OtherBeanquot;/gt;
The JaxbFactoryBean would need to have a reference to the BeanFactory that created it, to pass it on to the JAXB code unmarshalling the reference.
So far, I haven't found an easy way to get this. Any thoughts?
Best regards,
Florian Kirchmeir |
|