use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.
the class ClassPathBeanDefinitionScannerScopeIntegrationTests method sessionScopeWithNoProxy.
@Test
public void sessionScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("session");
// should not be a proxy
assertFalse(AopUtils.isAopProxy(bean));
assertEquals(DEFAULT_NAME, bean.getName());
bean.setName(MODIFIED_NAME);
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
// not a proxy so this should not have changed
assertEquals(MODIFIED_NAME, bean.getName());
// but a newly retrieved bean should have the default name
ScopedTestBean bean2 = (ScopedTestBean) context.getBean("session");
assertEquals(DEFAULT_NAME, bean2.getName());
}
use of org.springframework.context.ApplicationContext in project spring-framework by spring-projects.
the class ClassPathBeanDefinitionScannerScopeIntegrationTests method sessionScopeWithProxiedTargetClass.
@Test
public void sessionScopeWithProxiedTargetClass() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(TARGET_CLASS);
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
// should be a class-based proxy
assertTrue(AopUtils.isCglibProxy(bean));
assertTrue(bean instanceof ScopedTestBean);
assertTrue(bean instanceof SessionScopedTestBean);
assertEquals(DEFAULT_NAME, bean.getName());
bean.setName(MODIFIED_NAME);
RequestContextHolder.setRequestAttributes(newRequestAttributesWithSession);
// this is a proxy so it should be reset to default
assertEquals(DEFAULT_NAME, bean.getName());
bean.setName(MODIFIED_NAME);
IScopedTestBean bean2 = (IScopedTestBean) context.getBean("session");
assertEquals(MODIFIED_NAME, bean2.getName());
bean2.setName(DEFAULT_NAME);
assertEquals(DEFAULT_NAME, bean.getName());
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
assertEquals(MODIFIED_NAME, bean.getName());
}
use of org.springframework.context.ApplicationContext in project centipede by paulhoule.
the class CentipedeShell method parseOptions.
private CentipedeShellOptions parseOptions(String[] arguments) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
ApplicationContext bootstrapContext = newContext(getBootstrapApplicationContextPath());
OptionParser parser = new OptionParser(CentipedeShellOptions.class);
wireupOptionParser(bootstrapContext, parser);
closeContext(bootstrapContext);
return (CentipedeShellOptions) parser.parse(newArrayList(arguments));
}
use of org.springframework.context.ApplicationContext in project centipede by paulhoule.
the class StaticCentipedeShellTest method defaultEvaluationIsDefinedInFiles.
@Test
public void defaultEvaluationIsDefinedInFiles() {
ApplicationContext c = newContext(objectCountingContext());
assertEquals(1, ObjectThatCountsClassInstances.get());
Object that = c.getBean("l");
assertEquals(2, ObjectThatCountsClassInstances.get());
((AbstractApplicationContext) c).close();
assertEquals(0, ObjectThatCountsClassInstances.get());
}
use of org.springframework.context.ApplicationContext in project sharding-jdbc by dangdangdotcom.
the class SpringNamespaceWithMasterSlaveMain method main.
// CHECKSTYLE:OFF
public static void main(final String[] args) throws SQLException {
// CHECKSTYLE:ON
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/applicationContextWithMasterSlave.xml");
OrderService orderService = applicationContext.getBean(OrderService.class);
orderService.insert();
orderService.select();
orderService.delete();
orderService.select();
}
Aggregations