Example usage for org.springframework.context ApplicationContext getClass

List of usage examples for org.springframework.context ApplicationContext getClass

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:mojo.view.util.DebugUtils.java

public static void logBeanNames(ApplicationContext ctx) {
    System.out.println(ctx.getClass().getName() + " bean names:");
    String[] beanNames = ctx.getBeanDefinitionNames();
    Arrays.sort(beanNames);//from ww  w.ja  va2 s  .  com

    for (String beanName : beanNames) {
        System.out.println("\t" + beanName);
    }
}

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(//from  w  w w.j  a  va  2s .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: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)
    //      {//from  w  w w  .j  a  v a2  s  .  com
    // 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)
    //      {/* ww  w.  j  ava  2s .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.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)
    //      {//w  ww. j av a 2 s  .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.acc.fulfilmentprocess.test.PaymentIntegrationTest.java

@BeforeClass
public static void prepare() throws Exception //NOPMD
{
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();/*ww  w .  j  a  v a  2s  . c om*/
    LOG.debug("Preparing...");

    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.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/bncfulfilmentprocess/test/bncfulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/bncfulfilmentprocess/test/bncfulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/bncfulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add("classpath:/bncfulfilmentprocess/test/process/payment-process.xml");

    //setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg
            .setCommandFactoryList(Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
}

From source file:com.exxonmobile.ace.hybris.fulfilmentprocess.test.PaymentIntegrationTest.java

@BeforeClass
public static void prepare() throws Exception //NOPMD
{
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();/* ww w. jav  a 2 s .  c o m*/
    LOG.debug("Preparing...");

    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.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/exxonmobilfulfilmentprocess/test/exxonmobilfulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/exxonmobilfulfilmentprocess/test/exxonmobilfulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/exxonmobilfulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add("classpath:/exxonmobilfulfilmentprocess/test/process/payment-process.xml");

    //setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg
            .setCommandFactoryList(Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
}

From source file:org.vinmonopolet.fulfilmentprocess.test.PaymentIntegrationTest.java

@BeforeClass
public static void prepare() throws Exception //NOPMD
{
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();/*from  ww  w .ja va2  s .co m*/
    LOG.debug("Preparing...");

    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.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/vinmonopoletfulfilmentprocess/test/vinmonopoletfulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/vinmonopoletfulfilmentprocess/test/vinmonopoletfulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/vinmonopoletfulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add("classpath:/vinmonopoletfulfilmentprocess/test/process/payment-process.xml");

    //setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg
            .setCommandFactoryList(Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
}

From source file:org.training.fulfilmentprocess.test.PaymentIntegrationTest.java

@BeforeClass
public static void prepare() throws Exception //NOPMD
{
    Registry.activateStandaloneMode();
    Utilities.setJUnitTenant();/*w  w  w  .j  av  a2s  .c  o m*/
    LOG.debug("Preparing...");

    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.setDocumentReaderClass(ScopeTenantIgnoreDocReader.class);
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/trainingfulfilmentprocess/test/trainingfulfilmentprocess-spring-test.xml"));
    xmlReader.loadBeanDefinitions(new ClassPathResource(
            "/trainingfulfilmentprocess/test/trainingfulfilmentprocess-spring-test-fraudcheck.xml"));
    xmlReader.loadBeanDefinitions(
            new ClassPathResource("/trainingfulfilmentprocess/test/process/order-process-spring.xml"));
    modelService = (ModelService) getBean("modelService");
    processService = (DefaultBusinessProcessService) getBean("businessProcessService");
    definitonFactory = processService.getProcessDefinitionFactory();

    LOG.warn("Prepare Process Definition factory...");
    definitonFactory.add("classpath:/trainingfulfilmentprocess/test/process/payment-process.xml");

    //setup command factory to mock
    final DefaultCommandFactoryRegistryImpl commandFactoryReg = appCtx
            .getBean(DefaultCommandFactoryRegistryImpl.class);
    commandFactoryReg
            .setCommandFactoryList(Arrays.asList((CommandFactory) appCtx.getBean("mockupCommandFactory")));

    taskServiceStub = appCtx.getBean(TaskServiceStub.class);
    productService = appCtx.getBean("defaultProductService", DefaultProductService.class);
    cartService = appCtx.getBean("defaultCartService", DefaultCartService.class);
    userService = appCtx.getBean("defaultUserService", DefaultUserService.class);
}

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  w w w. 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;
}