20
20
import org .apache .commons .configuration .CompositeConfiguration ;
21
21
import org .apache .commons .configuration .Configuration ;
22
22
import org .apache .commons .configuration .ConfigurationException ;
23
+ import org .apache .commons .configuration .EnvironmentConfiguration ;
23
24
import org .apache .commons .configuration .PropertiesConfiguration ;
24
25
import org .slf4j .Logger ;
25
26
import org .slf4j .LoggerFactory ;
@@ -40,18 +41,18 @@ public class PalmettoConfiguration {
40
41
41
42
public static synchronized Configuration getInstance () {
42
43
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 ;
45
55
}
46
56
return instance ;
47
57
}
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
- }
57
58
}
0 commit comments