private static void checkExecutors(ConfigurableApplicationContext context) {
    final Map<String, Object> executors = new HashMap<>();

    executors.putAll(context.getBeansOfType(OperationExecutorFactory.class));

    executors.putAll(context.getBeansOfType(OperationExecutor.class));

    if (executors.size() == 0) {
      log.warn("!!! Configuration Warning !!!");
      log.warn(
          "No registered OperationExecutor/Factory instances found, please check your classpath for bundles.");
      log.warn(" ---    --------------    ---");
    } else {
      log.info("### Configured OperationExecutor/Factory instances ###");
      executors.forEach((k, v) -> log.info("-- " + k + " [" + v.getClass().getName() + "]"));
    }
  }
  public void doTest() {
    ConfigurableApplicationContext ac =
        new ClassPathXmlApplicationContext("classpath:" + searchConfigFileName);
    searchInfoTypeMap = ac.getBeansOfType(SearchTypeInfo.class);
    searchCriteriaTypeMap = ac.getBeansOfType(SearchCriteriaTypeInfo.class);
    searchResultTypeInfoMap = ac.getBeansOfType(SearchResultTypeInfo.class);
    queryMap = (Map<String, String>) ac.getBean("queryMap");
    ac.close();

    out.println("(!) This page was automatically generated on " + new Date());
    out.println("DO NOT UPDATE MANUALLY!");
    out.println("");
    out.print(
        "This page represents a formatted view of ["
            + searchConfigFileName
            + "|https://test.kuali.org/svn/student/trunk/"
            + projectLocation
            + "/src/main/resources/"
            + searchConfigFileName
            + "]");
    out.println("");
    out.println("----");
    out.println("{toc}");
    out.println("----");
    SearchConfigValidator validator = new SearchConfigValidator(searchInfoTypeMap, queryMap);

    List<String> errors = validator.validate();
    if (errors.size() > 0) {
      fail(
          searchConfigFileName
              + " failed search config validation:\n"
              + this.formatAsString(errors));
    }

    SearchConfigFormatter formatter = new SearchConfigFormatter(searchInfoTypeMap, queryMap);
    out.println(formatter.formatForWiki());
  }
  @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(
            "/merchandisefulfilmentprocess/test/merchandisefulfilmentprocess-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;
  }
Example #4
0
  public static void main(String[] args) {
    final ConfigurableApplicationContext context =
        new AnnotationConfigApplicationContext(AppConfig.class, DbConfig.class);
    System.out.println("spring-tx-text start");

    try {
      context.start();

      if (LOGGER.isDebugEnabled()) {
        final Map<String, Object> beanDefMap = context.getBeansOfType(Object.class);
        LOGGER.debug("Bean definitions: {}", beanDefMap);
      }

      // run application service
      context.getBean(AppService.class).run(args);

      context.getBean(DbaService.class).doDbAccess();
    } finally {
      context.close();
    }
  }
Example #5
0
  @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(
            "/octannerfulfilmentprocess/test/octannerfulfilmentprocess-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;
  }