Package org.springframework.context.support

Examples of org.springframework.context.support.AbstractApplicationContext


* @version
*/
public class CamelProxyUsingRefTest extends TestCase {

    public void testCamelProxyUsingRef() throws Exception {
        AbstractApplicationContext ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyUsingRefTest.xml");

        MyProxySender sender = ac.getBean("myProxySender", MyProxySender.class);
        String reply = sender.hello("World");

        assertEquals("Hello World", reply);

        // we're done so let's properly close the application context
        ac.close();
    }
View Full Code Here


    }
   
    void configure(Object beanInstance) {
        // check the ApplicationContext states first , and call the refresh if necessary
        if (applicationContext instanceof AbstractApplicationContext) {
            AbstractApplicationContext context = (AbstractApplicationContext) applicationContext;
            if (!context.isActive()) {
                context.refresh();
            }
        }
        configurer.configureBean(beanId, beanInstance);
    }
View Full Code Here

public class JmsToFileRouteTest extends Assert {
   
    @Test
    public void startRoute() throws Exception {
        AbstractApplicationContext applicationContext =
            new ClassPathXmlApplicationContext(new String[]{"/META-INF/spring/camelContext.xml"});
        CamelContext camelContext = (CamelContext)applicationContext.getBean("camelContext");
        assertNotNull("The camel context should not be null", camelContext);
        Thread.sleep(2000);       
        camelContext.stop();
        applicationContext.stop();
    }
View Full Code Here

    }
   
    @Test
    public void testStartApplicationContext() throws Exception {
        // test to boot up the application context from spring configuration
        AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/camel-context.xml");
        String[] names = context.getBeanNamesForType(CamelContext.class);
        assertEquals("There should be a camel context ", 1, names.length);
        CamelContext camelContext = context.getBean(names[0], CamelContext.class);
        assertNotNull(camelContext);
        Thread.sleep(2000);

        // we're done so let's properly close the application context
        context.close();
    }
View Full Code Here

      System.out.println("**************************");
      System.out.println("* JMS SAMPLE ON ACTIVEMQ *");
      System.out.println("**************************");

      // Create Spring context with the AbstractApplicationContext
      AbstractApplicationContext springCtx = new ClassPathXmlApplicationContext(
          "applicationContext-jms.xml");

      // Get a message producer
      MessageProducer messageProducer = (MessageProducer) springCtx
          .getBean("myMessageProducer");

      // Launch a Production/Consumption infinite cycle....
      while (true) {
        // Produce a message every 1 second
View Full Code Here

      System.out.println("*  ANNOTATION    *");
      System.out.println("*  SMALL CONFIG  *");
      System.out.println("******************");

      // Create Spring context with the AbstractApplicationContext
      AbstractApplicationContext springCtx = new ClassPathXmlApplicationContext(
          "applicationContext-jmx-annotations-smallconfig.xml");

      // Wait in order to use the JConsole to access to MBean server...
      long waitTime = 90000000;
      System.out
View Full Code Here

      System.out.println("*  JMX SAMPLE    *");
      System.out.println("*  NO ANNOTATION *");
      System.out.println("******************");

      // Create Spring context with the AbstractApplicationContext
      AbstractApplicationContext springCtx = new ClassPathXmlApplicationContext(
          "applicationContext-jmx-noannotations.xml");

      // Wait in order to use the JConsole to access to MBean server...
      long waitTime = 90000000;
      System.out
View Full Code Here

      System.out.println("*  ANNOTATION    *");
      System.out.println("*  NOTIFICATION  *");
      System.out.println("******************");

      // Create Spring context with the AbstractApplicationContext
      AbstractApplicationContext springCtx = new ClassPathXmlApplicationContext(
          "applicationContext-jmx-annotations.xml");

      // Wait in order to use the JConsole to access to MBean server...
      long waitTime = 90000000;
      System.out
View Full Code Here

    try {
      System.out.println("*********************");
      System.out.println("*  AUTOWIRE SAMPLE  *");
      System.out.println("*********************");
      // Create Spring context with the AbstractApplicationContext
      AbstractApplicationContext springCtx = new ClassPathXmlApplicationContext(
          "applicationContext-autowired.xml");

      // Get the processor beans
      DBProcessorV1 processor1 = (DBProcessorV1) springCtx
          .getBean("dbProcessorV1");
      DBProcessorV2 processor2 = (DBProcessorV2) springCtx
          .getBean("dbProcessorV2");

      // Call method
      System.out.println("=======DBProcessorV1=======");
      processor1.displayDBContent();
      processor1.displaySpringCtxBeanCount();
      System.out.println("=======DBProcessorV2=======");
      processor2.displayDBContent();
      processor2.displaySpringCtxBeanCount();
      processor2.displaySimplePojoCreation();

      // Add a shutdown hook for the above context because we are in a
      // non web application, in a web application a Spring context
      // shutdown hook registration is not needed because is alreay
      // included...
      springCtx.registerShutdownHook();
    } catch (Exception e) {
      e.printStackTrace();
    }

  }
View Full Code Here

  PropertyConfigurator.configure("log4j.properties");

  logger.debug("Starting app in: " + System.getProperty("user.dir"));

  // Load Spring context
  AbstractApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml");
  ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) context.getBean("pmScheduler");

  @SuppressWarnings("unchecked")
  ArrayList<ProcessCheckTask> processCheckTaskList = (ArrayList<ProcessCheckTask>) context
    .getBean("processCheckTaskList");

  // Schedule the process check tasks
  for (ProcessCheckTask task : processCheckTaskList) {
      ScheduledFuture<?> future = scheduler.schedule(task, new CronTrigger(task.getCron()));
      task.setScheduledFuture(future);
  }

  while (!Thread.interrupted()) {
      try {
    Thread.yield();
    Thread.sleep(2000);
      } catch (InterruptedException e) {
    logger.error("Thread error: " + e.getMessage());
      }
  }

  logger.debug("Stopping app...");

  scheduler.shutdown();
  context.close();

  logger.debug("Application stopped.");

  System.exit(0);
    }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.AbstractApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.