List of usage examples for org.springframework.context.support AbstractApplicationContext destroy
@Deprecated public void destroy()
From source file:cn.com.inhand.devicenetworks.ap.mq.rabbitmq.TaskNotificationConsumer.java
public static void main(String[] agrs) throws Exception { String path = "file:/home/han/myworks/workroom/NetBeansProjects/WSAP/RabbitMQDemo/RabbitMQDemo/src/main/webapp/WEB-INF/MQXMLApplicationContext.xml"; AbstractApplicationContext ctx = new FileSystemXmlApplicationContext(path); RabbitTemplate template = ctx.getBean(RabbitTemplate.class); template.convertAndSend("Hello, world!"); Thread.sleep(1000);/*from ww w .j a va2 s . co m*/ ctx.destroy(); }
From source file:com.anton.dev.tqrbs2.basic.BasicSpring.java
public static void main(String[] args) throws Exception { AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("basic-context.xml"); RabbitTemplate template = ctx.getBean(RabbitTemplate.class); String msg = "Hello, world Rabbit!"; LOGGER.info("Enviando Spring: " + msg); template.convertAndSend(msg);//w ww . java 2 s . c om Thread.sleep(1000); ctx.destroy(); }
From source file:com.googlecode.ehcache.annotations.config.EhCacheConfigBeanDefinitionParserTest.java
/** * 3 includes defined//from ww w . j a v a 2s . co m */ @Test public void testLoadContextTest1() { AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( "/com/googlecode/ehcache/annotations/config/evictExpiredElementsTest1.xml"); try { ExpiredElementEvictor evictor = (ExpiredElementEvictor) applicationContext .getBean(EhCacheConfigBeanDefinitionParser.EHCACHE_CONFIG_EVICTION_TASK_BEAN_NAME); Assert.assertNotNull(evictor); // minutes from configuration gets converted into milliseconds Assert.assertEquals(10, evictor.getInterval()); Assert.assertEquals(3, evictor.getCacheNameMatchers().size()); } finally { applicationContext.destroy(); } }
From source file:com.googlecode.ehcache.annotations.config.EhCacheConfigBeanDefinitionParserTest.java
/** * 3 excludes defined (will result in IncludeAll matcher being appended to front) *//*from ww w . ja v a2 s . c o m*/ @Test public void testLoadContextTest2() { AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( "/com/googlecode/ehcache/annotations/config/evictExpiredElementsTest2.xml"); try { ExpiredElementEvictor evictor = (ExpiredElementEvictor) applicationContext .getBean(EhCacheConfigBeanDefinitionParser.EHCACHE_CONFIG_EVICTION_TASK_BEAN_NAME); Assert.assertNotNull(evictor); // minutes from configuration gets converted into milliseconds Assert.assertEquals(20, evictor.getInterval()); Assert.assertEquals(4, evictor.getCacheNameMatchers().size()); } finally { applicationContext.destroy(); } }
From source file:com.googlecode.ehcache.annotations.config.EhCacheConfigBeanDefinitionParserTest.java
/** * 2 includes, 1 excludes defined/*from w ww. ja v a 2 s.c o m*/ */ @Test public void testLoadContextTest3() { AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( "/com/googlecode/ehcache/annotations/config/evictExpiredElementsTest3.xml"); try { ExpiredElementEvictor evictor = (ExpiredElementEvictor) applicationContext .getBean(EhCacheConfigBeanDefinitionParser.EHCACHE_CONFIG_EVICTION_TASK_BEAN_NAME); Assert.assertNotNull(evictor); // minutes from configuration gets converted into milliseconds Assert.assertEquals(20, evictor.getInterval()); Assert.assertEquals(3, evictor.getCacheNameMatchers().size()); } finally { applicationContext.destroy(); } }
From source file:com.googlecode.ehcache.annotations.config.EhCacheConfigBeanDefinitionParserTest.java
/** * control, no includes/excludes defined *///from www . j a v a 2s. c o m @Test public void testLoadControlContext() { AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( "/com/googlecode/ehcache/annotations/config/evictExpiredElementsTestControl.xml"); try { ExpiredElementEvictor evictor = (ExpiredElementEvictor) applicationContext .getBean(EhCacheConfigBeanDefinitionParser.EHCACHE_CONFIG_EVICTION_TASK_BEAN_NAME); Assert.assertNotNull(evictor); // minutes from configuration gets converted into milliseconds Assert.assertEquals(20, evictor.getInterval()); Assert.assertEquals(1, evictor.getCacheNameMatchers().size()); } finally { applicationContext.destroy(); } }
From source file:org.trpr.platform.runtime.impl.container.spring.SpringContainerImpl.java
/** * Helper method that locates and loads all Bootstrap extensions *///from w ww. j ava 2 s .c o m private void initializeBootstrapExtensions() { File[] bootstrapExtensionFiles = FileLocator.findFiles(RuntimeConstants.BOOTSTRAP_EXTENSIONS_FILE); // Create the Bootstrap Extension dependency manager that will load all bootstrap extensions BootstrapExtensionDependencyManager beManager = new BootstrapExtensionDependencyManager(this); for (File beFile : bootstrapExtensionFiles) { try { // add the "file:" prefix to file names to get around strange behavior of FileSystemXmlApplicationContext that converts absolute path // to relative path AbstractApplicationContext beDefinitionsContext = new FileSystemXmlApplicationContext( FILE_PREFIX + beFile.getAbsolutePath()); // All beans in the BE definitions context are expected to be of type BootstrapExtensionInfo. // We look up and load only these to BootstrapExtensionDependencyManager String[] beInfos = beDefinitionsContext.getBeanNamesForType(BootstrapExtensionInfo.class); for (String beInfo : beInfos) { beManager.addBootstrapExtensionInfo( (BootstrapExtensionInfo) beDefinitionsContext.getBean(beInfo)); } // destroy the beDefinitionsContext as we dont need it anymore beDefinitionsContext.destroy(); } catch (Exception e) { LOGGER.error("Error in loading BootStrap Extension File. Ignoring contents of : " + beFile.getAbsolutePath() + " .Error message : " + e.getMessage(), e); } } this.bootstrapExtensions = (BootstrapExtension[]) beManager.loadBootstrapExtensions() .toArray(new BootstrapExtension[0]); }
From source file:org.artifactory.webapp.servlet.ArtifactoryContextConfigListener.java
@Override public void contextDestroyed(ServletContextEvent event) { AbstractApplicationContext context = (AbstractApplicationContext) event.getServletContext() .getAttribute(ArtifactoryContext.APPLICATION_CONTEXT_KEY); try {/*from w w w . ja va2s . c o m*/ getLogger().debug("Context shutdown started"); if (context != null) { if (context instanceof ArtifactoryContext) { AddonsManager addonsManager = ((ArtifactoryContext) context).beanForType(AddonsManager.class); addonsManager.addonByType(HaCommonAddon.class).shutdown(); } context.destroy(); } if (artifactoryLockFile != null) { artifactoryLockFile.release(); } getLogger().debug("Context shutdown Finished"); } finally { event.getServletContext().removeAttribute(ArtifactoryContext.APPLICATION_CONTEXT_KEY); event.getServletContext().removeAttribute(ArtifactoryHome.SERVLET_CTX_ATTR); } }