Example usage for org.apache.commons.configuration ConfigurationFactory ConfigurationFactory

List of usage examples for org.apache.commons.configuration ConfigurationFactory ConfigurationFactory

Introduction

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

Prototype

public ConfigurationFactory(String configurationFileName) 

Source Link

Document

Constructor with ConfigurationFile Name passed

Usage

From source file:net.rinslet.util.ConfigManager.java

/**
 * Loads the specific configuration file.
 * //from  w  ww  . ja  v a2  s .  c  o  m
 * @param configFileName the file name
 */
public void loadConfig(String configFileName) {
    try {
        ConfigurationFactory factory = new ConfigurationFactory(configFileName);
        config = factory.getConfiguration();
        if (log.isDebugEnabled()) {
            log.debug("Configuration loaded: " + configFileName);
        }

    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException("Configuration loading error: " + configFileName, ex);
    }
}

From source file:android.apn.androidpn.server.util.ConfigManager.java

/**
 * Loads the specific configuration file.
 * //from   w  w w  .  j  av  a2s.c  o  m
 * @param configFileName the file name
 */
public void loadConfig(String configFileName) {
    try {
        ConfigurationFactory factory = new ConfigurationFactory(configFileName);
        config = factory.getConfiguration();
        log.info("Configuration loaded: " + configFileName);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        throw new RuntimeException("Configuration loading error: " + configFileName, ex);
    }
}

From source file:eu.optimis.trustedinstance.DBStorage.java

private void init() {
    try {/*  w  w  w  .  j  a  va 2 s  . co m*/
        ConfigurationFactory factory = new ConfigurationFactory("config.xml");
        config = factory.getConfiguration();
    } catch (ConfigurationException ex) {
        ex.printStackTrace();
    }
}

From source file:muvis.Environment.java

private Environment() {

    //Loading the main configuration
    ConfigurationFactory factory = new ConfigurationFactory("config.xml");
    try {/*from   w  w  w . j a va2  s. c o  m*/
        configuration = factory.getConfiguration();
    } catch (ConfigurationException ex) {
        System.out.println("Couldn't not load the configuration file! Possible reason: " + ex.toString());
    }

    initializeDataFolders();

    //initialize all the elements in the workspace
    audioPlayer = new MuVisAudioPlayer();
    snippetManager = new AudioSnippetPlayerManager(audioPlayer);
    userPlaylist = new BasePlaylist();
    configFile = new Properties();
    viewManager = new ViewManager();
    desk = new DockingDesktop();
    ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
    scheduler.scheduleAtFixedRate(new MemoryCollector(), 300, 300, TimeUnit.SECONDS);

    nbtreesManager = new NBTreeManager();
    try {
        String dataFolder = configuration.getString("muvis.data_folder");
        String nbtreeMainFolder = configuration.getString("muvis.nbtree_folder");
        String nbtreeFullfolder = dataFolder + Util.getOSEscapeSequence() + nbtreeMainFolder
                + Util.getOSEscapeSequence();

        nbtreesManager.addNBTree(Elements.TRACKS_NBTREE, new NBTree(Elements.TRACKS_NBTREE, nbtreeFullfolder));
        nbtreesManager.addNBTree(Elements.ALBUMS_NBTREE, new NBTree(Elements.ALBUMS_NBTREE, nbtreeFullfolder));
        nbtreesManager.addNBTree(Elements.ARTISTS_NBTREE,
                new NBTree(Elements.ARTISTS_NBTREE, nbtreeFullfolder));
    } catch (NBTreeException ex) {
        ex.printStackTrace();
        System.out.println("An error occured when trying to initialize the nbtreemanager!");
    }

    initConfigFile();
}

From source file:nl.bsoft.network.Configuration.java

/**
 * (Re)loads the configuration.//from w  ww . j  a v a 2 s .  com
 * 
 * @throws DomainRuntimeException
 *             if configuration could not be (re)loaded
 */
public void reload() {
    if (configFile == null) {
        configFile = DEFAULT_CONFIG_FILE;
    }
    try {
        ConfigurationFactory factory = new ConfigurationFactory(configFile);
        config = factory.getConfiguration();
    } catch (ConfigurationException e) {
        throw new DomainRuntimeException("Error loading configuration", e);
    }
}

From source file:org.genemania.util.ApplicationConfig.java

protected ApplicationConfig() {
    try {/*from  www.  j av  a2s.  c  o  m*/
        ConfigurationFactory factory = new ConfigurationFactory(Constants.APP_CONFIG_FILENAME);
        config = factory.getConfiguration();
    } catch (ConfigurationException x) {
        log.error("Application configuration error.", x);
    }
}

From source file:org.xmlactions.action.config.PropertyContainer.java

/**
 * This makes it possible to add a new configuration using a spring bean
 * factory, the factory is not really a factory
 * //  www  .  j  a  v  a 2s .  co  m
 * @throws ConfigurationException
 */
public CompositeConfiguration addConfigurationFile(String configFile) throws ConfigurationException {

    URL url = PropertyContainer.class.getResource(configFile);
    Validate.notNull(url, "Missing configuration file [" + configFile + "]");
    ConfigurationFactory cf = new ConfigurationFactory(url.getFile());
    compositeConfiguration.addConfiguration(cf.getConfiguration());
    return compositeConfiguration;
}