List of usage examples for org.springframework.context ConfigurableApplicationContext refresh
void refresh() throws BeansException, IllegalStateException;
From source file:org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer.java
/** * Refreshes the given ApplicationContext making the context active. * * @param applicationContext the ConfigurableApplicationContext to refresh. * @return the refreshed ApplicationContext. * @see org.springframework.context.ConfigurableApplicationContext * @see org.springframework.context.ConfigurableApplicationContext#refresh() * @throws java.lang.IllegalArgumentException if the ApplicationContext reference is null! *//*from w ww . j ava 2s . co m*/ protected ConfigurableApplicationContext refreshApplicationContext( ConfigurableApplicationContext applicationContext) { Assert.notNull(applicationContext, "The ConfigurableApplicationContext reference must not be null!"); applicationContext.refresh(); return applicationContext; }
From source file:org.springframework.migrationanalyzer.commandline.AbstractMigrationAnalysis.java
final void run(String[] args) { CommandLine commandLine = null;/* w ww . j a v a2 s .c o m*/ try { commandLine = new PosixParser().parse(OPTIONS, args); String outputType = commandLine.getOptionValue(OptionsFactory.OPTION_KEY_OUTPUT_TYPE); String outputPath = commandLine.getOptionValue(OptionsFactory.OPTION_KEY_OUTPUT_PATH); String[] excludes = commandLine.getOptionValues(OptionsFactory.OPTION_KEY_EXCLUDE); String inputPath = getInputPath(commandLine); try { ConfigurableApplicationContext applicationContext = getApplicationContext(); applicationContext.addBeanFactoryPostProcessor(new ConfigurationRegisteringBeanFactoryPostProcessor( new Configuration(inputPath, outputPath, outputType, excludes))); applicationContext.refresh(); applicationContext.getBean(MigrationAnalysisExecutor.class).execute(); } catch (RuntimeException re) { this.logger.error("A failure occurred. Please see earlier output for details."); exit(-1); } } catch (ParseException e) { displayUsage(); exit(-1); } }
From source file:org.springframework.richclient.test.SpringRichTestCase.java
protected final void setUp() throws Exception { try {// w ww . j a va 2 s. c om Application.load(null); ConfigurableApplicationContext applicationContext = createApplicationContext(); applicationServices = new DefaultApplicationServices(applicationContext); new ApplicationServicesLocator(applicationServices); final ApplicationLifecycleAdvisor advisor = createApplicationLifecycleAdvisor(); final Application application = new Application(advisor); advisor.setApplication(application); Application.instance().setApplicationContext(applicationContext); applicationServices.setApplicationContext(applicationContext); registerBasicServices(applicationServices); registerAdditionalServices(applicationServices); applicationContext.refresh(); doSetUp(); } catch (Exception e) { Application.load(null); throw e; } }
From source file:org.springframework.xd.dirt.stream.FileSourceModuleTests.java
@Test public void testSplitterUsesIterator() throws Exception { System.out.println(System.getProperty("user.dir")); ConfigurableApplicationContext ctx = new FileSystemXmlApplicationContext( new String[] { "../modules/common/file-source-common-context.xml", "classpath:org/springframework/xd/dirt/stream/ppc-context.xml" }, false);//from w w w.j a va 2 s.c o m StandardEnvironment env = new StandardEnvironment(); Properties props = new Properties(); props.setProperty("fixedDelay", "5"); props.setProperty("timeUnit", "SECONDS"); props.setProperty("initialDelay", "0"); props.setProperty("withMarkers", "false"); PropertiesPropertySource pps = new PropertiesPropertySource("props", props); env.getPropertySources().addLast(pps); env.setActiveProfiles("use-contents-with-split"); ctx.setEnvironment(env); ctx.refresh(); FileSplitter splitter = ctx.getBean(FileSplitter.class); File foo = File.createTempFile("foo", ".txt"); final AtomicReference<Method> splitMessage = new AtomicReference<>(); ReflectionUtils.doWithMethods(FileSplitter.class, new MethodCallback() { @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { method.setAccessible(true); splitMessage.set(method); } }, new MethodFilter() { @Override public boolean matches(Method method) { return method.getName().equals("splitMessage"); } }); Object result = splitMessage.get().invoke(splitter, new GenericMessage<File>(foo)); assertThat(result, instanceOf(Iterator.class)); ctx.close(); foo.delete(); }