本文整理了Java中org.springframework.context.annotation.AnnotationConfigApplicationContext.close()
方法的一些代码示例,展示了AnnotationConfigApplicationContext.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotationConfigApplicationContext.close()
方法的具体详情如下:
包路径:org.springframework.context.annotation.AnnotationConfigApplicationContext
类名称:AnnotationConfigApplicationContext
方法名:close
暂无
代码示例来源:origin: spring-projects/spring-framework
@After
public void tearDown() {
if (ctx != null) {
ctx.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@After
public void close() {
if (context != null) {
context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void importXmlWithAutowiredConfig() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlAutowiredConfig.class);
String name = ctx.getBean("xmlBeanName", String.class);
assertThat(name, equalTo("xml.declared"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void txManagerIsResolvedOnInvocationOfTransactionalMethod() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, TxManagerConfig.class);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
// invoke a transactional method, causing the PlatformTransactionManager bean to be resolved.
bean.findAllFoos();
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void txManagerIsResolvedCorrectlyWhenMultipleManagersArePresent() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, MultiTxManagerConfig.class);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
// invoke a transactional method, causing the PlatformTransactionManager bean to be resolved.
bean.findAllFoos();
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testSelfInjectHierarchy() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ChildConfig.class);
assertNotNull(context.getBean(MyComponent.class));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void spr14322FindsOnInterfaceWithInterfaceProxy() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigA.class);
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
bean.saveFoo();
bean.saveBar();
assertThat(txManager.begun, equalTo(2));
assertThat(txManager.commits, equalTo(2));
assertThat(txManager.rollbacks, equalTo(0));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void spr14322FindsOnInterfaceWithCglibProxy() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Spr14322ConfigB.class);
TransactionalTestInterface bean = ctx.getBean(TransactionalTestInterface.class);
CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class);
bean.saveFoo();
bean.saveBar();
assertThat(txManager.begun, equalTo(2));
assertThat(txManager.commits, equalTo(2));
assertThat(txManager.rollbacks, equalTo(0));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void importNonXmlResource() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportNonXmlResourceConfig.class);
assertTrue(ctx.containsBean("propertiesDeclaredBean"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void providesBeanMethodBeanDefinition() throws Exception {
AnnotationConfigApplicationContext context= new AnnotationConfigApplicationContext(Conf.class);
BeanDefinition beanDefinition = context.getBeanDefinition("myBean");
assertThat("should provide AnnotatedBeanDefinition", beanDefinition, instanceOf(AnnotatedBeanDefinition.class));
Map<String, Object> annotationAttributes =
((AnnotatedBeanDefinition) beanDefinition).getFactoryMethodMetadata().getAnnotationAttributes(MyAnnotation.class.getName());
assertThat(annotationAttributes.get("value"), equalTo("test"));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void asyncProcessorIsOrderedLowestPrecedenceByDefault() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AsyncConfig.class);
ctx.refresh();
AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
assertThat(bpp.getOrder(), is(Ordered.LOWEST_PRECEDENCE));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void orderAttributeIsPropagated() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(OrderedAsyncConfig.class);
ctx.refresh();
AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
assertThat(bpp.getOrder(), is(Ordered.HIGHEST_PRECEDENCE));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void transactionProxyIsCreated() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
EnableTxConfig.class, TxManagerConfig.class);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
Map<?,?> services = ctx.getBeansWithAnnotation(Service.class);
assertTrue("Stereotype annotation not visible", services.containsKey("testBean"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void transactionProxyIsCreatedWithEnableOnSuperclass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(
InheritedEnableTxConfig.class, TxManagerConfig.class);
TransactionalTestBean bean = ctx.getBean(TransactionalTestBean.class);
assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
Map<?,?> services = ctx.getBeansWithAnnotation(Service.class);
assertTrue("Stereotype annotation not visible", services.containsKey("testBean"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void proxyingOccurs() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AsyncConfig.class);
ctx.refresh();
AsyncBean asyncBean = ctx.getBean(AsyncBean.class);
assertThat(AopUtils.isAopProxy(asyncBean), is(true));
asyncBean.work();
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void spr12233() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(PropertySourcesPlaceholderConfigurer.class);
ctx.register(ImportConfiguration.class);
ctx.refresh();
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void spr11124MultipleAnnotations() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr11124Config.class);
Spr11124Service bean = context.getBean(Spr11124Service.class);
bean.single(2);
bean.single(2);
bean.multiple(2);
bean.multiple(2);
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void proxyingOccursWithMockitoStub() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(AsyncConfigWithMockito.class, AsyncBeanUser.class);
ctx.refresh();
AsyncBeanUser asyncBeanUser = ctx.getBean(AsyncBeanUser.class);
AsyncBean asyncBean = asyncBeanUser.getAsyncBean();
assertThat(AopUtils.isAopProxy(asyncBean), is(true));
asyncBean.work();
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void importWithPlaceholder() throws Exception {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
PropertySource<?> propertySource = new MapPropertySource("test",
Collections.<String, Object> singletonMap("test", "springframework"));
ctx.getEnvironment().getPropertySources().addFirst(propertySource);
ctx.register(ImportXmlConfig.class);
ctx.refresh();
assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void importXml() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlConfig.class);
assertTrue("did not contain java-declared bean", ctx.containsBean("javaDeclaredBean"));
assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
TestBean tb = ctx.getBean("javaDeclaredBean", TestBean.class);
assertEquals("myName", tb.getName());
ctx.close();
}
内容来源于网络,如有侵权,请联系作者删除!