eu.forgetit.middleware.ConfigurationManager.java Source code

Java tutorial

Introduction

Here is the source code for eu.forgetit.middleware.ConfigurationManager.java

Source

/**
 * ConfigurationManager.java
 * Author: Francesco Gallo (gallo@eurix.it)
 * 
 * This file is part of ForgetIT Preserve-or-Forget (PoF) Middleware.
 * 
 * Copyright (C) 2013-2016 ForgetIT Consortium - www.forgetit-project.eu
 *  
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package eu.forgetit.middleware;

import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class ConfigurationManager {

    private static String PROPERTY_FILE = "config.properties";
    private static Configuration configuration = null;

    public static Configuration getConfiguration() {

        if (configuration == null) {

            try {
                configuration = new PropertiesConfiguration(PROPERTY_FILE);
            } catch (ConfigurationException e) {
                e.printStackTrace();
            }
        }

        return configuration;

    }

}