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

Read “config.file” from environment

parent 7c927885
......@@ -16,13 +16,13 @@
package org.genesys2.spring.config;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -33,9 +33,6 @@ import org.springframework.core.io.Resource;
@Configuration
public class SpringProperties {
@Value("${config.file}")
private String extraConfigFile;
@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
......@@ -51,9 +48,16 @@ public class SpringProperties {
// Include genesys.properties
locations.add(new ClassPathResource("genesys.properties"));
String extraConfigFile = System.getenv("config.file");
if (StringUtils.isNotBlank(extraConfigFile)) {
System.err.println("Registering extra filesystem resource at " + extraConfigFile);
locations.add(new FileSystemResource(extraConfigFile));
File f = new File(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[] {}));
......
......@@ -17,7 +17,7 @@
base.host=localhost
base.hostname=${base.host}:8080
base.url=http://${base.hostname}
base.cookie-domain=
base.cookie-domain=${base.host}
base.cookie-secure=false
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