Commit b14cf407 authored by Matija Obreza's avatar Matija Obreza
Browse files

Read “config.file” from environment

parent 7c927885
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
package org.genesys2.spring.config; package org.genesys2.spring.config;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -33,9 +33,6 @@ import org.springframework.core.io.Resource; ...@@ -33,9 +33,6 @@ import org.springframework.core.io.Resource;
@Configuration @Configuration
public class SpringProperties { public class SpringProperties {
@Value("${config.file}")
private String extraConfigFile;
@Bean @Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
...@@ -51,9 +48,16 @@ public class SpringProperties { ...@@ -51,9 +48,16 @@ public class SpringProperties {
// Include genesys.properties // Include genesys.properties
locations.add(new ClassPathResource("genesys.properties")); locations.add(new ClassPathResource("genesys.properties"));
String extraConfigFile = System.getenv("config.file");
if (StringUtils.isNotBlank(extraConfigFile)) { if (StringUtils.isNotBlank(extraConfigFile)) {
System.err.println("Registering extra filesystem resource at " + extraConfigFile); File f = new File(extraConfigFile);
locations.add(new FileSystemResource(extraConfigFile)); if (f.exists() && f.canRead()) {
System.err.println("Including properties from config.file=" + extraConfigFile);
locations.add(new FileSystemResource(extraConfigFile));
} else {
System.err.println("Cannot read properties from config.file=" + extraConfigFile);
}
} }
propertyPlaceholderConfigurer.setLocations(locations.toArray(new Resource[] {})); propertyPlaceholderConfigurer.setLocations(locations.toArray(new Resource[] {}));
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
base.host=localhost base.host=localhost
base.hostname=${base.host}:8080 base.hostname=${base.host}:8080
base.url=http://${base.hostname} base.url=http://${base.hostname}
base.cookie-domain= base.cookie-domain=${base.host}
base.cookie-secure=false base.cookie-secure=false
base.cookie-http-only=true base.cookie-http-only=true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment