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:mjg.spring.Demo.java

public static void main(String[] args) {
    ApplicationContext ctx = new FileSystemXmlApplicationContext("resources/applicationContext.xml");
    Evaluator e = null;/* w w  w . j  a  va2  s.  com*/
    boolean ok;

    for (int i = 0; i < 10; i++) {
        e = (Evaluator) ctx.getBean("groovyEvaluator");
        ok = e.approve(null);
        System.out.println(ok ? "approved" : "denied");

        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        }
    }

    ((FileSystemXmlApplicationContext) ctx).close();
}

From source file:com.netpet.spools.spring.springtest.testQuickStart.java

/**
 * The special way (DI in Spring) for reading from config file.
 * @param args//from  w  w w. j a  v a 2s.  c  o m
 * Testing by Using Spring!
 */
public static void main(String[] args) {
    ApplicationContext ctx = new FileSystemXmlApplicationContext("springTest/bean.xml");
    Action action = (Action) ctx.getBean("theAction");
    Action secondAction = (Action) ctx.getBean("secondAction");

    int i = 0;
    System.out.println(action.execute("Trigger Jonathan:") + i++);
    System.out.println(secondAction.execute("bootstrap:") + i++);

    for (i = 0; i < 10; i++) {
        if (i == 6) {
            continue;
        }
        System.out.println(i);
    }
}

From source file:bit.crawl.bloomfilter.BloomfilterRunnerMain.java

public static void main(String[] argv) {

    String taskFileName = "/home/sliver/workspace2/CrawlerEngine/real-world-tasks/bloomFilter-config.spring.xml";

    ApplicationContext context = new FileSystemXmlApplicationContext("file:" + taskFileName);
    BloomFilterInit bloomFilterInit = context.getBean("bloomFilterInit", BloomFilterInit.class);

    bloomFilterInit.init();//from  w  w  w  . j  a  v a2 s.c  om
}

From source file:nl.knaw.dans.common.lang.log.RL_MAIN.java

/**
 * @param args//from ww  w. j av a  2 s  .co  m
 * @throws ConfigurationException 
 */
public static void main(String[] args) throws ConfigurationException {
    ApplicationContext context = new FileSystemXmlApplicationContext(
            "src/test/resources/test-files/log/test-log-context.xml");

    //RL rl = RL.initialize("/home/easy/batch/reports/test2/app/enz", true);
    //rl.setReporter((Reporter) context.getBean("reporter"));

    //        RL rl = RL.initialize("/home/easy/batch/reports/test2/app/enz", true);
    //        RLTestReporter testReporter = new RLTestReporter();
    //        testReporter.addReport(new OverviewReport("test-overview.csv"));
    //        rl.setReporter(testReporter);

    RL.info(new Event("main", "message2"));

}

From source file:com.netpet.spools.javacore.study.proxy.springcase.testProxyClient.java

/**
 * Use the Spring for calling the Proxy Class.
 *
 * @param args//from   www .j av a  2  s . com
 */
public static void main(String[] args) {
    //SpringDIBean
    ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml");
    System.out.println(Subject.class.getCanonicalName());
    Subject sub = (Subject) ctx.getBean(Subject.class.getCanonicalName());

    MyHandler handler1 = new MyHandler();
    MyHandler handler2 = new MyHandler();

    handler1.SetSub(sub); //?

    Subject proxySub1 = (Subject) Proxy.newProxyInstance(RealSubject.class.getClassLoader(),
            RealSubject.class.getInterfaces(), handler1);
    Subject proxySub2 = (Subject) Proxy.newProxyInstance(RealSubject.class.getClassLoader(),
            RealSubject.class.getInterfaces(), handler2);

    proxySub1.sailBook();

    proxySub2.sailBook();
}

From source file:org.cgiar.dapa.ccafs.tpe.geojson.MailTest.java

public static void main(String[] args) {
    // Create the application context
    ApplicationContext context = new FileSystemXmlApplicationContext("applicationContext.xml");

    // Get the mailer instance
    ITPEMailService mailer = (ITPEMailService) context.getBean("mailService");

    // Send a composed mail
    mailer.sendMail("ccafstpe@gmail.com", "Test Subject", "Testing body");

    // Send a pre-configured mail
    mailer.sendPreConfiguredMail("Exception occurred.");
}

From source file:org.copperengine.spring.SpringEngineStarter.java

/**
 * @param args//from  ww w  .  j a  v a 2  s. c  om
 */
public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("Usage: " + SpringEngineStarter.class.getName() + " <configLocations>");
        System.exit(-2);
    }
    try {
        new FileSystemXmlApplicationContext(args);
    } catch (Exception e) {
        logger.error("Startup failed", e);
        System.exit(-1);
    }
}

From source file:com.illmeyer.polygraph.dist.simple.Polygraph.java

/**
 * @param args/*from w  w w . j  av a2s . co m*/
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    ApplicationContext context = new FileSystemXmlApplicationContext(args[1]);
    DefaultGunConfigurator gc = new DefaultGunConfigurator();
    gc.setActiveTemplate(args[0]);
    gc.initialize();
    Gun g = (Gun) context.getBean("gun");
    g.setConfigurator(gc);
    g.initialize();
    g.trigger();
    g.destroy();
}

From source file:org.apache.niolex.config.main.ConfigServerMain.java

public static void main(String[] args) throws Exception {
    ApplicationContext ctx = new FileSystemXmlApplicationContext("conf/spring.xml");
    ConfigServer cServer = ctx.getBean(ConfigServer.class);
    if (!cServer.start()) {
        System.out.println("Failed to start Config Server, system will exit...");
        System.exit(-1);//from w w  w . j av a2  s. co m
    }
    ConnectionWorker.setAuthInfo("d178b4c149");
    BeanServer beanS = new BeanServer();
    beanS.putIfAbsent("os", new OSInfo());
    beanS.putIfAbsent("conf", ctx.getBean(MemoryStorage.class));
    beanS.putIfAbsent("dispatch", ctx.getBean(ConfigEventDispatcher.class));
    beanS.putIfAbsent("server", cServer);
    if (!beanS.start()) {
        System.out.println("Failed to start Bean Server, system will exit...");
        System.exit(-1);
    }
}

From source file:com.villemos.ispace.Starter.java

public static void main(String[] args) {

    System.out.println("Starting iSpace.");

    try {//from   w ww .  j a  v a2 s.c o  m
        /** Read the configuration file as the first argument. If not set, then we try the default name. */
        String assemblyFile = System.getProperty("ispace.assembly") == null ? "assembly.xml"
                : System.getProperty("ispace.assembly");

        System.out.println("Using assembly file " + assemblyFile);

        new FileSystemXmlApplicationContext(assemblyFile);

        while (true) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}