Java Code Examples for org.springframework.context.support.FileSystemXmlApplicationContext#close()
The following examples show how to use
org.springframework.context.support.FileSystemXmlApplicationContext#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbToXML.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) { if (args.length != 2) { System.err.println("Usage:"); System.err.println("java " + DbToXML.class.getName() + " <context.xml> <output.xml>"); System.exit(1); } String contextPath = args[0]; File outputFile = new File(args[1]); // Create the Spring context FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(contextPath); DbToXML dbToXML = new DbToXML(context, outputFile); dbToXML.execute(); // Shutdown the Spring context context.close(); }
Example 2
Source File: JarContainerServer.java From happor with MIT License | 5 votes |
public JarContainerServer(String filename) { FileSystemXmlApplicationContext serverContext = new FileSystemXmlApplicationContext(filename); HapporServerElement element = serverContext.getBean(HapporServerElement.class); server = element.getServer(); containerConfig = element.getConfigs().get("container"); log4jConfig = element.getConfigs().get("log4j"); serverContext.close(); }
Example 3
Source File: ContextLoader.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Unloads a context (Red5 application) and removes it from the context map, then removes it's beans from the parent (that is, Red5) * * @param name * Context name */ public void unloadContext(String name) { log.debug("Un-load context - name: {}", name); ApplicationContext context = contextMap.remove(name); log.debug("Context from map: {}", context); String[] bnames = BeanFactoryUtils.beanNamesIncludingAncestors(context); for (String bname : bnames) { log.debug("Bean: {}", bname); } ConfigurableBeanFactory factory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); if (factory.containsSingleton(name)) { log.debug("Context found in parent, destroying: {}", name); FileSystemXmlApplicationContext ctx = (FileSystemXmlApplicationContext) factory.getSingleton(name); if (ctx.isRunning()) { log.debug("Context was running, attempting to stop"); ctx.stop(); } if (ctx.isActive()) { log.debug("Context is active, attempting to close"); ctx.close(); } else { try { factory.destroyBean(name, ctx); } catch (Exception e) { log.warn("Context destroy failed for: {}", name, e); } finally { if (factory.containsSingleton(name)) { log.debug("Singleton still exists, trying another destroy method"); ((DefaultListableBeanFactory) factory).destroySingleton(name); } } } } else { log.debug("Context does not contain singleton: {}", name); } context = null; }