Suppose have following beach definition:
<bean id="singletonBean" class="...">
<property name="instanceBean" ref="instanceBean"/>
</bean>
<bean id="instanceBean" class="..." scope="prototype"/>
When I call:
singletonBean = context.getBean("singletonBean");
...some code...
singletonBean = context.getBean("singletonBean");
Would property instanceBean of singletonBean be initialized again or it would just use already created singleton?
A prototyped inner bean of a singleton won’t be recreated each time you get the singleton from context. The singleton and all is references are created one for all.
But
context.getBean("instanceBean");would give you a new since scope is ‘prototype’.