本文整理了Java中org.springframework.web.context.WebApplicationContext.getParent()
方法的一些代码示例,展示了WebApplicationContext.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebApplicationContext.getParent()
方法的具体详情如下:
包路径:org.springframework.web.context.WebApplicationContext
类名称:WebApplicationContext
方法名:getParent
暂无
代码示例来源:origin: spring-projects/spring-framework
@Override
protected WebApplicationContext initWebAppContext() {
ServletContext servletContext = this.webAppContext.getServletContext();
Assert.state(servletContext != null, "No ServletContext");
ApplicationContext rootWac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (rootWac == null) {
rootWac = this.webAppContext;
ApplicationContext parent = this.webAppContext.getParent();
while (parent != null) {
if (parent instanceof WebApplicationContext && !(parent.getParent() instanceof WebApplicationContext)) {
rootWac = parent;
break;
}
parent = parent.getParent();
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootWac);
}
return this.webAppContext;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void verifyRootWacConfig() {
ApplicationContext parent = wac.getParent();
assertNotNull(parent);
assertFalse(parent instanceof WebApplicationContext);
assertEquals("ear", ear);
assertEquals("root", root);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void verifyRootWacSupport() {
assertEquals("foo", foo);
assertEquals("bar", bar);
ApplicationContext parent = wac.getParent();
assertNotNull(parent);
assertTrue(parent instanceof WebApplicationContext);
WebApplicationContext root = (WebApplicationContext) parent;
assertFalse(root.getBeansOfType(String.class).containsKey("bar"));
ServletContext childServletContext = wac.getServletContext();
assertNotNull(childServletContext);
ServletContext rootServletContext = root.getServletContext();
assertNotNull(rootServletContext);
assertSame(childServletContext, rootServletContext);
assertSame(root, rootServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
assertSame(root, childServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Verify that the breaking change introduced in <a
* href="https://jira.spring.io/browse/SPR-12553">SPR-12553</a> has been reverted.
*
* <p>This code has been copied from
* {@link org.springframework.test.context.hierarchies.web.ControllerIntegrationTests}.
*
* @see org.springframework.test.context.hierarchies.web.ControllerIntegrationTests#verifyRootWacSupport()
*/
private void verifyRootWacSupport() {
assertNotNull(personDao);
assertNotNull(personController);
ApplicationContext parent = wac.getParent();
assertNotNull(parent);
assertTrue(parent instanceof WebApplicationContext);
WebApplicationContext root = (WebApplicationContext) parent;
ServletContext childServletContext = wac.getServletContext();
assertNotNull(childServletContext);
ServletContext rootServletContext = root.getServletContext();
assertNotNull(rootServletContext);
assertSame(childServletContext, rootServletContext);
assertSame(root, rootServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
assertSame(root, childServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* See SPR-12553 and SPR-13075.
*/
@Test
public void rootWacServletContainerAttributeNotPreviouslySetWithContextHierarchy() {
StaticApplicationContext ear = new StaticApplicationContext();
StaticWebApplicationContext root = new StaticWebApplicationContext();
root.setParent(ear);
root.setServletContext(this.servletContext);
StaticWebApplicationContext dispatcher = new StaticWebApplicationContext();
dispatcher.setParent(root);
dispatcher.setServletContext(this.servletContext);
DefaultMockMvcBuilder builder = webAppContextSetup(dispatcher);
WebApplicationContext wac = builder.initWebAppContext();
assertSame(dispatcher, wac);
assertSame(root, wac.getParent());
assertSame(ear, wac.getParent().getParent());
assertSame(root, WebApplicationContextUtils.getRequiredWebApplicationContext(this.servletContext));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* See SPR-12553 and SPR-13075.
*/
@Test
public void rootWacServletContainerAttributePreviouslySetWithContextHierarchy() {
StubWebApplicationContext root = new StubWebApplicationContext(this.servletContext);
this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, root);
StaticWebApplicationContext child = new StaticWebApplicationContext();
child.setParent(root);
child.setServletContext(this.servletContext);
DefaultMockMvcBuilder builder = webAppContextSetup(child);
assertSame(builder.initWebAppContext().getParent(),
WebApplicationContextUtils.getRequiredWebApplicationContext(this.servletContext));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void verifyDispatcherWacConfig() {
ApplicationContext parent = wac.getParent();
assertNotNull(parent);
assertTrue(parent instanceof WebApplicationContext);
ApplicationContext grandParent = parent.getParent();
assertNotNull(grandParent);
assertFalse(grandParent instanceof WebApplicationContext);
ServletContext dispatcherServletContext = wac.getServletContext();
assertNotNull(dispatcherServletContext);
ServletContext rootServletContext = ((WebApplicationContext) parent).getServletContext();
assertNotNull(rootServletContext);
assertSame(dispatcherServletContext, rootServletContext);
assertSame(parent,
rootServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
assertSame(parent,
dispatcherServletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
assertEquals("ear", ear);
assertEquals("root", root);
assertEquals("dispatcher", dispatcher);
}
代码示例来源:origin: org.grails/grails-web
public static void configureServletContextAttributes(ServletContext servletContext, GrailsApplication application, GrailsPluginManager pluginManager, WebApplicationContext webContext) {
servletContext.setAttribute(ApplicationAttributes.PLUGIN_MANAGER, pluginManager);
// use config file locations if available
servletContext.setAttribute(ApplicationAttributes.PARENT_APPLICATION_CONTEXT, webContext.getParent());
servletContext.setAttribute(GrailsApplication.APPLICATION_ID, application);
servletContext.setAttribute(ApplicationAttributes.APPLICATION_CONTEXT, webContext);
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test
@Override
protected WebApplicationContext initWebAppContext() {
ServletContext servletContext = this.webAppContext.getServletContext();
Assert.state(servletContext != null, "No ServletContext");
ApplicationContext rootWac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (rootWac == null) {
rootWac = this.webAppContext;
ApplicationContext parent = this.webAppContext.getParent();
while (parent != null) {
if (parent instanceof WebApplicationContext && !(parent.getParent() instanceof WebApplicationContext)) {
rootWac = parent;
break;
}
parent = parent.getParent();
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootWac);
}
return this.webAppContext;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
protected WebApplicationContext initWebAppContext() {
ServletContext servletContext = this.webAppContext.getServletContext();
ApplicationContext rootWac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
if (rootWac == null) {
rootWac = this.webAppContext;
ApplicationContext parent = this.webAppContext.getParent();
while (parent != null) {
if (parent instanceof WebApplicationContext && !(parent.getParent() instanceof WebApplicationContext)) {
rootWac = parent;
break;
}
parent = parent.getParent();
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootWac);
}
return this.webAppContext;
}
代码示例来源:origin: stackoverflow.com
public abstract class AutowireCapableDispatcherServlet extends DispatcherServlet {
@Override
protected void initFrameworkServlet() {
super.initFrameworkServlet();
AutowireCapableBeanFactory autowireCapableBeanFactory = wac
.getAutowireCapableBeanFactory();
autowireCapableBeanFactory.autowireBean(this);
WebApplicationContext wac = getWebApplicationContext();
ApplicationContext parent = wac.getParent();
if(parent != null){
autowireCapableBeanFactory = parent.getAutowireCapableBeanFactory();
autowireCapableBeanFactory.autowireBean(this);
}
}
}
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
private void debug(final WebApplicationContext ctx) {
// DEBUG
if ( DEBUG ) {
logger.debug("SearchServlet: Context Display name = "
+ ctx.getDisplayName());
logger.debug("SearchServlet: Context ID = " + ctx.getId());
if (ctx.getParent() == null) {
logger.debug("SearchServlet: Context Parent is null.");
} else {
logger.debug("SearchServlet: Context Parent Display name = "
+ ctx.getParent().getDisplayName());
}
if (ctx.getServletContext() == null) {
logger.debug("SearchServlet: ServletContext is null.");
} else {
logger.debug("SearchServlet: ServletContext path = "
+ ctx.getServletContext().getContextPath());
logger.debug("SearchServlet: ServletContext context name = "
+ ctx.getServletContext().getServletContextName());
}
}
// DEBUG
}
代码示例来源:origin: org.eagle-i/eagle-i-search-gwt
logger.debug( "InstanceServlet: Context Display name = " + ctx.getDisplayName() );
logger.debug( "InstanceServlet: Context ID = " + ctx.getId() );
if ( ctx.getParent() == null ) {
logger.debug( "InstanceServlet: Context Parent is null." );
} else {
logger.debug( "InstanceServlet: Context Parent Display name = " + ctx.getParent().getDisplayName() );
内容来源于网络,如有侵权,请联系作者删除!