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

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

Introduction

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

Prototype

public FileSystemXmlApplicationContext(String... configLocations) throws BeansException 

Source Link

Document

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

Usage

From source file:com.enterpriseios.push.spring.Main.java

/**
 *
 * @param args//from  ww  w.  j  av a 2s.  c  om
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    final String config = args.length == 1 ? args[0] : "etc/spring/bean.xml";
    //        final String config = args.length == 1 ? args[0] : "jetty-push2/src/main/resources/etc/spring/bean.xml";
    final AbstractApplicationContext applicationContext = new FileSystemXmlApplicationContext(config);
    final ActiveSyncServer server = (ActiveSyncServer) applicationContext
            .getBean(args.length == 2 ? args[1] : "ActiveSyncServer");
    server.start();
}

From source file:org.dcache.xdr.SpringRunner.java

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        System.err.println("Usage: SpringRunner <config>");
        System.exit(1);//from  w ww .ja  v a2s.  com
    }

    try {
        ApplicationContext context = new FileSystemXmlApplicationContext(args[0]);
        OncRpcSvc service = (OncRpcSvc) context.getBean("oncrpcsvc");
        service.start();

        System.in.read();
    } catch (BeansException e) {
        System.err.println("Spring: " + e.getMessage());
        System.exit(1);
    }
}

From source file:com.dc.gameserver.launcher.java

public static void main(String[] args) {
    try {/*w  ww.j  a  v  a2s  . c  o m*/

        DOMConfigurator.configure(Config.DEFAULT_VALUE.FILE_PATH.LOG4J);

        System.setProperty("java.net.preferIPv4Stack", "true"); //Disable IPv6 in JVM
        /**?spring*/
        BeanFactory springContext = new FileSystemXmlApplicationContext(
                Config.DEFAULT_VALUE.FILE_PATH.SPRING_CONFIG_PATH);
        launcher gameServer = (launcher) springContext.getBean("gameServer");
        /**set  spring context**/
        ServerHandler.setSpringContext(springContext);

        /**???*/
        gameServer.serverService.IntiServer();

        gameServer.serverService.run();

    } catch (Exception e) {
        LOG.error("server start error", e);
    }

}

From source file:net.darkmist.alib.spring.Main.java

public static void main(String[] args) {
    FileSystemXmlApplicationContext ctx;
    Runnable mb;// w ww  .j a v  a  2s . c o m
    boolean doExit = false;
    int exitCode = 0;

    if (args.length < 1)
        usage();
    ctx = new FileSystemXmlApplicationContext(args[0]);
    mb = (Runnable) ctx.getBean(MAIN_BEAN);
    if (mb instanceof MainBean)
        ((MainBean) mb).setArgs(args, 1, args.length - 1);
    else if (args.length > 1)
        throw new IllegalArgumentException("main bean does not take arguments");
    mb.run();
    if (mb instanceof MainBean) {
        exitCode = ((MainBean) mb).getExitCode();
        doExit = true;
    }
    mb = null;
    ctx.close();
    if (doExit)
        System.exit(exitCode);
}

From source file:net.sourceforge.happybank.facade.BankTest.java

/**
 * Test method./*from  w w w.  j  a  v  a  2  s .c om*/
 * 
 * @param args command line arguments
 */
public static void main(final String[] args) {

    try {
        // get context and facade
        ApplicationContext ctx = new FileSystemXmlApplicationContext("build/applicationContext.xml");
        BankingFacade bank = (BankingFacade) ctx.getBean("bankManager");

        // get all customers
        List<Customer> customers = bank.getCustomers();
        Iterator<Customer> custIter = customers.iterator();
        Customer cust = null;
        while (custIter.hasNext()) {
            cust = custIter.next();
            String cid = cust.getId();
            Customer customer = bank.getCustomer(cid);
            System.out.println(customer.toString());

            // get customers accounts
            List<Account> accounts = bank.getAccounts(cid);
            Iterator<Account> accIter = accounts.iterator();
            Account acc = null;
            while (accIter.hasNext()) {
                acc = accIter.next();
                String aid = acc.getId();
                Account account = bank.getAccount(aid);
                System.out.println("\t> " + account.toString());

                // get account transactions
                List<TransRecord> transactions = bank.getTransactions(aid);
                Iterator<TransRecord> transIter = transactions.iterator();
                TransRecord tr = null;
                while (transIter.hasNext()) {
                    tr = transIter.next();
                    System.out.println("\t\t>" + tr.toString());
                }
            }
        }

        // test creation, deletion and withdrawal
        bank.addCustomer("999", "Mr", "First", "Last");
        bank.addAccount("999-99", "999", "Checking");
        bank.deposit("999-99", new BigDecimal(1000.0));
        bank.withdraw("999-99", new BigDecimal(500.0));
        bank.deleteAccount("999-99");
        bank.deleteCustomer("999");

    } catch (BankException ex) {
        ex.printStackTrace();
    }
}

From source file:org.openvpms.archetype.test.tools.TestReminderGenerator.java

/**
 * Main line.//  w ww. j  a  v  a2  s . c om
 *
 * @param args the command line arguments
 */
public static void main(String[] args) {
    String contextPath = "applicationContext.xml";
    if (!new File(contextPath).exists()) {
        new ClassPathXmlApplicationContext(contextPath);
    } else {
        new FileSystemXmlApplicationContext(contextPath);
    }

    Entity[] reminderTypes = new Entity[10];
    Entity documentTemplate = ReminderTestHelper.createDocumentTemplate();
    for (int i = 0; i < reminderTypes.length; ++i) {
        Entity reminderType = ReminderTestHelper.createReminderType();
        ReminderTestHelper.addTemplate(reminderType, documentTemplate, 0, 1, DateUnits.DAYS);
        reminderTypes[i] = reminderType;
    }

    Date date = DateRules.getTomorrow();
    for (int i = 0; i < 100; ++i) {
        Party customer = TestHelper.createCustomer();
        Party patient = TestHelper.createPatient(customer);
        for (Entity reminderType : reminderTypes) {
            ReminderTestHelper.createReminderWithDueDate(patient, reminderType, date);
        }
    }
}

From source file:com.cxf.sts.WSO2STSTest.java

public static void main(String[] args) throws ParserConfigurationException {
    System.out.println("base folder - " + new File("").getAbsolutePath());

    System.setProperty("javax.net.ssl.trustStore",
            "/home/kasun/wso2/products/420-packs/wso2is-4.6.0/repository/resources/security/client-truststore.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

    ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:wssec-sts-bean.xml");
    doSTS(ctx);//from  w  w w  .  ja  va  2 s  .  c  om
}

From source file:de.uniwue.dmir.heatmap.EntryPoint.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {

    String settingsFile;/*from w ww .j  av a2 s  .  c o  m*/
    if (args.length > 0 && args[0] != null) {
        settingsFile = args[0];
    } else {
        settingsFile = SETTINGS_FILE;
    }

    LOGGER.debug("Reading settings file: {}", settingsFile);

    FileSystemXmlApplicationContext appContext = new FileSystemXmlApplicationContext(settingsFile);

    IHeatmap heatmap = appContext.getBean(HEATMAP_BEAN, IHeatmap.class);

    ITileProcessor tileProcessor = appContext.getBean(WRITER_BEAN, ITileProcessor.class);

    heatmap.processTiles(tileProcessor);

    tileProcessor.close();
    appContext.close();
}

From source file:infrascructure.data.StandaloneLauncher.java

/**
 * @param args//ww w . j  av  a2s  .  c om
 */
public static void main(String[] args) {
    Trace.trace("starting ..");
    String appContextPath = null;
    if (args.length > 0) {
        appContextPath = args[0];
    }

    String testConfigPath = appContextPath == null ? "src/main/resources/localSampleContext.xml"
            : appContextPath;
    String fullPath = new File(testConfigPath).getAbsolutePath();

    Trace.trace("Configuration path: " + fullPath);

    FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(testConfigPath);
    StandaloneLauncher launcher = context.getBean(StandaloneLauncher.class);
    launcher.process();
}

From source file:com.jbrisbin.vcloud.cache.Bootstrap.java

public static void main(String[] args) {

    CommandLineParser parser = new BasicParser();
    CommandLine cmdLine = null;//from   w ww . j  a  va 2s.c o  m
    try {
        cmdLine = parser.parse(opts, args);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }

    String configFile = "/etc/cloud/async-cache.xml";
    if (null != cmdLine) {
        if (cmdLine.hasOption('c')) {
            configFile = cmdLine.getOptionValue('c');
        }
    }

    ApplicationContext context = new FileSystemXmlApplicationContext(configFile);
    RabbitMQAsyncCacheProvider cacheProvider = context.getBean(RabbitMQAsyncCacheProvider.class);
    while (cacheProvider.isActive()) {
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            log.error(e.getMessage(), e);
        }
    }

}