|
|
Bean in Context File1 used in Context File 2
Hi,
I have 2 spring context files to seperate two different group of objects.
Can I you use beanA [defined in Context File 1] for beanB[defined in Context file 2]?
These Context files are themselves loaded up using ContextSingletonBeanFactoryLocator
from beanRefContext.xml
So, code is:
BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(); BeanFactoryReference bfr = locator.useBeanFactory(lt;some context bean idgt;); BeanFactory beanFactory = bfr.getFactory();
How could I force parent/child relationship like:
XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory)
with ContextSingletonBeanFactoryLocator usage?
Thank you!
The application context takes a parent app context constructor argument. Within your beanRefFactory xml file, you can define this relationship. This is demonstrated within the javadocs for SingletonBeanFactoryLocator.
Hope that helps.
-karl
Using ContextSingletonBeanFactoryLocator I could define parent child.
Also, obviously, This does not impose any restrictions as to if the individual bean in a specific context file can be singleton or not.
Thanks!
No, this does not impose any restriction on Singletons. |
|