/** * Load system configuration, using the supplied configLocation as base. The config location is converted * into an URI first. */ public static Config getConfig(@Nonnull final String configLocation, @Nullable final String configName) { final ConfigFactory configFactory = new ConfigFactory(URI.create(configLocation), configName); return new Config(configFactory.load()); }
/** * Load Configuration, using the supplied URI as base. The loaded configuration can be overridden using * system properties. */ public static Config getConfig(@Nonnull final URI configLocation, @Nullable final String configName) { final ConfigFactory configFactory = new ConfigFactory(configLocation, configName); return new Config(configFactory.load()); }
/** * Loads the configuration. The no-args method uses system properties to determine which configurations * to load. * * -Dness.config=x/y/z defines a hierarchy of configurations from general * to detail. * * The ness.config.location variable must be set. * If the ness.config variable is unset, the default value "default" is used. * * @throws IllegalStateException If the ness.config.location variable is not set. */ public static Config getConfig() { final Configuration systemConfig = new SystemConfiguration(); final String configName = systemConfig.getString(CONFIG_PROPERTY_NAME); final String configLocation = systemConfig.getString(CONFIG_LOCATION_PROPERTY_NAME); Preconditions.checkState(configLocation != null, "Config location must be set!"); final ConfigFactory configFactory = new ConfigFactory(URI.create(configLocation), configName); return new Config(configFactory.load()); }