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

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

Introduction

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

Prototype

@Override
    public void stop() 

Source Link

Usage

From source file:org.gflogger.perftest.SpringTest.java

public static void main(String[] args) throws Throwable {
    final SpringTest springTest = new SpringTest();
    final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:app-context.xml");
    ctx.start();/*from  w  w  w.  j a v a  2s.com*/

    springTest.test();

    ctx.stop();
}

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

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

    try {/*from w ww.  java2 s  .  co m*/
        Thread.sleep(180000);
    } catch (InterruptedException e) {
        //do nothing
    }
    context.stop();
}

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

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

    try {//from   w w  w  .j  a  v  a2  s .com
        Thread.sleep(180000);
    } catch (InterruptedException e) {
        //do nothing
    }
    context.stop();
}

From source file:org.camelcookbook.structuringroutes.simplespring.SpringCamelApplication.java

public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "META-INF/spring/simplespring-context.xml");
    applicationContext.start();//from w  w w . ja  v  a 2  s. c o  m

    // let the Camel runtime do its job for 5 seconds
    Thread.sleep(5000);

    // shutdown
    applicationContext.stop();
}

From source file:org.camelcookbook.structuringroutes.simplespring.SpringJavaDslApplication.java

public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "META-INF/spring/simplespring-java-context.xml");
    applicationContext.start();/*  w  w w. j  ava2s  .c  om*/

    // let the Camel runtime do its job for 5 seconds
    Thread.sleep(5000);

    // shutdown
    applicationContext.stop();
}

From source file:com.apress.prospringintegration.social.mail.SmtpMail.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/smtp-mail.xml",
            SmtpMail.class);

    MessageChannel input = context.getBean("input", MessageChannel.class);

    Message<String> message = MessageBuilder.withPayload("This is a test").build();
    input.send(message);//from   www  .ja va2 s.  c o m

    context.stop();
}

From source file:com.apress.prospringintegration.social.xmpp.XmppOutbound.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "/spring/xmpp/xmpp-outbound.xml", XmppOutbound.class);

    MessageChannel input = context.getBean("input", MessageChannel.class);

    Message<String> message = MessageBuilder.withPayload("This is a test").build();
    input.send(message);//w  w w.  ja v  a  2s.  c om

    context.stop();
}

From source file:org.sourceopen.hadoop.hbase.replication.server.Consumer.java

public static void main(String args[]) {
    try {/* w  w  w  .  j  a  va 2  s  .  co m*/
        final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(SPRING_PATH);
        // ?
        Runtime.getRuntime().addShutdownHook(new Thread() {

            @Override
            public void run() {
                try {
                    context.stop();
                    context.close();
                    LOG.info("Consumer server stopped");
                    System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())
                            + " Consumer server stoped");
                } catch (Throwable t) {
                    LOG.error("Fail to stop consumer server: ", t);
                }
                synchronized (Consumer.class) {
                    running = false;
                    Consumer.class.notify();
                }

            }
        });
        Configuration conf = HBaseConfiguration.create();
        conf.addResource(ConsumerConstants.COMMON_CONFIG_FILE);
        conf.addResource(ConsumerConstants.CONSUMER_CONFIG_FILE);
        Consumer.start(conf);
        LOG.info("Consumer server started");
        System.out.println(
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " Consumer server started");

    } catch (Throwable t) {
        LOG.error("Fail to start consumer server: ", t);
        System.exit(-1);
    }
    synchronized (Consumer.class) {
        while (running) {
            try {
                Consumer.class.wait();
            } catch (Throwable t) {
                LOG.error("Consumer server got runtime errors: ", t);
            }
        }
    }
}

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

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

    MessageChannel add = context.getBean("operation", MessageChannel.class);
    add.send(MessageBuilder.withPayload("Hello").build());

    try {/* ww  w .  j av  a 2s. com*/
        Thread.sleep(180000);
    } catch (InterruptedException e) {
        //do nothing
    }
    context.stop();
}

From source file:nl.mindef.c2sc.nbs.olsr.pud.uplink.server.Main.java

public static void main(String[] args) {
    logger.info("RelayServer starting");
    try {/*from  w ww.  java 2s .  c  om*/
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                "classpath:META-INF/spring/application-context.xml");

        logger.info("RelayServer started");

        context.start();

        UplinkReceiver uplinkReceiver = (UplinkReceiver) context.getBean("UplinkReceiver");
        uplinkReceiver.join();

        logger.info("RelayServer stopped");

        context.stop();
        context.close();
        context.destroy();
    } catch (Exception e) {
        e.printStackTrace();
    }
}