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.apress.prospringintegration.ip.UdpSingle.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring/ip/udp-context.xml");
    MessageChannel messageChannel = (MessageChannel) context.getBean("sendUdp");
    messageChannel.send(MessageBuilder.withPayload("Testing UDP").build());
}

From source file:com.apress.prospringintegration.ip.TcpAdapter.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring/ip/tcp-context.xml");
    MessageChannel messageChannel = (MessageChannel) context.getBean("tcpSend");
    messageChannel.send(MessageBuilder.withPayload("Testing TCP").build());
}

From source file:com.newlandframework.rpc.boot.RpcServerStarter.java

public static void main(String[] args) {
    new ClassPathXmlApplicationContext("classpath:rpc-invoke-config-server.xml");
}

From source file:com.apress.prospringintegration.ip.UdpMulticast.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring/ip/udp-multicast.xml");
    MessageChannel messageChannel = (MessageChannel) context.getBean("sendUdp");
    messageChannel.send(MessageBuilder.withPayload("Testing UDP").build());
}

From source file:com.apress.prospringintegration.jmx.JmxNotificationPublisher.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "jmx/notification-publisher.xml");

    try {// w  w w .  java  2s . c o  m
        Thread.sleep(60000);
    } catch (InterruptedException e) {
        //do nothing
    }

    System.out.println("Sending message");
    MessageChannel send = context.getBean("send", MessageChannel.class);
    send.send(MessageBuilder.withPayload("Sample Message").build());

    try {
        Thread.sleep(180000);
    } catch (InterruptedException e) {
        //do nothing
    }
    context.stop();
}

From source file:com.kang.spring.integration.service.http.HttpClientDemo.java

/**
 * @param args/*www . j av  a2s.c  om*/
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    RequestGateway requestGateway = context.getBean("requestGateway", RequestGateway.class);
    String reply = requestGateway.echo("Hello");
    log.info("Replied with: " + reply);
}

From source file:org.jolokia.support.spring.sample.Application.java

public static void main(String[] args) throws InterruptedException {
    System.out.println("Starting up Spring sample application");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("/applicationContext.xml");
    synchronized (ctx) {
        ctx.wait();// www  .java 2  s .c o m
    }
}

From source file:com.apress.prospringintegration.messaging.activemq.jms.adapter.TicketReporterMain.java

public static void main(String[] args) throws Throwable {
    String contextName = "ticket-reporter.xml";

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName);
    applicationContext.start();//from w  w w.jav a 2  s .  c om

    ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class);
    TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class);

    while (true) {
        List<Ticket> tickets = ticketGenerator.createTickets();
        for (Ticket ticket : tickets) {
            problemReporter.openTicket(ticket);
        }

        Thread.sleep(5000);
    }
}

From source file:com.alacoder.lion.rpc.springsupport.DemoRpcClient.java

@SuppressWarnings({ "resource", "unused" })
public static void main(String[] args) throws InterruptedException {

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            new String[] { "classpath*:lion_demo_server.xml" });
    System.out.println("server start...");

    ApplicationContext ctx = new ClassPathXmlApplicationContext(
            new String[] { "classpath:lion_demo_client.xml" });

    DemoService service = (DemoService) ctx.getBean("lionDemoReferer");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        System.out.println(service.hello("lion " + i));
        Thread.sleep(1000);//w ww  . j  a va 2 s. c om
    }
    System.out.println("lion demo is finish.");
    System.exit(0);
}

From source file:com.orchestrationexample.registerinfoservice.server.Server.java

public static void main(String args[]) throws Exception {
    new ClassPathXmlApplicationContext("server-context.xml");
    System.in.read();//from w  w w . j  ava  2 s.c o  m
}