mirror of
https://github.com/lightbend/config.git
synced 2025-02-24 02:00:46 +08:00
get rid of ConfigConfig, wasn't the right API.
Will replace it with something better later.
This commit is contained in:
parent
31a8e9ee57
commit
f1bedacdfc
@ -9,16 +9,6 @@ import com.typesafe.config.impl.ConfigUtil;
|
|||||||
* This class holds some global static methods for the config package.
|
* This class holds some global static methods for the config package.
|
||||||
*/
|
*/
|
||||||
public final class Config {
|
public final class Config {
|
||||||
/**
|
|
||||||
* Loads a configuration object.
|
|
||||||
*
|
|
||||||
* @param configConfig
|
|
||||||
* configuration for the configuration.
|
|
||||||
* @return a configuration object
|
|
||||||
*/
|
|
||||||
public static ConfigRoot load(ConfigConfig configConfig) {
|
|
||||||
return ConfigImpl.loadConfig(configConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a configuration for the given root path. The root path should be a
|
* Loads a configuration for the given root path. The root path should be a
|
||||||
@ -37,7 +27,7 @@ public final class Config {
|
|||||||
* @return configuration object for the requested root path
|
* @return configuration object for the requested root path
|
||||||
*/
|
*/
|
||||||
public static ConfigRoot load(String rootPath) {
|
public static ConfigRoot load(String rootPath) {
|
||||||
return ConfigImpl.loadConfig(new ConfigConfig(rootPath));
|
return ConfigImpl.loadConfig(rootPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getUnits(String s) {
|
private static String getUnits(String s) {
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package com.typesafe.config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Configuration for a configuration!
|
|
||||||
*/
|
|
||||||
public final class ConfigConfig {
|
|
||||||
|
|
||||||
final private String rootPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new configuration configuration.
|
|
||||||
*
|
|
||||||
* @param rootPath
|
|
||||||
* the root path as described in Config.load() docs
|
|
||||||
*/
|
|
||||||
public ConfigConfig(String rootPath) {
|
|
||||||
this.rootPath = rootPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the configured root path. This method would be used by code
|
|
||||||
* implementing a configuration backend; don't worry about it.
|
|
||||||
*
|
|
||||||
* @return the root path
|
|
||||||
*/
|
|
||||||
public String rootPath() {
|
|
||||||
return rootPath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,20 +5,18 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.typesafe.config.ConfigConfig;
|
|
||||||
import com.typesafe.config.ConfigException;
|
import com.typesafe.config.ConfigException;
|
||||||
import com.typesafe.config.ConfigObject;
|
import com.typesafe.config.ConfigObject;
|
||||||
import com.typesafe.config.ConfigRoot;
|
import com.typesafe.config.ConfigRoot;
|
||||||
|
|
||||||
/** This is public but is only supposed to be used by the "config" package */
|
/** This is public but is only supposed to be used by the "config" package */
|
||||||
public class ConfigImpl {
|
public class ConfigImpl {
|
||||||
public static ConfigRoot loadConfig(ConfigConfig configConfig) {
|
public static ConfigRoot loadConfig(String rootPath) {
|
||||||
ConfigTransformer transformer = withExtraTransformer(null);
|
ConfigTransformer transformer = withExtraTransformer(null);
|
||||||
|
|
||||||
AbstractConfigObject system = null;
|
AbstractConfigObject system = null;
|
||||||
try {
|
try {
|
||||||
system = systemPropertiesConfig()
|
system = systemPropertiesConfig().getObject(rootPath);
|
||||||
.getObject(configConfig.rootPath());
|
|
||||||
} catch (ConfigException e) {
|
} catch (ConfigException e) {
|
||||||
// no system props in the requested root path
|
// no system props in the requested root path
|
||||||
}
|
}
|
||||||
@ -32,7 +30,7 @@ public class ConfigImpl {
|
|||||||
// object that the app might be able to pass in.
|
// object that the app might be able to pass in.
|
||||||
IncludeHandler includer = defaultIncluder();
|
IncludeHandler includer = defaultIncluder();
|
||||||
|
|
||||||
stack.add(includer.include(configConfig.rootPath()).transformed(
|
stack.add(includer.include(rootPath).transformed(
|
||||||
transformer));
|
transformer));
|
||||||
|
|
||||||
AbstractConfigObject merged = AbstractConfigObject.merge(stack);
|
AbstractConfigObject merged = AbstractConfigObject.merge(stack);
|
||||||
|
@ -8,7 +8,6 @@ import com.typesafe.config.ConfigObject
|
|||||||
import com.typesafe.config.ConfigException
|
import com.typesafe.config.ConfigException
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import com.typesafe.config.ConfigConfig
|
|
||||||
|
|
||||||
class ConfigTest extends TestUtils {
|
class ConfigTest extends TestUtils {
|
||||||
|
|
||||||
@ -620,11 +619,6 @@ class ConfigTest extends TestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
def test01LoadWithConfigConfig() {
|
|
||||||
val conf = Config.load(new ConfigConfig("test01"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def test02SubstitutionsWithWeirdPaths() {
|
def test02SubstitutionsWithWeirdPaths() {
|
||||||
val conf = Config.load("test02")
|
val conf = Config.load("test02")
|
||||||
|
Loading…
Reference in New Issue
Block a user