mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1283 - ENH: Support simplified test configuration (with docker setup typically via application-test.yml)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package io.ebean.config;
|
||||
|
||||
/**
|
||||
* Used to provide some automatic configuration early in the creation of an EbeanServer.
|
||||
*/
|
||||
public interface AutoConfigure {
|
||||
|
||||
/**
|
||||
* Provide some configuration the ServerConfig prior to server creation.
|
||||
* <p>
|
||||
* Return true if the autoConfiguration applies to this ServerConfig.
|
||||
*/
|
||||
void configure(ServerConfig serverConfig);
|
||||
|
||||
}
|
||||
@@ -2606,10 +2606,22 @@ public class ServerConfig {
|
||||
public void loadFromProperties(Properties properties) {
|
||||
// keep the properties used for configuration so that these are available for plugins
|
||||
this.properties = properties;
|
||||
autoConfiguration();
|
||||
PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties);
|
||||
loadSettings(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a 'plugin' to provide automatic configuration. Intended for automatic testing
|
||||
* configuration with Docker containers via ebean-test-config.
|
||||
*/
|
||||
private void autoConfiguration() {
|
||||
Iterator<AutoConfigure> iterator = serviceLoad(AutoConfigure.class).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next().configure(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated - this does nothing now, we always try to read test configuration.
|
||||
* <p>
|
||||
|
||||
@@ -55,4 +55,15 @@ public class PropertiesLoader {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set (override) a configuration property.
|
||||
*
|
||||
* This is expected to be only called by test configuration logic
|
||||
* (ala automatic test configuration via ebean-test-config).
|
||||
*/
|
||||
public static synchronized void setProperty(String key, String value) {
|
||||
load();
|
||||
properties.setProperty(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user