本文整理了Java中org.springframework.context.ConfigurableApplicationContext.close()
方法的一些代码示例,展示了ConfigurableApplicationContext.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConfigurableApplicationContext.close()
方法的具体详情如下:
包路径:org.springframework.context.ConfigurableApplicationContext
类名称:ConfigurableApplicationContext
方法名:close
[英]Close this application context, releasing all resources and locks that the implementation might hold. This includes destroying all cached singleton beans.
Note: Does not invoke close on a parent context; parent contexts have their own, independent lifecycle.
This method can be called multiple times without side effects: Subsequent close calls on an already closed context will be ignored.
[中]关闭此应用程序上下文,释放实现可能持有的所有资源和锁。这包括销毁所有缓存的单例bean。
注意:不在父上下文上调用close;父上下文有自己独立的生命周期。
可以多次调用此方法而不会产生副作用:将忽略对已关闭上下文的后续关闭调用。
代码示例来源:origin: spring-projects/spring-framework
/**
* Close the view bean factory on context shutdown.
*/
@Override
public void destroy() throws BeansException {
if (this.cachedFactory != null) {
this.cachedFactory.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void contextDestroyed(ServletContextEvent sce) {
this.applicationContext.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* This implementation closes the Spring ApplicationContext.
*/
@Override
public void stop() {
logger.debug("Stopping SpringContextResourceAdapter");
if (this.applicationContext != null) {
this.applicationContext.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (this.context != null) {
this.context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (context != null) {
context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (this.context != null) {
this.context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (this.ctx != null) {
this.ctx.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (this.context != null) {
this.context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void closeContext() {
if (this.context != null) {
this.context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void close() {
if (this.ctx != null) {
this.ctx.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void tearDown() {
if (ctx != null) {
ctx.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testAutodetectNoMBeans() throws Exception {
ConfigurableApplicationContext ctx = load("autodetectNoMBeans.xml");
try {
ctx.getBean("exporter");
}
finally {
ctx.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void cacheResolver() {
ConfigurableApplicationContext context = new GenericXmlApplicationContext(
"/org/springframework/cache/config/annotationDrivenCacheNamespace-resolver.xml");
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = new GenericXmlApplicationContext(
"/org/springframework/cache/config/annotationDrivenCacheNamespace-manager-resolver.xml");
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-11692
@SuppressWarnings("unchecked")
public void expressionIsCacheBasedOnActualMethod() {
ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(SharedConfig.class, Spr11692Config.class);
BaseDao<User> userDao = (BaseDao<User>) context.getBean("userDao");
BaseDao<Order> orderDao = (BaseDao<Order>) context.getBean("orderDao");
userDao.persist(new User("1"));
orderDao.persist(new Order("2"));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
private void assertApplicationContextLoadsAndContainsFooString(MergedContextConfiguration mergedConfig)
throws Exception {
ApplicationContext applicationContext = loader.loadContext(mergedConfig);
assertNotNull(applicationContext);
assertEquals("foo", applicationContext.getBean(String.class));
assertTrue(applicationContext instanceof ConfigurableApplicationContext);
((ConfigurableApplicationContext) applicationContext).close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void invokedAsynchronously() {
ConfigurableApplicationContext context = initContext(
new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
Thread mainThread = Thread.currentThread();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertNotSame(mainThread, asyncThread);
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void emptyConfigSupport() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
CacheInterceptor ci = context.getBean(CacheInterceptor.class);
assertNotNull(ci.getCacheResolver());
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager());
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-6354
public void destroyLazyInitSchedulerWithCustomShutdownOrderDoesNotHang() {
ConfigurableApplicationContext context =
new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", getClass());
assertNotNull(context.getBean("lazyInitSchedulerWithCustomShutdownOrder"));
StopWatch sw = new StopWatch();
sw.start("lazyScheduler");
context.close();
sw.stop();
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " +
sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-6354
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {
ConfigurableApplicationContext context =
new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", getClass());
assertNotNull(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder"));
StopWatch sw = new StopWatch();
sw.start("lazyScheduler");
context.close();
sw.stop();
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " +
sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
}
内容来源于网络,如有侵权,请联系作者删除!