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:cl.bbr.servicemix.ServiceMixEmbebbed.Main.java

/**
 * @param args// w w  w . j  a v a 2  s . com
 */
public static void main(String[] args) {
    // This is a very simple example of how you might embed ServiceMix
    try {
        final ApplicationContext context = new ClassPathXmlApplicationContext("context-jbi.xml");
        SpringJBIContainer container = (SpringJBIContainer) context.getBean("jbi");

        container.onShutDown(new Runnable() {
            public void run() {
                if (context instanceof DisposableBean) {
                    try {
                        ((DisposableBean) context).destroy();
                    } catch (Exception e) {
                        System.out.println("Caught: " + e);
                        e.printStackTrace();
                    }
                }
            }
        });
    } catch (Exception e) {
        System.out.println("Caught: " + e);
        e.printStackTrace();
    }

}

From source file:org.apache.vysper.spring.ServerMain.java

/**
 * boots the server as a standalone application according to the spring-config.xml file
 * found on the classpath/*from  ww w .  ja va  2 s  . c om*/
 * @param args
 */
public static void main(String[] args) {

    new ClassPathXmlApplicationContext("spring-config.xml");

    System.out.println("vysper server is running (using spring framework)...");
}

From source file:io.pivotal.fe.Main.java

/**
 * @param args/*from   w  w w  . ja va  2  s .  c o m*/
 * @throws CommandServiceException 
 */
public static void main(String[] args) throws CommandServiceException {
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/gemfire/cache-config.xml");

}

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

public static void main(String[] args) {
    try {//from w  w w . j  a v  a 2 s  .com
        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.btc4j.ws.BtcDaemonServiceMain.java

public static void main(String[] args) {
    try {/*from   w  w w. j a v a  2 s  . c  o m*/
        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:uk.co.onehp.trickle.routing.BetfairEngineRoutingCustomT.java

/**
 * @param args/*from  w  w  w  .  j a v a 2  s.  c om*/
 * @throws Exception 
 * @throws CamelExecutionException 
 */
public static void main(String[] args) throws CamelExecutionException, Exception {
    final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:/spring-trickle.xml");
    final BetfairService betfairService = (BetfairService) applicationContext.getBean("betfairService");
    betfairService.login();
    //      betfairService.getUkMarket();
    //      betfairService.getMeeting(26676407);
    //      betfairService.getRace(102267423);
    //      betfairService.getRacePrices(102267423);
}

From source file:com.gopivotal.training.LoadRegions.java

/**
 * @param args//  w w w  .  j  av a  2 s  . com
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/gemfire/cache-config.xml");
    ClientCache cache = context.getBean("clientCache", ClientCache.class);
    if (cache != null) {
        new LoadRegions(cache).populateGemFire();
    } else {
        System.out.println("Failed to initialize Client Cache");
    }
}

From source file:org.age.node.Bootstrapper.java

public static void main(final String... args) {

    DefaultNodeLifecycleService lifecycleService = null;
    try (final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("spring-node.xml")) {
        context.registerShutdownHook();/* ww  w .ja  v a2  s .  co  m*/
        lifecycleService = context.getBean(DefaultNodeLifecycleService.class);
        lifecycleService.awaitTermination();
    } finally {
        log.info("Finishing.");
        lifecycleService.awaitTermination();
    }
    log.info("Exiting.");
    System.exit(0);
}

From source file:com.igorbaiborodine.example.mybatis.MyBatisWithAnnotaionsExample.java

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

    ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/application-context.xml");
    CustomerService customerService = (CustomerService) ctx.getBean("customerService");

    Customer customer = customerService.findCustomer((short) 1);
    logger.info("Found " + customer);
}

From source file:com.amazonaws.services.simpleworkflow.flow.examples.deployment.DeploymentInitiator.java

/**
 * @param args//from  w  w  w. j av a 2  s. c om
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    URL pUrl = DeploymentHost.class
            .getResource("/com/amazonaws/services/simpleworkflow/flow/examples/log4j.properties");
    PropertyConfigurator.configure(pUrl);

    ApplicationContext appContext = new ClassPathXmlApplicationContext(
            "/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentInitiator-context.xml");

    DeploymentWorkflowClientExternalFactory workflowFactory = appContext.getBean("workflowFactory",
            DeploymentWorkflowClientExternalFactory.class);

    String applicationStackConfigFile = args[0];
    // Use applicationStackConfig as workflowId to prohibit running multiple deployments of the same stack in parallel
    String workflowId = new File(applicationStackConfigFile).getName();
    DeploymentWorkflowClientExternal worklfowClient = workflowFactory.getClient(workflowId);
    String template = loadFile(applicationStackConfigFile);
    worklfowClient.deploy(template);
    System.out.println("Initiated deployment from " + applicationStackConfigFile);
}