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

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

Introduction

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

Prototype

@Override
public void close() 

Source Link

Document

Close this application context, destroying all beans in its bean factory.

Usage

From source file:org.ogcs.okra.example.game.Bootstrap.java

public static void main(String[] args) {
    LOG.info("PreBootstrap server.");
    ClassPathXmlApplicationContext context = null;
    try {//ww w  . j  a v  a2s.  c  o m
        context = new ClassPathXmlApplicationContext("classpath:spring/beans.xml");
        context.registerShutdownHook();
        LOG.info("Server bootstrap successful.");
    } catch (Exception e) {
        if (context != null)
            context.close();
        LOG.error("Server bootstrap failure.", e);
    }
}

From source file:com.chaosting.product.hotkey.Main.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    context.start();//from w w w  .j  av  a  2  s  .  com
    context.close();
}

From source file:org.londonsburning.proxy.ProxyPrinterRunner.java

/**
 * @param args FileName/*  w w  w .  j  a va2s. com*/
 */
public static void main(final String[] args) {
    String applicationContext = "applicationContext.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(applicationContext);
    FlagParser flagParser = (FlagParser) context.getBean("flagParser");
    flagParser.setFlags(args);
    flagParser.parse();
    ProxyPrinter printer = (ProxyPrinter) context.getBean("proxyPrinter");
    printer.printProxies(flagParser);
    context.close();
}

From source file:org.btc4j.ws.BtcDaemonServiceMain.java

public static void main(String[] args) {
    try {/*  www . j  a  va 2  s.  com*/
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("btc4j-ws-test.xml");
        BtcDaemonServicePort daemon = (BtcDaemonServicePort) ctx.getBean("btcDaemonService");
        //System.out.println("help: " + daemon.help("walletlock"));
        System.out.println("getAddressesByAccount: " + daemon.getAddressesByAccount("user"));
        //daemon.stop();
        ctx.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:org.btc4j.jms.BtcDaemonListenerMain.java

public static void main(String[] args) {
    try {//from   w  w  w .  ja v a  2 s.  c  o m
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("btc4j-jms-test.xml");
        BtcDaemonCaller caller = (BtcDaemonCaller) ctx.getBean("daemonCaller");
        System.out.println(caller.sendReceive("BTCAPI.JSON_RPC.INVOKE",
                "{\"jsonrpc\":\"2.0\",\"method\":\"help\",\"params\":[\"getblock\"],\"id\":\"400ec474-5b67-4f82-bb65-4e10ee807d04\"}"));
        ctx.close();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

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

public static void main(String args[]) {
    try {//  w w w.  j  av  a2 s  .  c om
        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:net.sf.companymanager.dbpopulator.DBPopulatorRunner.java

public static void main(final String... args) {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
            "dbpopulator-datasource-context.xml", "dbpopulator-jpa-context.xml", "services-context.xml",
            "facades-context.xml", "components-context.xml");
    DBPopulator populator = ctx.getBean(DBPopulator.class);
    logger.info("Populating database");
    populator.populate();//  ww  w. j ava  2 s.co  m
    logger.info("Database populated ");

    ctx.close();
}

From source file:net.sf.companymanager.dbpopulator.DBRefPopulatorRunner.java

public static void main(final String... args) {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
            "dbpopulator-ref-datasource-context.xml", "dbpopulator-jpa-context.xml", "services-context.xml",
            "facades-context.xml", "components-context.xml");
    DBPopulator populator = ctx.getBean(DBPopulator.class);
    logger.info("Populating database");
    populator.populate();/* w w w  .ja v a 2s. co  m*/
    logger.info("Database populated ");

    ctx.close();
}

From source file:net.sf.gazpachoquest.codelab.CodeLabRunner.java

public static void main(final String... args) throws IOException {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("codelab-datasource-context.xml",
            "codelab-jpa-context.xml", "services-context.xml", "facades-context.xml",
            "questionnaire-context.xml", "components-context.xml");
    logger.info("Hand on lab started");
    AccessRight2Lab codelab = ctx.getBean(AccessRight2Lab.class);
    codelab.execute();/*from   w  w w  .  j ava2  s  .  c o m*/
    logger.info("Hand on lab ended");
    ctx.close();
}

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   ww w  .  ja  v  a2  s . com
        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();
    }
}