List of usage examples for org.springframework.context.support FileSystemXmlApplicationContext close
@Override public void close()
From source file:org.jaffre.springframework.JaffreExporterTestCase.java
public void test() throws Exception { final File l_fileAppContext; final FileSystemXmlApplicationContext l_appCtx; l_fileAppContext = PackageFile.get("test-resources/appcontext01.xml"); assertTrue(l_fileAppContext.isFile()); l_appCtx = new FileSystemXmlApplicationContext(l_fileAppContext.getPath()); l_appCtx.start();// w w w . j a v a 2 s .c o m assertEquals(6, l_appCtx.getBeanDefinitionCount()); assertNotNull(l_appCtx.getBean("jaffreClient")); assertNotNull(l_appCtx.getBean("jaffreServer")); assertNotNull(l_appCtx.getBean("jaffreConnector")); assertNotNull(l_appCtx.getBean("jaffreExporter")); assertNotNull(l_appCtx.getBean("throwException")); assertNotNull(l_appCtx.getBean("greeting")); l_appCtx.stop(); l_appCtx.close(); }
From source file:org.red5.server.jboss.JbossLoader.java
/** * Shut server down// w ww . jav a 2 s . c o m */ public void stop() { logger.info("Shutting down jboss context"); try { //prepare spring for shutdown Introspector.flushCaches(); //shutdown our jmx agent JMXAgent.shutdown(); //shutdown spring FileSystemXmlApplicationContext appContext = (FileSystemXmlApplicationContext) getApplicationContext(); ConfigurableBeanFactory factory = appContext.getBeanFactory(); if (factory.containsSingleton("default.context")) { for (String scope : factory.getRegisteredScopeNames()) { logger.debug("Registered scope: " + scope); } for (String singleton : factory.getSingletonNames()) { logger.debug("Registered singleton: " + singleton); //factory.destroyScopedBean(singleton); } factory.destroySingletons(); } appContext.close(); LogFactory.release(Thread.currentThread().getContextClassLoader()); } catch (Exception e) { logger.warn("Jboss could not be stopped", e); } }
From source file:org.activiti.crystalball.anttasks.RunSimulationTask.java
public void execute() { log("Starting simulation run [" + simRunBean + "] from application context [" + appContext + "]."); // seting app context if (appContext == null) { throw new BuildException("No application context set."); }// w w w . j a va 2 s .co m FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(appContext); try { // getting simulation run SimulationRun simRun = null; if (simRunBean != null) simRun = (SimulationRun) applicationContext.getBean(simRunBean); if (simRun == null) { log("Using default simulation run bean", Project.MSG_WARN); simRun = applicationContext.getBean(SimulationRun.class); } if (simRun == null) { throw new BuildException("unable to get sim run bean"); } // // execute simulation run // simRun.execute(getStartDate(), getEndDate()); } catch (ParseException e) { log("Simulation task exception - parsing dates", Project.MSG_ERR); throw new BuildException(e); } catch (Exception e) { log("Simulation task exception - simulation run error", Project.MSG_ERR); throw new BuildException(e); } finally { applicationContext.close(); } log("Simulation run [" + simRunBean + "] from application context [" + appContext + "] done."); }
From source file:org.openspaces.admin.application.ApplicationFileDeployment.java
private static ApplicationConfig readConfigFromXmlFile(final String applicationFilePath) throws BeansException { ApplicationConfig config;/*ww w . jav a 2 s. c o m*/ // Convert to URL to workaround the "everything is a relative paths problem" // see spring documentation 5.7.3 FileSystemResource caveats. String fileUri = new File(applicationFilePath).toURI().toString(); final FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(fileUri); try { //CR: Catch runtime exceptions. convert to AdminException(s) context.refresh(); config = context.getBean(ApplicationConfig.class); } finally { if (context.isActive()) { context.close(); } } return config; }