Skip to content

Commit d8b9b54

Browse files
committed
Changed the server to prefer environmental variables. If they are not present, the values from the configuration file, which comes with the war file, will be used.
1 parent b9127a4 commit d8b9b54

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

palmetto/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<modelVersion>4.0.0</modelVersion>
1313
<groupId>org.aksw</groupId>
1414
<artifactId>palmetto</artifactId>
15-
<version>0.1.5-SNAPSHOT</version>
15+
<version>0.1.5</version>
1616
<name>Palmetto</name>
1717
<description>Palmetto is a quality measure tool for topics.</description>
1818
<packaging>jar</packaging>

webApp/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build:
55

66
Major=0
77
Minor=1
8-
Patch=4
8+
Patch=5
99

1010
dockerize:
1111
docker build -t dicegroup/palmetto-service:latest .

webApp/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<modelVersion>4.0.0</modelVersion>
2222
<groupId>org.aksw</groupId>
2323
<artifactId>palmetto-webapp</artifactId>
24-
<version>0.1.5-SNAPSHOT</version>
24+
<version>0.1.5</version>
2525
<name>Palmetto Web Application</name>
2626
<description>Palmetto is a quality measure tool for topics.</description>
2727
<packaging>war</packaging>

webApp/src/main/java/org/aksw/palmetto/webapp/config/PalmettoConfiguration.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.commons.configuration.CompositeConfiguration;
2121
import org.apache.commons.configuration.Configuration;
2222
import org.apache.commons.configuration.ConfigurationException;
23+
import org.apache.commons.configuration.EnvironmentConfiguration;
2324
import org.apache.commons.configuration.PropertiesConfiguration;
2425
import org.slf4j.Logger;
2526
import org.slf4j.LoggerFactory;
@@ -40,18 +41,18 @@ public class PalmettoConfiguration {
4041

4142
public static synchronized Configuration getInstance() {
4243
if (instance == null) {
43-
instance = new CompositeConfiguration();
44-
loadAdditionalProperties(DEFAULT_PALMETTO_PROPERTIES_FILE_NAME);
44+
CompositeConfiguration tempConfig = new CompositeConfiguration();
45+
// Add environmental variables first
46+
tempConfig.addConfiguration(new EnvironmentConfiguration());
47+
// Add default values for parameters to ensure that all parameters are set
48+
try {
49+
tempConfig.addConfiguration(new PropertiesConfiguration(DEFAULT_PALMETTO_PROPERTIES_FILE_NAME));
50+
} catch (ConfigurationException e) {
51+
LOGGER.error("Couldnt load Properties from the properties file (\"" + DEFAULT_PALMETTO_PROPERTIES_FILE_NAME
52+
+ "\"). This GERBIL instance won't work as expected.", e);
53+
}
54+
instance = tempConfig;
4555
}
4656
return instance;
4757
}
48-
49-
public static synchronized void loadAdditionalProperties(String fileName) {
50-
try {
51-
((CompositeConfiguration) getInstance()).addConfiguration(new PropertiesConfiguration(fileName));
52-
} catch (ConfigurationException e) {
53-
LOGGER.error("Couldnt load Properties from the properties file (\"" + fileName
54-
+ "\"). This GERBIL instance won't work as expected.", e);
55-
}
56-
}
5758
}

webApp/src/main/java/org/aksw/palmetto/webapp/config/RootConfig.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class RootConfig {
8383

8484
static @Bean public WindowSupportingAdapter createLuceneAdapter() throws Exception {
8585
Configuration config = PalmettoConfiguration.getInstance();
86-
String indexPath = PalmettoConfiguration.getInstance().getString(INDEX_PATH_PROPERTY_KEY);
86+
String indexPath = config.getString(INDEX_PATH_PROPERTY_KEY);
8787
if (indexPath == null) {
8888
String errormsg = "Couldn't load \"" + INDEX_PATH_PROPERTY_KEY + "\" from properties. Aborting.";
8989
LOGGER.error(errormsg);

0 commit comments

Comments
 (0)