/** * Create a new AbstractApplicationContext with the given parent context. * @param parent the parent context */ public AbstractApplicationContext(@Nullable ApplicationContext parent) { this(); setParent(parent); }
/** * Create a new AbstractApplicationContext with the given parent context. * @param parent the parent context */ public AbstractApplicationContext(@Nullable ApplicationContext parent) { this(); setParent(parent); }
/** * Set the parent of this application context, also setting * the parent of the internal BeanFactory accordingly. * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory */ @Override public void setParent(@Nullable ApplicationContext parent) { super.setParent(parent); this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory()); }
/** * Set the parent of this application context, also setting * the parent of the internal BeanFactory accordingly. * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory */ @Override public void setParent(@Nullable ApplicationContext parent) { super.setParent(parent); this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory()); }
/** * Create a new AbstractApplicationContext with the given parent context. * @param parent the parent context */ public AbstractApplicationContext(@Nullable ApplicationContext parent) { this(); setParent(parent); }
/** * Set the parent of this application context, also setting * the parent of the internal BeanFactory accordingly. * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory */ @Override public void setParent(@Nullable ApplicationContext parent) { super.setParent(parent); this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory()); }
ApplicationContext parent =... AbstractApplicationContext contextA = new GenericXmlApplicationContext("classpath:contextA.xml"); contextA.setParent(parent); AbstractApplicationContext contextB = new GenericXmlApplicationContext("classpath:contextB.xml"); contextB.setParent(parent);
public void onApplicationEvent(ApplicationEvent event) { // only respond to ContextRefreshedEvents that are sourced from the parent context if (event.getSource() != parent) return; if (event instanceof ContextRefreshedEvent) { if (logger.isDebugEnabled()) logger.debug(format("Caught ContextRefreshedEvent from parent application context [%s], now refreshing [%s]", parent.getDisplayName(), child.getDisplayName())); copyBeanFactoryPostProcessors(); child.setParent(parent); child.refresh(); return; } if (event instanceof ContextClosedEvent) { if (logger.isDebugEnabled()) logger.debug(format("Caught ContextClosedEvent from parent application context [%s], now closing [%s]", parent.getDisplayName(), child.getDisplayName())); child.close(); return; } }
private void createChildContext() { if (appMetadata.isWebapp()) { applicationContext = new AnnotationConfigWebApplicationContext(); if (appMetadata.getConfigurationClasses().length > 0) { ((AnnotationConfigWebApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses()); } } else { applicationContext = new AnnotationConfigApplicationContext(); if (appMetadata.getConfigurationClasses().length > 0) { ((AnnotationConfigApplicationContext) applicationContext).register(appMetadata.getConfigurationClasses()); } } applicationContext.setParent(bootstrapApplicationContext); applicationContext.getEnvironment().getPropertySources().addFirst(new ArchaiusSpringPropertySource(appMetadata.getName() + "-archaius")); PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); configurer.setEnvironment(applicationContext.getEnvironment()); applicationContext.addBeanFactoryPostProcessor(configurer); applicationContext.setId(appMetadata.getName()); applicationContext.refresh(); }