From 1437843f0863ce41f5b0a2e5a34431000d970f1d Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Fri, 21 Aug 2015 16:05:09 +1200 Subject: [PATCH] #393 - ENH: Add ServerConfig.getProperties() ... serverConfig remembers the properties that were used in configuration in order to make these available to plugins --- .../java/com/avaje/ebean/config/ServerConfig.java | 13 +++++++++++++ .../com/avaje/ebean/config/ServerConfigTest.java | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/com/avaje/ebean/config/ServerConfig.java b/src/main/java/com/avaje/ebean/config/ServerConfig.java index d93f52b36..5dd492047 100644 --- a/src/main/java/com/avaje/ebean/config/ServerConfig.java +++ b/src/main/java/com/avaje/ebean/config/ServerConfig.java @@ -73,6 +73,11 @@ public class ServerConfig { private ContainerConfig containerConfig; + /** + * The underlying properties that were used during configuration. + */ + private Properties properties; + /** * The resource directory. */ @@ -1944,10 +1949,18 @@ public class ServerConfig { * Load the settings from the given properties */ public void loadFromProperties(Properties properties) { + // keep the properties used for configuration so that these are available for plugins + this.properties = properties; PropertiesWrapper p = new PropertiesWrapper("ebean", name, properties); loadSettings(p); } + /** + * Return the properties that we used for configuration and were set via a call to loadFromProperties(). + */ + public Properties getProperties() { + return properties; + } @SuppressWarnings("unchecked") private T createInstance(PropertiesWrapper p, Class pluginType, String key) { diff --git a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java index d31577022..07c7ff72e 100644 --- a/src/test/java/com/avaje/ebean/config/ServerConfigTest.java +++ b/src/test/java/com/avaje/ebean/config/ServerConfigTest.java @@ -17,6 +17,8 @@ public class ServerConfigTest { assertEquals(PersistBatch.NONE, serverConfig.getPersistBatch()); assertEquals(PersistBatch.ALL, serverConfig.getPersistBatchOnCascade()); + + assertNotNull(serverConfig.getProperties()); } @Test