I have a need to populate beans of unkown types with dynamic variables. More precisely, I have XML comming into a Spring MVC Controller that uses a helper class (got via Spring IoC) to parse the XML and populate other beans based on the XML. I'd like to get the beans from the application context and then use Jakarta Commons BeanUtils to populate properties.
Originally I had the helper class maintain its own list of prototype beans. It would make a copy of the prototype that matched an XML node. Then it would populate the copy using org.apache.commons.beanutils.BeanUtils.copyPropert y(bean, name, value). (The name and value came from the XML.)
The original design set up the prototypes in the no-arg constructor of the helper class, but when I started using Spring I got exceptions saying the class could not be instanciated.
Now the helper class is BeanFactoryAware and looks up the beans from the BeanFactory as non-singletons. My tests show that that is working fine, but when I try to populate with BeanUtils.copyProperty(bean, name, value) the system just seems to go off into limbo: no exceptions, no nothing.
Is org.apache.commons.beanutils.BeanUtils unable to work with Spring loaded beans? If so, why? and how do I work around it?
I don't see a copyProperty(bean, name, value) equivalent in Spring. Is there one?
TIA
,boz


Reply With Quote