• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to access Beans in any class ?  RSS feed

 
samir ware
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,
We do instantiate beans in XML file through the <bean> tag and all those beans are singlton beans. I want to access these beans which got created by the spring in my custom class. Is there any way by which I can access the same instance which the spring has created in my class. I heard about BeanFactoryAware interface but I was not able to get it through it. Can anybody give me the code snippest for the same ? Is there any other way apart from spring injection and BeanFactoryAware interface implementation to access those beans.
Thanks in advance
Samir
 
ranjan Khaba
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this link, the explanation is given properly.

http://blog.jdevelop.eu/2008/07/06/access-the-spring-applicationcontext-from-everywhere-in-your-application/
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!