mirror of
https://github.com/apache/druid.git
synced 2025-02-10 12:05:00 +00:00
Properties module can now take multiple properties files
This commit is contained in:
parent
f7c4d6a24a
commit
8340a1b0a1
@ -85,6 +85,7 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -351,7 +352,7 @@ public class Initialization
|
|||||||
return Guice.createInjector(
|
return Guice.createInjector(
|
||||||
new DruidGuiceExtensions(),
|
new DruidGuiceExtensions(),
|
||||||
new JacksonModule(),
|
new JacksonModule(),
|
||||||
new PropertiesModule("runtime.properties"),
|
new PropertiesModule(Arrays.asList("global.runtime.properties", "runtime.properties")),
|
||||||
new ConfigModule(),
|
new ConfigModule(),
|
||||||
new Module()
|
new Module()
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,11 +42,11 @@ public class PropertiesModule implements Module
|
|||||||
{
|
{
|
||||||
private static final Logger log = new Logger(PropertiesModule.class);
|
private static final Logger log = new Logger(PropertiesModule.class);
|
||||||
|
|
||||||
private final String propertiesFile;
|
private final List<String> propertiesFiles;
|
||||||
|
|
||||||
public PropertiesModule(String propertiesFile)
|
public PropertiesModule(List<String> propertiesFiles)
|
||||||
{
|
{
|
||||||
this.propertiesFile = propertiesFile;
|
this.propertiesFiles = propertiesFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,6 +58,7 @@ public class PropertiesModule implements Module
|
|||||||
Properties props = new Properties(fileProps);
|
Properties props = new Properties(fileProps);
|
||||||
props.putAll(systemProps);
|
props.putAll(systemProps);
|
||||||
|
|
||||||
|
for (String propertiesFile : propertiesFiles) {
|
||||||
InputStream stream = ClassLoader.getSystemResourceAsStream(propertiesFile);
|
InputStream stream = ClassLoader.getSystemResourceAsStream(propertiesFile);
|
||||||
try {
|
try {
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
@ -82,6 +84,7 @@ public class PropertiesModule implements Module
|
|||||||
finally {
|
finally {
|
||||||
Closeables.closeQuietly(stream);
|
Closeables.closeQuietly(stream);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
binder.bind(Properties.class).toInstance(props);
|
binder.bind(Properties.class).toInstance(props);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user