/** * {@inheritDoc} * <p>The parent {@linkplain #getEnvironment() environment} is * delegated to this (child) context if the parent is a * {@link org.springframework.context.ConfigurableApplicationContext} implementation. * <p>The parent {@linkplain #getServletContext() servlet context} is * delegated to this (child) context if the parent is a {@link WebApplicationContext} * implementation. */ @Override public void setParent(ApplicationContext parent) { super.setParent(parent); if (parent instanceof WebApplicationContext) { this.servletContext = ((WebApplicationContext) parent).getServletContext(); } }
/** * {@inheritDoc} * <p>The parent {@linkplain #getEnvironment() environment} is * delegated to this (child) context if the parent is a * {@link ConfigurableApplicationContext} implementation. * <p>The parent {@linkplain #getServletContext() servlet context} is * delegated to this (child) context if the parent is a {@link WebApplicationContext} * implementation. */ @Override public void setParent(ApplicationContext parent) { super.setParent(parent); if (parent instanceof WebApplicationContext) { this.servletContext = ((WebApplicationContext) parent).getServletContext(); } }
public ExtendsSpringBeanContainer(ExtendsSpringBeanContainer parent, ClassLoader loader, Class<? extends AbstractRefreshableConfigApplicationContext> clazz) { if (inited == true) return; inited = true; try { applicationContext = clazz.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } applicationContext.setParent(parent.getBeanContainerPrototype()); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setClassLoader(loader); applicationContext.refresh(); }
public ExtendsSpringBeanContainer(ExtendsSpringBeanContainer parent, List<FileObject> files, ClassLoader loader, Class<? extends AbstractRefreshableConfigApplicationContext> clazz) { if (inited == true) return; inited = true; List<String> configLocations = new ArrayList<String>(); for (FileObject fileObject : files) { String urlString = fileObject.getURL().toString(); if (!configLocations.contains(urlString)) { configLocations.add(urlString); LOGGER.logMessage(LogLevel.INFO, "添加Spring配置文件:{urlString}", urlString); } } try { applicationContext = clazz.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } applicationContext.setConfigLocations(listToArray(configLocations)); applicationContext.setParent(parent.getBeanContainerPrototype()); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.setClassLoader(loader); applicationContext.refresh(); // initNoBeanCaseInfo(); }