本文整理匯總了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);
}
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}