Example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext.

Prototype

public ClassPathXmlApplicationContext(String... configLocations) throws BeansException 

Source Link

Document

Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.

Usage

From source file:com.dianping.dpsf.other.echo.EchoServer.java

/**
 * @param args//  w  ww .j a  v a  2  s.c  o  m
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer1============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer2.java

/**
 * @param args//w  ww  .j av  a 2s .c  om
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer2============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server2.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer3.java

/**
 * @param args/* w  w w . j a v a2s .  c o  m*/
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer3============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server3.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer4.java

/**
 * @param args//from w ww .  ja  va 2s .c  om
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer4============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server4.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:biz.c24.io.spring.integration.samples.fpml.EngineMain.java

/**
 * @param args//from   w w  w .  j  ava 2 s . c o  m
 */
public static void main(String[] args) {

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:/biz/c24/io/spring/integration/samples/fpml/si-context.xml");

    context.registerShutdownHook();

}

From source file:com.javacreed.examples.sc.part1.Main.java

public static void main(final String[] args) {
    final String xmlFile = "META-INF/spring/app-context.xml";
    try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(xmlFile)) {

        final Worker worker = context.getBean(Worker.class);
        System.out.println("Worker class: " + worker.getClass().getCanonicalName());
        worker.longTask(1);//from  w w  w.  ja v  a2 s . co  m
        worker.longTask(1);
        worker.longTask(1);
        worker.longTask(2);
        worker.longTask(2);

        // Short task is not cached
        worker.shortTask(1);
        worker.shortTask(1);
    }
}

From source file:com.apress.prospringintegration.corespring.aop.MainAOP.java

public static void main(String[] args) throws Exception {

    ApplicationContext app = new ClassPathXmlApplicationContext("ioc_aop.xml");
    PurchaseOrderProcessor orderProcessor = app.getBean(PurchaseOrderProcessor.class);

    PurchaseOrder order = new PurchaseOrder();
    order.setItemCost(1000.00f);/*from  ww  w .ja  v a 2 s .c o  m*/
    Receipt receipt = orderProcessor.processPurchaseOrder(order);

    PurchaseOrderDiscountProcessor orderDiscountProcessor = (PurchaseOrderDiscountProcessor) orderProcessor;
    Receipt discountedReceipt = orderDiscountProcessor.processDiscountOrder(order,
            DiscountStrategy.HALF_OFF_ENTIRE);

    System.out.println(String.format("Total discounted purchase amount (given %s discount): %f ",
            DiscountStrategy.HALF_OFF_ENTIRE,
            (discountedReceipt.getPurchaseAmt() - discountedReceipt.getDiscountedAmount())));
}

From source file:com.apress.prospringintegration.messageflow.resequencer.MainResequencer.java

public static void main(String[] args) throws Exception {

    ApplicationContext context = new ClassPathXmlApplicationContext("resequencer.xml");

    SimpleSendingClient simple = context.getBean("simpleSendingClient", SimpleSendingClient.class);
    simple.kickOff();//  w  w w. jav a2 s  .  c  o m
}

From source file:com.apress.prospringintegration.corespring.config.annotation.AnnotationMain.java

public static void main(String[] args) throws Exception {
    ApplicationContext app = new ClassPathXmlApplicationContext("ioc_annotations.xml");

    ColorPicker cp = app.getBean(ColorPicker.class);
    assert cp != null;
    assert cp.getColorRandomizer() != null;
    System.out.println(cp.getColorRandomizer().randomColor());
}

From source file:com.apress.prospringintegration.stream.StreamLog.java

public static void main(String[] args) throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring/stream/stream-log.xml");
}