__________________________________________________
Hi,
I was playing Spring framework for couple days and got confused about the application context access.
To my understanding, in order to get a bean, you should get the application context and call getBean. In the servlet layer it is easy, all you need to do is
// test the spring framework
ServletContext servletContext =this.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils.
getRequiredWebApplicationContext(servletContext);
User user = (User)wac.getBean("user");
But if you are in the business layer, how do you reach the application context? The Spring reference has example of loading the xml file directly. But that is not a good way to do it. I just want to get the context and call getBean.
Thanks for the help.
-- Jin
Recommended Books for Learning Spring
Spring in Action ~ Craig Walls
Spring Recipes: A Problem-Solution Approach ~ Gary Mak
Professional Java Development with the Spring Framework ~ Rod Johnson PhD
Pro Java EE Spring Patterns: Best Practices and Design Strategies ~ Dhrubojyoti Kayal