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:de.uzk.hki.da.action.ActionInformationTests.java

/**
 * Sets the up.//from w ww.j  a  v a2s.com
 * @throws IOException 
 */
@Before
public void setUp() throws IOException {
    FileUtils.copyFile(new File("src/main/conf/config.properties.dev"), new File("conf/config.properties"));

    context = new FileSystemXmlApplicationContext(
            "src/test/resources/core/ActionInformationTests/action-definitions.xml");
    ;
    info = (ActionInformation) context.getBean("actionInformation");
}

From source file:de.langmi.spring.batch.tutorials.helloworld.HelloWorldJobConfigurationManualTest.java

@Test
public void testLaunch() throws Exception {
    // load ApplicationContext
    ApplicationContext context = new FileSystemXmlApplicationContext(
            "src/main/resources/spring/batch/job/hello-world-job.xml");
    // get job/*from w  w w .j a  va  2s  .  co  m*/
    Job job = context.getBean(Job.class);
    // get job launcher
    JobLauncher jobLauncher = context.getBean(JobLauncher.class);
    // start job
    JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
    // assertion
    assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
    // assert sysoutput        
    assertEquals("Hello World!", outContent.toString());
}

From source file:de.uzk.hki.da.at.AcceptanceTest.java

/**
 * @param gridImplBeanName bean name //from w w  w.j  a va 2  s  . c om
 * @param dcaImplBeanName distributed conversion adapter beanName
 * @return
 */

private static void instantiateGrid(Properties properties) {

    String gridImplBeanName = properties.getProperty("cb.implementation.grid");
    String dcaImplBeanName = properties.getProperty("cb.implementation.distributedConversion");

    if (gridImplBeanName == null)
        gridImplBeanName = "fakeGridFacade";
    if (dcaImplBeanName == null)
        dcaImplBeanName = "fakeDistributedConversionAdapter";

    AbstractApplicationContext context = new FileSystemXmlApplicationContext("conf/beans.xml");

    gridFacade = (GridFacade) context.getBean(gridImplBeanName);
    distributedConversionAdapter = (DistributedConversionAdapter) context.getBean(dcaImplBeanName);
    context.close();
}

From source file:com.opensymphony.able.jpa.SpringTestSupport.java

protected AbstractXmlApplicationContext loadContext(String relativeOrAbsoluteClassPathUri) {
    URL url = getClass().getResource(relativeOrAbsoluteClassPathUri);
    if (url == null) {
        // lets try an absolute classpath URI
        url = getClass().getClassLoader().getResource(relativeOrAbsoluteClassPathUri);
    }/*  w  w  w  .  j av  a 2  s .c  o  m*/
    Assert.assertNotNull(url, "Failed to load relativeClassPathUri: " + relativeOrAbsoluteClassPathUri);
    return new FileSystemXmlApplicationContext(url.toString());

}

From source file:com.jgui.ttscrape.Bootstrap.java

public void run() {
    if (logger.isTraceEnabled()) {
        logger.trace("initializing container");
    }/*from   ww  w. j  av  a 2  s .  c om*/

    URL url = Bootstrap.class.getResource("/applicationContext.xml");
    ApplicationContext ctx = new FileSystemXmlApplicationContext(url.toExternalForm());
    FetchController c = ctx.getBean(FetchController.class);
    if (c != null) {
        //c.setWriteShows(true);
        //c.setWriteContent(true);
        if (c.getFetcher().init()) {
            if (readMode) {
                c.read();
            } else if (fetchMode) {
                c.fetch();
            }
        }
    } else {
        logger.error("unable to find fetch controller");
    }
}

From source file:egovframework.rte.fdl.crypto.EgovPasswordLoad.java

/**
 * EgovPasswordLoad Class ??//  w ww. j  a v  a 2s .c o  m
 */
public EgovPasswordLoad() {
    passwordEncryptor = new ConfigurablePasswordEncryptor();
    context = new FileSystemXmlApplicationContext(default_path);
    cryptoConfig = (CryptoConfig) context.getBean("config");
    String pwdAlgorithm = cryptoConfig.getPasswordAlgorithm();
    if (pwdAlgorithm.trim().length() <= 0)
        passwordEncryptor.setAlgorithm("SHA-1");
    else
        passwordEncryptor.setAlgorithm(pwdAlgorithm);
    passwordEncryptor.setPlainDigest(true);
}

From source file:org.activiti.crystalball.anttasks.RunSimulationTask.java

public void execute() {

    log("Starting simulation run [" + simRunBean + "] from application context [" + appContext + "].");

    // seting app context
    if (appContext == null) {
        throw new BuildException("No application context set.");
    }/*  ww  w  .  j a va  2 s.  c o m*/
    FileSystemXmlApplicationContext applicationContext = new FileSystemXmlApplicationContext(appContext);

    try {
        // getting simulation run
        SimulationRun simRun = null;
        if (simRunBean != null)
            simRun = (SimulationRun) applicationContext.getBean(simRunBean);
        if (simRun == null) {
            log("Using default simulation run bean", Project.MSG_WARN);
            simRun = applicationContext.getBean(SimulationRun.class);
        }
        if (simRun == null) {
            throw new BuildException("unable to get sim run bean");
        }

        //
        // execute simulation run
        //
        simRun.execute(getStartDate(), getEndDate());
    } catch (ParseException e) {
        log("Simulation task exception - parsing dates", Project.MSG_ERR);
        throw new BuildException(e);
    } catch (Exception e) {
        log("Simulation task exception - simulation run error", Project.MSG_ERR);
        throw new BuildException(e);
    } finally {
        applicationContext.close();
    }

    log("Simulation run [" + simRunBean + "] from application context [" + appContext + "] done.");

}

From source file:org.jbpm.formbuilder.server.RESTIoServiceTest.java

public void testSetContextOK() throws Exception {
    RESTIoService restService = new RESTIoService();
    URL pathToClasses = getClass().getResource("/FormBuilder.properties");
    String filePath = pathToClasses.toExternalForm();
    //assumes compilation is in target/classes
    filePath = filePath.replace("target/classes/FormBuilder.properties", "src/main/webapp");
    filePath = filePath + "/WEB-INF/springComponents.xml";
    FileSystemXmlApplicationContext ctx = new FileSystemXmlApplicationContext(filePath);
    ServiceFactory.getInstance().setBeanFactory(ctx);
    ServletContext context = EasyMock.createMock(ServletContext.class);

    EasyMock.replay(context);/*from w w  w .j a v  a  2 s .  com*/
    restService.setContext(context);
    EasyMock.verify(context);

    TaskDefinitionService service = restService.getTaskService();
    assertNotNull("service shouldn't be null", service);
}

From source file:test.net.sourceforge.happybank.model.TestBank.java

/**
 * Add some new accounts and customers./* ww  w  .  jav  a 2  s.c  o  m*/
 */
protected final void setUp() {
    // get context and facade
    ApplicationContext ctx = new FileSystemXmlApplicationContext("build/applicationContext.xml");
    bank = (BankingFacade) ctx.getBean("bankManager");

    // create test accounts and customers
    try {
        bank.addCustomer("120", "Mr", "A", "Customer");
        bank.addCustomer("130", "Mr", "Ano", "Customer");
        bank.addAccount("120-2001", "120", "Checking");
        bank.addAccount("120-2002", "120", "Savings");
        bank.addAccount("120-2010", "130", "Checking");
        bank.addAccount("120-2011", "130", "Savings");
        bank.addAccount("120-2012", "130", "Savings");
        bank.deposit("120-2002", new BigDecimal("100.00"));
        delay(5);
        bank.deposit("120-2002", new BigDecimal("50.00"));
        delay(5);
        bank.deposit("120-2010", new BigDecimal("1000.45"));
        delay(5);
        bank.deposit("120-2011", new BigDecimal("123.69"));
    } catch (BankException ex) {
        ex.printStackTrace();
    }
}

From source file:egovframework.rte.fdl.crypto.ConfigInfo.java

/**
 * Context Component  /*  w ww.j av  a2s.  com*/
 * @param fileName -   ? 
 */
public void setUp(String fileName) {
    if (fileName == null)
        context = new FileSystemXmlApplicationContext(default_path);
    else
        context = new FileSystemXmlApplicationContext(fileName);

    cryptoConfig = (CryptoConfig) context.getBean("config");
}