Example usage for org.apache.commons.configuration HierarchicalINIConfiguration setFile

List of usage examples for org.apache.commons.configuration HierarchicalINIConfiguration setFile

Introduction

In this page you can find the example usage for org.apache.commons.configuration HierarchicalINIConfiguration setFile.

Prototype

public void setFile(File file) 

Source Link

Usage

From source file:sf.net.experimaestro.utils.XPMEnvironment.java

public static ServerTask prepare() throws Throwable {
    synchronized (token) {
        if (server == null) {
            LOGGER.info("Opening scheduler [%s]", Thread.currentThread());
            final File mainDirectory = getDirectory().getFile();

            final File dbFile = new File(mainDirectory, "db");
            dbFile.mkdir();/*from   www  . j a v a  2s .c  om*/

            server = new ServerTask();

            HierarchicalINIConfiguration serverConfiguration = new HierarchicalINIConfiguration();
            serverConfiguration.setProperty("server.database", dbFile.getAbsolutePath());
            serverConfiguration.setProperty("server.name", "test");
            serverConfiguration.setProperty("server.port", findFreeLocalPort());
            testPassword = RandomStringUtils.randomAlphanumeric(10);
            serverConfiguration.setDelimiterParsingDisabled(true);
            serverConfiguration.setProperty("passwords." + testUser, format("%s, user", testPassword));

            // Just to avoid reading the default configuration file
            serverConfiguration.setFile(mainDirectory);

            server.setConfiguration(serverConfiguration);

            server.wait(false); // No need to wait
            server.execute();

            Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                LOGGER.info("Stopping server");
                try {
                    server.close();
                } catch (Exception e) {
                    LOGGER.error(e, "Could not close the server");
                }
                LOGGER.info("Scheduler server");
            }));

        }
    }
    return server;
}