當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextLoader.initWebApplicationContext方法代碼示例

本文整理匯總了Java中org.springframework.web.context.ContextLoader.initWebApplicationContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextLoader.initWebApplicationContext方法的具體用法?Java ContextLoader.initWebApplicationContext怎麽用?Java ContextLoader.initWebApplicationContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.web.context.ContextLoader的用法示例。


在下文中一共展示了ContextLoader.initWebApplicationContext方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateTargetUrlWithContextLoader

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
@Test
public void updateTargetUrlWithContextLoader() throws Exception {
	StaticWebApplicationContext wac = new StaticWebApplicationContext();
	wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class);

	MockServletContext servletContext = new MockServletContext();
	ContextLoader contextLoader = new ContextLoader(wac);
	contextLoader.initWebApplicationContext(servletContext);

	try {
		RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class);
		wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor);

		RedirectView rv = new RedirectView();
		rv.setUrl("/path");

		MockHttpServletRequest request = createRequest();
		HttpServletResponse response = new MockHttpServletResponse();

		given(mockProcessor.processUrl(request, "/path")).willReturn("/path?key=123");

		rv.render(new ModelMap(), request, response);

		verify(mockProcessor).processUrl(request, "/path");
	}
	finally {
		contextLoader.closeWebApplicationContext(servletContext);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:30,代碼來源:RedirectViewTests.java

示例2: init

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
@BeforeClass
public static void init() {
	mockServletContext = new MockServletContext();
	String configLocations = "classpath:TagSpringBeans.xml";
	mockServletContext.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, configLocations);
	ContextLoader loader = new ContextLoader();
	loader.initWebApplicationContext(mockServletContext);
}
 
開發者ID:tamerman,項目名稱:mobile-starting-framework,代碼行數:9,代碼來源:DefinitionListDefinitionTagTest.java

示例3: init

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
@BeforeClass
public static void init() {
	mockServletContext = new MockServletContext();
	String configLocations = "classpath:TagSpringBeans.xml";
	mockServletContext.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, configLocations);
	ContextLoader loader = new ContextLoader();
	loader.initWebApplicationContext(mockServletContext);

	nci.setKmeProperties(new Properties());
}
 
開發者ID:tamerman,項目名稱:mobile-starting-framework,代碼行數:11,代碼來源:PageTagTest.java

示例4: init

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
@BeforeClass
public static void init() {
	mockServletContext = new MockServletContext();
	String configLocations = "classpath:ThemeTestSpringBeans.xml";
	mockServletContext.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, configLocations);
	ContextLoader loader = new ContextLoader();
	loader.initWebApplicationContext(mockServletContext);
}
 
開發者ID:tamerman,項目名稱:mobile-starting-framework,代碼行數:9,代碼來源:PageTagThemeTest.java

示例5: registerSubContext

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
public void registerSubContext(String webAppKey) {
    // get the sub contexts - servlet context
    ServletContext ctx = servletContext.getContext(webAppKey);
    if (ctx == null) {
        ctx = servletContext;
    }
    ContextLoader loader = new ContextLoader();
    ConfigurableWebApplicationContext appCtx = (ConfigurableWebApplicationContext) loader.initWebApplicationContext(ctx);
    appCtx.setParent(applicationContext);
    appCtx.refresh();

    ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);

    ConfigurableBeanFactory appFactory = appCtx.getBeanFactory();

    logger.debug("About to grab Webcontext bean for {}", webAppKey);
    Context webContext = (Context) appCtx.getBean("web.context");
    webContext.setCoreBeanFactory(parentFactory);
    webContext.setClientRegistry(clientRegistry);
    webContext.setServiceInvoker(globalInvoker);
    webContext.setScopeResolver(globalResolver);
    webContext.setMappingStrategy(globalStrategy);

    WebScope scope = (WebScope) appFactory.getBean("web.scope");
    scope.setServer(server);
    scope.setParent(global);
    scope.register();
    scope.start();

    // register the context so we dont try to reinitialize it
    registeredContexts.add(ctx);

}
 
開發者ID:Red5,項目名稱:red5-server,代碼行數:34,代碼來源:WarLoaderServlet.java

示例6: registerSubContext

import org.springframework.web.context.ContextLoader; //導入方法依賴的package包/類
public void registerSubContext(String webAppKey) {
	// get the sub contexts - servlet context
	ServletContext ctx = servletContext.getContext(webAppKey);
	if (ctx == null) {
		ctx = servletContext;
	}
	ContextLoader loader = new ContextLoader();
	ConfigurableWebApplicationContext appCtx = (ConfigurableWebApplicationContext) loader.initWebApplicationContext(ctx);
	appCtx.setParent(applicationContext);
	appCtx.refresh();

	ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx);

	ConfigurableBeanFactory appFactory = appCtx.getBeanFactory();

	logger.debug("About to grab Webcontext bean for {}", webAppKey);
	Context webContext = (Context) appCtx.getBean("web.context");
	webContext.setCoreBeanFactory(parentFactory);
	webContext.setClientRegistry(clientRegistry);
	webContext.setServiceInvoker(globalInvoker);
	webContext.setScopeResolver(globalResolver);
	webContext.setMappingStrategy(globalStrategy);

	WebScope scope = (WebScope) appFactory.getBean("web.scope");
	scope.setServer(server);
	scope.setParent(global);
	scope.register();
	scope.start();

	// register the context so we dont try to reinitialize it
	registeredContexts.add(ctx);

}
 
開發者ID:cwpenhale,項目名稱:red5-mobileconsole,代碼行數:34,代碼來源:WarLoaderServlet.java


注:本文中的org.springframework.web.context.ContextLoader.initWebApplicationContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。