
ninja.utils.NinjaPropertiesImpl Maven / Gradle / Ivy
/**
* Copyright (C) the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ninja.utils;
import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Properties;
import org.apache.commons.configuration.CompositeConfiguration;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.inject.Binder;
import com.google.inject.Singleton;
import com.google.inject.name.Names;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.commons.configuration.SystemConfiguration;
@Singleton
public class NinjaPropertiesImpl implements NinjaProperties {
private static final Logger logger = LoggerFactory
.getLogger(NinjaPropertiesImpl.class);
private final NinjaMode ninjaMode;
private String contextPath = "";
private final String ERROR_KEY_NOT_FOUND = "Key %s does not exist. Please include it in your application.conf. Otherwise this app will not work";
/**
* This is the final configuration holding all information from
* 1. application.conf.
* 2. Special properties for the mode you are running on extracted
* from application.conf
* 3. An external configuration file defined
* by a system property and on the classpath.
*/
private CompositeConfiguration compositeConfiguration;
public static Builder builder() {
return new Builder();
}
public static class Builder {
private NinjaMode ninjaMode;
private Optional externalConfigurationOpt = Optional.empty();
private Optional
© 2015 - 2025 Weber Informatics LLC | Privacy Policy