本文整理了Java中org.springframework.context.ApplicationContext.getParent()
方法的一些代码示例,展示了ApplicationContext.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.getParent()
方法的具体详情如下:
包路径:org.springframework.context.ApplicationContext
类名称:ApplicationContext
方法名:getParent
[英]Return the parent context, or null if there is no parent and this is the root of the context hierarchy.
[中]返回父上下文,如果没有父上下文且这是上下文层次结构的根,则返回null。
代码示例来源: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
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ContextHierarchyDirtiesContextTests.context = applicationContext;
ContextHierarchyDirtiesContextTests.baz = applicationContext.getBean("bean", String.class);
ContextHierarchyDirtiesContextTests.bar = applicationContext.getParent().getBean("bean", String.class);
ContextHierarchyDirtiesContextTests.foo = applicationContext.getParent().getParent().getBean("bean", String.class);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Before
public void verifyContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void contextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("parent", parent);
assertEquals("parent + user", user);
assertEquals("from UserConfig", beanFromUserConfig);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo", foo);
assertEquals("bar", bar);
assertEquals("baz-child", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo", foo);
assertEquals("bar", bar);
assertEquals("baz-child", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Override
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo-level-2", foo);
assertEquals("bar", bar);
assertEquals("baz", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Override
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo-level-2", foo);
assertEquals("bar", bar);
assertEquals("baz", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo", foo);
assertEquals("bar", bar);
assertEquals("baz-child", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Override
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("foo-level-2", foo);
assertEquals("bar", bar);
assertEquals("baz", baz);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Override
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertNull("grandparent ApplicationContext", context.getParent().getParent());
assertEquals("parent", parent);
assertEquals("parent + test user", user);
assertEquals("from TestUserConfig", beanFromTestUserConfig);
assertNull("Bean from UserConfig should not be present.", beanFromUserConfig);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void grandparentNull() {
assertTrue("grandparent is null", applicationContext.getParent().getParent() == null);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNull("parent ApplicationContext", context.getParent());
assertEquals("foo", foo);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void verifyEarConfig() {
assertFalse(context instanceof WebApplicationContext);
assertNull(context.getParent());
assertEquals("ear", ear);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNull("parent ApplicationContext", context.getParent());
assertEquals("foo-level-1", foo);
assertEquals("bar", bar);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNull("parent ApplicationContext", context.getParent());
assertEquals("foo-level-1", foo);
assertEquals("bar", bar);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNull("parent ApplicationContext", context.getParent());
assertEquals("foo-level-1", foo);
assertEquals("bar", bar);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Override
public void loadContextHierarchy() {
assertNotNull("child ApplicationContext", context);
assertNotNull("parent ApplicationContext", context.getParent());
assertEquals("foo-level-2", foo);
assertEquals("bar", bar);
assertEquals("baz", baz);
}
代码示例来源: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));
}
内容来源于网络,如有侵权,请联系作者删除!