当前位置: 首页>>代码示例>>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;未经允许,请勿转载。