1 package org.directwebremoting.guice.spring;
2
3 import javax.servlet.ServletContext;
4
5 import org.springframework.beans.factory.BeanFactory;
6 import org.springframework.web.context.ContextLoader;
7 import org.springframework.web.context.WebApplicationContext;
8 import org.springframework.web.context.support.WebApplicationContextUtils;
9
10 /**
11 * A BeanFactory loader that loads a WebApplicationContext given a servlet context.
12 */
13 public class WebApplicationContextLoader implements BeanFactoryLoader
14 {
15 public WebApplicationContextLoader(ServletContext servletContext)
16 {
17 this.servletContext = servletContext;
18 }
19
20 public BeanFactory loadBeanFactory()
21 {
22 new ContextLoader().initWebApplicationContext(servletContext);
23 return WebApplicationContextUtils.getWebApplicationContext(servletContext);
24 }
25
26 private final ServletContext servletContext;
27 }