http://static.springsource.org/spring/docs/current/spring-framework-reference/html/beans.html
When you need to ask a container for an actual
FactoryBean
instance itself, not the bean it produces, you preface the bean id with the ampersand symbol&
(without quotes) when calling thegetBean()
method of theApplicationContext
. So for a givenFactoryBean
with an id ofmyBean
, invokinggetBean("myBean")
on the container returns the product of theFactoryBean
, and invokinggetBean("&myBean")
returns theFactoryBean
instance itself.
http://stackoverflow.com/questions/2830337/spring-factorybean-and-scopes-working-together
<bean class="x.y.z.TestFactoryBean" name="testFactory">
<bean class="x.y.z.TestBean" factory-bean="testFactory"
factory-method="getObject" scope="test" />