Skip to content

Commit 583017d

Browse files
authored
Merge branch 'master' into 1819-migrate-to-spring-boot-refactor-as-preparation
2 parents 4b95ba3 + 3ff3f14 commit 583017d

17 files changed

+50
-130
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ SteVe is designed to run standalone, a java servlet container / web server (e.g.
7272
7373
3. Configure SteVe **before** building:
7474
75-
The basic configuration is defined in [main.properties](src/main/resources/config/prod/main.properties):
76-
- You _must_ change [database configuration](src/main/resources/config/prod/main.properties#L9-L13)
77-
- You _must_ change [the host](src/main/resources/config/prod/main.properties#L22) to the correct IP address of your server
78-
- You _must_ change [web interface credentials](src/main/resources/config/prod/main.properties#L17-L18)
79-
- You _can_ access the application via HTTPS, by [enabling it and setting the keystore properties](src/main/resources/config/prod/main.properties#L32-L35)
75+
The basic configuration is defined in [application-prod.properties](src/main/resources/application-prod.properties):
76+
- You _must_ change [database configuration](src/main/resources/application-prod.properties)
77+
- You _must_ change [the host](src/main/resources/application-prod.properties) to the correct IP address of your server
78+
- You _must_ change [web interface credentials](src/main/resources/application-prod.properties)
79+
- You _can_ access the application via HTTPS, by [enabling it and setting the keystore properties](src/main/resources/application-prod.properties)
8080
8181
For advanced configuration please see the [Configuration wiki](https://github.com/steve-community/steve/wiki/Configuration)
8282
@@ -101,7 +101,7 @@ SteVe is designed to run standalone, a java servlet container / web server (e.g.
101101
If you prefer to build and start this project via docker (you can skip the steps 1, 4 and 5 from above), this can be done as follows: `docker compose up -d`
102102
103103
Because the docker compose file is written to build the project for you, you still have to change the project configuration settings from step 3.
104-
Instead of changing the [main.properties in the prod directory](src/main/resources/config/prod/main.properties), you have to change the [main.properties in the docker directory](src/main/resources/config/docker/main.properties). There you have to change all configurations which are described in step 3.
104+
Instead of changing the [application-prod.properties](src/main/resources/application-prod.properties), you have to change the [application-docker.properties](src/main/resources/application-docker.properties). There you have to change all configurations which are described in step 3.
105105
The database password for the user "steve" has to be the same as you have configured it in the docker compose file.
106106
107107
With the default docker compose configuration, the web interface will be accessible at: `http://localhost:8180`

pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,12 @@
9696
<finalName>${project.artifactId}</finalName>
9797
<resources>
9898
<resource>
99-
<directory>src/main/resources/config/${envName}</directory>
99+
<directory>src/main/resources</directory>
100100
<filtering>true</filtering>
101+
<includes>
102+
<include>application**.properties</include>
103+
<include>logback-spring**.xml</include>
104+
</includes>
101105
</resource>
102106
<resource>
103107
<directory>src/main/resources</directory>
@@ -266,7 +270,8 @@
266270
</goals>
267271
<configuration>
268272
<files>
269-
<file>src/main/resources/config/${envName}/main.properties</file>
273+
<file>src/main/resources/application.properties</file>
274+
<file>src/main/resources/application-${envName}.properties</file>
270275
</files>
271276
</configuration>
272277
</execution>

src/main/java/de/rwth/idsg/steve/ApplicationProfile.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
*/
2525
public enum ApplicationProfile {
2626
DEV,
27-
TEST,
28-
PROD;
27+
DOCKER,
28+
KUBERNETES,
29+
PROD,
30+
TEST;
2931

3032
public static ApplicationProfile fromName(String v) {
3133
for (ApplicationProfile ap : ApplicationProfile.values()) {
@@ -35,8 +37,4 @@ public static ApplicationProfile fromName(String v) {
3537
}
3638
throw new IllegalArgumentException(v);
3739
}
38-
39-
public boolean isProd() {
40-
return this == PROD;
41-
}
4240
}

src/main/java/de/rwth/idsg/steve/SteveConfiguration.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public enum SteveConfiguration {
4848
private final String timeZoneId = "UTC"; // or ZoneId.systemDefault().getId();
4949

5050
// -------------------------------------------------------------------------
51-
// main.properties
51+
// application.properties
5252
// -------------------------------------------------------------------------
5353

5454
private final String contextPath;
@@ -62,7 +62,10 @@ public enum SteveConfiguration {
6262
private final Jetty jetty;
6363

6464
SteveConfiguration() {
65-
PropertiesFileLoader p = new PropertiesFileLoader("main.properties");
65+
// Load the profile in order to load the correct application-<profile>.properties file
66+
String profileTemp = new PropertiesFileLoader("application.properties").getString("profile");
67+
68+
PropertiesFileLoader p = new PropertiesFileLoader("application-" + profileTemp.toLowerCase() + ".properties");
6669

6770
contextPath = sanitizeContextPath(p.getOptionalString("context.path"));
6871
steveVersion = p.getString("steve.version");

src/main/java/de/rwth/idsg/steve/utils/PropertiesFileLoader.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818
*/
1919
package de.rwth.idsg.steve.utils;
2020

21-
import com.google.common.base.Splitter;
2221
import com.google.common.base.Strings;
2322
import lombok.extern.slf4j.Slf4j;
2423

2524
import java.io.FileInputStream;
2625
import java.io.FileNotFoundException;
2726
import java.io.IOException;
2827
import java.io.InputStream;
29-
import java.util.Collections;
30-
import java.util.List;
3128
import java.util.Properties;
3229

3330
/**
@@ -96,18 +93,6 @@ public String getOptionalString(String key) {
9693
return trim(key, s);
9794
}
9895

99-
public List<String> getStringList(String key) {
100-
String s = prop.getProperty(key);
101-
if (Strings.isNullOrEmpty(s)) {
102-
return Collections.emptyList();
103-
}
104-
s = resolveIfSystemEnv(s);
105-
return Splitter.on(",")
106-
.trimResults()
107-
.omitEmptyStrings()
108-
.splitToList(s);
109-
}
110-
11196
public boolean getOptionalBoolean(String key) {
11297
String s = getOptionalString(key);
11398
if (s == null) {
@@ -119,15 +104,6 @@ public boolean getOptionalBoolean(String key) {
119104
}
120105
}
121106

122-
public Integer getOptionalInt(String key) {
123-
String s = getOptionalString(key);
124-
if (s == null) {
125-
return null;
126-
} else {
127-
return Integer.parseInt(s);
128-
}
129-
}
130-
131107
// -------------------------------------------------------------------------
132108
// Private helpers
133109
// -------------------------------------------------------------------------

src/main/resources/config/dev/main.properties renamed to src/main/resources/application-dev.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ws.session.select.strategy = ALWAYS_LAST
5252
# stations into database and accept their requests.
5353
#
5454
# CAUTION: setting this property to true is very dangerous, because we will accept EVERY BootNotification or WebSocket
55-
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
55+
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
5656
#
5757
auto.register.unknown.stations = false
5858

src/main/resources/config/docker/main.properties renamed to src/main/resources/application-docker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ws.session.select.strategy = ALWAYS_LAST
5252
# stations into database and accept their requests.
5353
#
5454
# CAUTION: setting this property to true is very dangerous, because we will accept EVERY BootNotification or WebSocket
55-
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
55+
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
5656
#
5757
auto.register.unknown.stations = false
5858

src/main/resources/config/kubernetes/main.properties renamed to src/main/resources/application-kubernetes.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ws.session.select.strategy = ALWAYS_LAST
5252
# stations into database and accept their requests.
5353
#
5454
# CAUTION: setting this property to true is very dangerous, because we will accept EVERY BootNotification or WebSocket
55-
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
55+
# connection attempt from ANY sender as long as the sender knows the URL and sends a valid message.
5656
#
5757
auto.register.unknown.stations = false
5858

0 commit comments

Comments
 (0)