#1343 - Update the #1283 ENH: Support simplified test configuration (with docker setup typically via application-test.yml)

This commit is contained in:
Rob Bygrave
2018-03-09 00:44:04 +13:00
parent 2042bdf29a
commit d0b24dc340
2 changed files with 17 additions and 9 deletions
@@ -6,10 +6,13 @@ package io.ebean.config;
public interface AutoConfigure {
/**
* Provide some configuration the ServerConfig prior to server creation.
* <p>
* Return true if the autoConfiguration applies to this ServerConfig.
* Perform configuration for the ServerConfig prior to properties load.
*/
void configure(ServerConfig serverConfig);
void preConfigure(ServerConfig serverConfig);
/**
* Provide some configuration the ServerConfig prior to server creation but after properties have been applied.
*/
void postConfigure(ServerConfig serverConfig);
}
@@ -2650,19 +2650,24 @@ public class ServerConfig {
* Load the settings from the given properties
*/
private void configureFromProperties() {
autoConfiguration();
PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties, classLoadConfig);
loadSettings(p);
List<AutoConfigure> autoConfigures = autoConfiguration();
loadSettings(new PropertiesWrapper("ebean", name, properties, classLoadConfig));
for (AutoConfigure autoConfigure : autoConfigures) {
autoConfigure.postConfigure(this);
}
}
/**
* Use a 'plugin' to provide automatic configuration. Intended for automatic testing
* configuration with Docker containers via ebean-test-config.
*/
private void autoConfiguration() {
private List<AutoConfigure> autoConfiguration() {
List<AutoConfigure> list = new ArrayList<>();
for (AutoConfigure autoConfigure : serviceLoad(AutoConfigure.class)) {
autoConfigure.configure(this);
autoConfigure.preConfigure(this);
list.add(autoConfigure);
}
return list;
}
/**