List of usage examples for org.springframework.context.support SimpleThreadScope SimpleThreadScope
SimpleThreadScope
From source file:com.apress.prospringintegration.corespring.iocbasics.BasicIoCMain.java
public static void main(String[] args) { ApplicationContext app = new ClassPathXmlApplicationContext("ioc_basics.xml"); BasicPOJO basicPOJO = (BasicPOJO) app.getBean("basic-pojo"); assert basicPOJO != null; System.out.println(basicPOJO.getColor()); ColorEnum colorEnum = (ColorEnum) app.getBean("randomColor"); System.out.println("randomColor: " + colorEnum); colorEnum = (ColorEnum) app.getBean("exclusiveColor"); System.out.println("exclusiveColor: " + colorEnum); ColorPicker colorPicker = (ColorPicker) app.getBean(ColorPicker.class); assert colorPicker != null; System.out.println(colorPicker.getColorRandomizer().randomColor()); BasicIoCMain.demonstrateScopes(app); // Custom Scope Registration with SimpleThreadScope ConfigurableApplicationContext configApp = (ConfigurableApplicationContext) app; configApp.getBeanFactory().registerScope("thread", new SimpleThreadScope()); }
From source file:org.wte4j.examples.showcase.server.config.WebContextTestExecutionListener.java
@Override public void prepareTestInstance(TestContext testContext) { if (testContext.getApplicationContext() instanceof GenericApplicationContext) { GenericApplicationContext context = (GenericApplicationContext) testContext.getApplicationContext(); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new SimpleThreadScope()); beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SimpleThreadScope()); }// w w w.jav a2s . com }
From source file:dk.nsi.haiba.epimibaimporter.config.SimpleThreadScopeConfigurer.java
public SimpleThreadScopeConfigurer() { super();/*w w w . j a v a 2 s. c o m*/ super.setScopes(new HashMap<String, Object>() { { put("thread", new SimpleThreadScope()); } }); }
From source file:dhbw.ka.mwi.businesshorizon2.tests.ui.assets.TestExecutionListener.java
@Override public void prepareTestInstance(TestContext testContext) throws Exception { if (testContext.getApplicationContext() instanceof GenericApplicationContext) { GenericApplicationContext context = (GenericApplicationContext) testContext.getApplicationContext(); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); Scope requestScope = new SimpleThreadScope(); beanFactory.registerScope("request", requestScope); Scope sessionScope = new SimpleThreadScope(); beanFactory.registerScope("session", sessionScope); }//from www .ja va 2 s. c om }
From source file:py.una.pol.karaku.test.configuration.BaseTestConfiguration.java
@Bean public CustomScopeConfigurer configurer() { CustomScopeConfigurer toRet = new CustomScopeConfigurer(); Map<String, Object> map = new HashMap<String, Object>(); map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION, new SimpleThreadScope()); map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION_MANUAL, new SimpleThreadScope()); map.put(WebApplicationContext.SCOPE_SESSION, new SimpleThreadScope()); toRet.setScopes(map);/*from w ww .jav a 2 s. c o m*/ return toRet; }