/** * Triggers {@link #refresh()} if not refreshed in the concrete context's * constructor already. */ @Override public void afterPropertiesSet() { if (!isActive()) { refresh(); } }
/** * Triggers {@link #refresh()} if not refreshed in the concrete context's * constructor already. */ @Override public void afterPropertiesSet() { if (!isActive()) { refresh(); } }
/** * Triggers {@link #refresh()} if not refreshed in the concrete context's * constructor already. */ @Override public void afterPropertiesSet() { if (!isActive()) { refresh(); } }
public ExtendsSpringBeanContainer() { if (inited == true) return; inited = true; initedByDefault = true; applicationContext = new FileSystemXmlApplicationContext(); applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.refresh(); }
/** * 当调用无参构造函数时,会默认初始化为FileSystemXmlApplicationContext实例 * 可通过此方法改变ApplicationContext的类型 * * @param clazz */ public void setApplicationType(Class<? extends AbstractRefreshableConfigApplicationContext> clazz) { if (initedByDefault == false) { throw new RuntimeException("该方法仅允许执行无参构造函数时调用"); } if (applicationContext != null) { applicationContext.destroy(); } try { applicationContext = clazz.newInstance(); } catch (Exception e) { throw new RuntimeException(e); } applicationContext.setAllowBeanDefinitionOverriding(true); applicationContext.refresh(); }
public void refresh() { applicationContext.setConfigLocations(listToArray(configs)); applicationContext.refresh(); }
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(); }
AbstractRefreshableConfigApplicationContext ctx = new ClassPathXmlApplicationContext(); // init empty Properties ftpSessionProps = new Properties(); ftpSessionProps.setProperty("user", "first"); StandardEnvironment env = new StandardEnvironment(); env.getPropertySources().addLast(new PropertiesPropertySource("pops", ftpSessionProps)); ctx.setEnvironment(env); ctx.setConfigLocation("classpath:main.xml"); // set the config here ctx.refresh(); ctx.start();
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(); }
this.applicationContext.refresh();
applicationContext.refresh();
this.applicationContext.refresh();
public void initialize() { applicationContext = new DefaultComponentManagerApplicationContext(componentManager.getContainerConfiguration(), parentApplicationContext); if (componentManager != null && applicationContext instanceof ComponentManagerAware) { ((ComponentManagerAware) applicationContext).setComponentManager(componentManager); } String [] checkedConfigurationResources = ApplicationContextUtils.getCheckedLocationPatterns(applicationContext, moduleDefinition.getConfigLocations()); if (ArrayUtils.isEmpty(checkedConfigurationResources)) { log.warn("There's no valid component configuration for addon module, '{}'.", name); } applicationContext.setConfigLocations(checkedConfigurationResources); applicationContext.refresh(); for (ModuleInstance moduleInstance : getModuleInstances()) { if (componentManager != null && moduleInstance instanceof ComponentManagerAware) { ((ComponentManagerAware) moduleInstance).setComponentManager(componentManager); } if (componentManager != null && moduleInstance instanceof ApplicationContextAware) { ((ApplicationContextAware) moduleInstance).setApplicationContext(applicationContext); } moduleInstance.initialize(); } }