Back Forum Reply New

Obtaining Factory bean inside xml context

3.6.1. Obtaining a FactoryBean, not its product

Sometimes there is a need to ask a BeanFactory for an actual FactoryBean instance itself, not the bean it produces. This may be done by prepending the bean id with amp; when calling the getBean method of BeanFactory (including ApplicationContext). So for a given FactoryBean with an id myBean, invoking getBean(quot;myBeanquot;) on the BeanFactory will return the product of the FactoryBean, but invoking getBean(quot;amp;myBeanquot;) will return the FactoryBean instance itself.

How do you do this inside xml context?Code:   lt;bean id=quot;configurationquot; factory-bean=quot;amp;sessionFactoryquot; factory-method=quot;getConfigurationquot;/gt;
Here xml parser crashes:
org.xml.sax.SAXParseException: The reference to entity quot;sessionFactoryquot; must end with the ';' delimiter.

Rgds, Ales

Seems to have become an FAQ:
showthread.php?t=15517

ops:

Layzly searched the forum ... didn't know how exactly too look.
Hoping one who faced similar problem would jump right in   .

Thanx.
¥
Back Forum Reply New