Java Code Examples for org.springframework.web.context.support.XmlWebApplicationContext#getBean()

The following examples show how to use org.springframework.web.context.support.XmlWebApplicationContext#getBean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockTdsContextLoader.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public ApplicationContext loadContext(String... locations) throws Exception {
  final MockServletContext servletContext = new MockTdsServletContext();
  final MockServletConfig servletConfig = new MockServletConfig(servletContext);
  final XmlWebApplicationContext webApplicationContext = new XmlWebApplicationContext();

  servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
  webApplicationContext.setServletConfig(servletConfig);
  webApplicationContext.setConfigLocations(locations);
  webApplicationContext.refresh();

  TdsContext tdsContext = webApplicationContext.getBean(TdsContext.class);
  checkContentRootPath(webApplicationContext, tdsContext);

  webApplicationContext.registerShutdownHook();

  return webApplicationContext;
}
 
Example 2
Source File: PathMatchingUrlHandlerMappingTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	MockServletContext sc = new MockServletContext("");
	wac = new XmlWebApplicationContext();
	wac.setServletContext(sc);
	wac.setConfigLocations(new String[] {CONF});
	wac.refresh();
	hm = (HandlerMapping) wac.getBean("urlMapping");
}
 
Example 3
Source File: PathMatchingUrlHandlerMappingTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	MockServletContext sc = new MockServletContext("");
	wac = new XmlWebApplicationContext();
	wac.setServletContext(sc);
	wac.setConfigLocations(new String[] {CONF});
	wac.refresh();
	hm = (HandlerMapping) wac.getBean("urlMapping");
}
 
Example 4
Source File: PathMatchingUrlHandlerMappingTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	MockServletContext sc = new MockServletContext("");
	wac = new XmlWebApplicationContext();
	wac.setServletContext(sc);
	wac.setConfigLocations(new String[] {CONF});
	wac.refresh();
	hm = (HandlerMapping) wac.getBean("urlMapping");
}