List of usage examples for org.springframework.context ConfigurableApplicationContext getBeansOfType
<T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException;
From source file:org.onebusaway.nyc.vehicle_tracking.utility.SensorModelVerificationMain.java
public static void main(String[] args) throws ParseException, ClassNotFoundException, CsvEntityIOException, IOException { Options options = new Options(); options.addOption(ARG_RULE, true, "sensor model rule class"); GnuParser parser = new GnuParser(); CommandLine cli = parser.parse(options, args); args = cli.getArgs();/*from w w w . j a v a 2 s. c o m*/ if (args.length != 2) { System.err.println("usage: data-sources.xml tracesPath"); System.exit(-1); } ConfigurableApplicationContext context = ContainerLibrary.createContext( "classpath:org/onebusaway/nyc/vehicle_tracking/application-context.xml", "classpath:org/onebusaway/transit_data_federation/application-context.xml", args[0]); SensorModelVerificationMain m = new SensorModelVerificationMain(); context.getAutowireCapableBeanFactory().autowireBean(m); Collection<SensorModelRule> rules = Collections.emptyList(); if (cli.hasOption(ARG_RULE)) { Class<?> ruleClass = Class.forName(cli.getOptionValue(ARG_RULE)); rules = Arrays.asList((SensorModelRule) context.getBean(ruleClass)); } else { Map<String, SensorModelRule> rulesByName = context.getBeansOfType(SensorModelRule.class); rules = rulesByName.values(); } m.setRules(rules); File tracePath = new File(args[1]); List<File> traces = new ArrayList<File>(); getAllTraces(tracePath, traces); m.setTraces(traces); try { m.run(); } catch (Throwable ex) { ex.printStackTrace(); System.exit(-1); } System.exit(0); }
From source file:com.acc.fulfilmentprocess.test.PaymentIntegrationTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(// www .ja va 2 s .c o m new ClassPathResource("/bncfulfilmentprocess/test/bncfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); // if (definitonFactory != null) // { // TODO this test seems to let processes run after method completion - therefore we cannot // remove definitions !!! // definitonFactory.remove("testPlaceorder"); // definitonFactory.remove("testConsignmentFulfilmentSubprocess"); // } processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:org.training.fulfilmentprocess.test.PaymentIntegrationTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/trainingfulfilmentprocess/test/trainingfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); // if (definitonFactory != null) // {/*from w w w . j a v a2s . c o m*/ // TODO this test seems to let processes run after method completion - therefore we cannot // remove definitions !!! // definitonFactory.remove("testPlaceorder"); // definitonFactory.remove("testConsignmentFulfilmentSubprocess"); // } processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:com.exxonmobile.ace.hybris.fulfilmentprocess.test.PaymentIntegrationTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/exxonmobilfulfilmentprocess/test/exxonmobilfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); // if (definitonFactory != null) // {/* www.j a va 2 s . co m*/ // TODO this test seems to let processes run after method completion - therefore we cannot // remove definitions !!! // definitonFactory.remove("testPlaceorder"); // definitonFactory.remove("testConsignmentFulfilmentSubprocess"); // } processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:org.vinmonopolet.fulfilmentprocess.test.PaymentIntegrationTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/vinmonopoletfulfilmentprocess/test/vinmonopoletfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); // if (definitonFactory != null) // {/*from ww w . java 2s . c om*/ // TODO this test seems to let processes run after method completion - therefore we cannot // remove definitions !!! // definitonFactory.remove("testPlaceorder"); // definitonFactory.remove("testConsignmentFulfilmentSubprocess"); // } processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:com.mitre.fulfilmentprocess.test.PaymentIntegrationTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getGlobalApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/mitrefulfilmentprocess/test/mitrefulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); // if (definitonFactory != null) // {/*from ww w .j a v a2 s . c o m*/ // TODO this test seems to let processes run after method completion - therefore we cannot // remove definitions !!! // definitonFactory.remove("testPlaceorder"); // definitonFactory.remove("testConsignmentFulfilmentSubprocess"); // } processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:com.acc.fulfilmentprocess.test.ProcessFlowTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(/* w w w .j a va 2 s . c o m*/ new ClassPathResource("/bncfulfilmentprocess/test/bncfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null; processService = null; }
From source file:com.mitre.fulfilmentprocess.test.ProcessFlowTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/mitrefulfilmentprocess/test/mitrefulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null;/* w ww . j av a2s .co m*/ processService = null; }
From source file:org.training.fulfilmentprocess.test.ProcessFlowTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/trainingfulfilmentprocess/test/trainingfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null;/*from ww w .j av a 2 s .c om*/ processService = null; }
From source file:com.exxonmobile.ace.hybris.fulfilmentprocess.test.ProcessFlowTest.java
@AfterClass public static void removeProcessDefinitions() { LOG.debug("cleanup..."); final ApplicationContext appCtx = Registry.getApplicationContext(); assertTrue("Application context of type " + appCtx.getClass() + " is not a subclass of " + ConfigurableApplicationContext.class, appCtx instanceof ConfigurableApplicationContext); final ConfigurableApplicationContext applicationContext = (ConfigurableApplicationContext) appCtx; final ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory(); assertTrue("Bean Factory of type " + beanFactory.getClass() + " is not of type " + BeanDefinitionRegistry.class, beanFactory instanceof BeanDefinitionRegistry); final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory); xmlReader.loadBeanDefinitions(new ClassPathResource( "/exxonmobilfulfilmentprocess/test/exxonmobilfulfilmentprocess-spring-testcleanup.xml")); //cleanup command factory final Map<String, CommandFactory> commandFactoryList = applicationContext .getBeansOfType(CommandFactory.class); commandFactoryList.remove("mockupCommandFactory"); final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx .getBean(DefaultCommandFactoryRegistryImpl.class); commandFactoryReg.setCommandFactoryList(commandFactoryList.values()); processService.setTaskService(appCtx.getBean(DefaultTaskService.class)); definitonFactory = null;//from w w w. j a va 2s . c o m processService = null; }