本文整理了Java中org.springframework.context.support.ClassPathXmlApplicationContext.close()
方法的一些代码示例,展示了ClassPathXmlApplicationContext.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPathXmlApplicationContext.close()
方法的具体详情如下:
包路径:org.springframework.context.support.ClassPathXmlApplicationContext
类名称:ClassPathXmlApplicationContext
方法名:close
暂无
代码示例来源:origin: spring-projects/spring-framework
@After
public void after() {
if (enabled != null) {
System.setProperty("ENABLED", enabled);
}
else {
System.clearProperty("ENABLED");
}
if (context != null) {
context.close();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testSingleConfigLocationWithClass() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(SIMPLE_CONTEXT, getClass());
assertTrue(ctx.containsBean("someMessageSource"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testResourceArrayPropertyEditor() throws IOException {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONTEXT_WILDCARD);
Service service = (Service) ctx.getBean("service");
assertEquals(3, service.getResources().length);
List<Resource> resources = Arrays.asList(service.getResources());
assertTrue(resources.contains(new FileSystemResource(new ClassPathResource(FQ_CONTEXT_A).getFile())));
assertTrue(resources.contains(new FileSystemResource(new ClassPathResource(FQ_CONTEXT_B).getFile())));
assertTrue(resources.contains(new FileSystemResource(new ClassPathResource(FQ_CONTEXT_C).getFile())));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testSingleConfigLocation() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(FQ_SIMPLE_CONTEXT);
assertTrue(ctx.containsBean("someMessageSource"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testChildWithProxy() throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONTEXT_WILDCARD);
ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(
new String[] {CHILD_WITH_PROXY_CONTEXT}, ctx);
assertTrue(AopUtils.isAopProxy(child.getBean("assemblerOne")));
assertTrue(AopUtils.isAopProxy(child.getBean("assemblerTwo")));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testFactoryBeanAndApplicationListener() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONTEXT_WILDCARD);
ctx.getBeanFactory().registerSingleton("manualFBAAL", new FactoryBeanAndApplicationListener());
assertEquals(2, ctx.getBeansOfType(ApplicationListener.class).size());
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void staticScriptImplementingInterface() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerImpl"));
Messenger messenger = (Messenger) ctx.getBean("messengerImpl");
String desiredMessage = "Hello World!";
assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
ctx.close();
assertNull(messenger.getMessage());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void staticWithScriptReturningInstance() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerInstance"));
Messenger messenger = (Messenger) ctx.getBean("messengerInstance");
String desiredMessage = "Hello World!";
assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
ctx.close();
assertNull(messenger.getMessage());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void staticScriptWithTwoInterfacesSpecified() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bshContext.xml", getClass());
assertTrue(Arrays.asList(ctx.getBeanNamesForType(Messenger.class)).contains("messengerWithConfigExtra"));
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerWithConfigExtra");
messenger.setMessage(null);
assertNull(messenger.getMessage());
assertTrue(ctx.getBeansOfType(Messenger.class).values().contains(messenger));
ctx.close();
assertNull(messenger.getMessage());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void customAnnotationUsedForBothComponentScanAndQualifier() {
ClassPathXmlApplicationContext context = loadContext("customAnnotationUsedForBothComponentScanAndQualifierTests.xml");
KustomAnnotationAutowiredBean testBean = (KustomAnnotationAutowiredBean) context.getBean("testBean");
assertNotNull(testBean.getDependency());
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void defaultDestroyMethod() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(CONFIG);
ITestBean testBean = (ITestBean) context.getBean("nonRefreshableTestBean");
assertFalse(testBean.isDestroyed());
context.close();
assertTrue(testBean.isDestroyed());
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void customTypeFilter() {
ClassPathXmlApplicationContext context = loadContext("customTypeFilterTests.xml");
KustomAnnotationAutowiredBean testBean = (KustomAnnotationAutowiredBean) context.getBean("testBean");
assertNotNull(testBean.getDependency());
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testDefaultScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyDefaultTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should not be a proxy
assertFalse(AopUtils.isAopProxy(bean));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testNoScopedProxy() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/context/annotation/scopedProxyNoTests.xml");
context.getBeanFactory().registerScope("myScope", new SimpleMapScope());
ScopedProxyTestBean bean = (ScopedProxyTestBean) context.getBean("scopedProxyTestBean");
// should not be a proxy
assertFalse(AopUtils.isAopProxy(bean));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void schedulerRepositoryExposure() throws Exception {
ClassPathXmlApplicationContext ctx = context("schedulerRepositoryExposure.xml");
assertSame(SchedulerRepository.getInstance().lookup("myScheduler"), ctx.getBean("scheduler"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void nonMatchingResourcePattern() {
ClassPathXmlApplicationContext context = loadContext("nonMatchingResourcePatternTests.xml");
assertFalse(context.containsBean("fooServiceImpl"));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void matchingResourcePattern() {
ClassPathXmlApplicationContext context = loadContext("matchingResourcePatternTests.xml");
assertTrue(context.containsBean("fooServiceImpl"));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testMultipleConfigLocationsWithClass() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
new String[] {CONTEXT_B, CONTEXT_C, CONTEXT_A}, getClass());
assertTrue(ctx.containsBean("service"));
assertTrue(ctx.containsBean("logicOne"));
assertTrue(ctx.containsBean("logicTwo"));
ctx.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void componentScanWithAutowiredQualifier() {
ClassPathXmlApplicationContext context = loadContext("componentScanWithAutowiredQualifierTests.xml");
AutowiredQualifierFooService fooService = (AutowiredQualifierFooService) context.getBean("fooService");
assertTrue(fooService.isInitCalled());
assertEquals("bar", fooService.foo(123));
context.close();
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void aspectjTypeFilter() {
ClassPathXmlApplicationContext context = loadContext("aspectjTypeFilterTests.xml");
assertTrue(context.containsBean("fooServiceImpl"));
assertTrue(context.containsBean("stubFooDao"));
assertFalse(context.containsBean("scopedProxyTestBean"));
context.close();
}
内容来源于网络,如有侵权,请联系作者删除!