deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject deltaspike git commit: DELTASPIKE-1254 pring full configuration on bootstrap
Date Mon, 15 May 2017 07:05:06 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master ebcac8257 -> f767c80c8


DELTASPIKE-1254 pring full configuration on bootstrap

This feature needs to be enabled via the configuration entry
'deltaspike.configuration.log=true'


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/f767c80c
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/f767c80c
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/f767c80c

Branch: refs/heads/master
Commit: f767c80c845d8b5643d23af49eb7d23d67d1752f
Parents: ebcac82
Author: Mark Struberg <struberg@apache.org>
Authored: Mon May 15 09:04:08 2017 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Mon May 15 09:04:08 2017 +0200

----------------------------------------------------------------------
 .../core/api/config/ConfigResolver.java         |  6 +++
 .../impl/config/ConfigurationExtension.java     | 41 +++++++++++++++++---
 2 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f767c80c/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
index 5d0bf47..f8bcae7 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
@@ -68,6 +68,12 @@ public final class ConfigResolver
      */
     public static final String DELTASPIKE_APP_NAME_CONFIG = "deltaspike.application.name";
 
+    /**
+     * Set this to true if your application should log the whole ConfigSources and Configuration
+     * at startup.
+     */
+    public static final String DELTASPIKE_LOG_CONFIG = "deltaspike.config.log";
+
 
     private static final Logger LOG = Logger.getLogger(ConfigResolver.class.getName());
 

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f767c80c/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
index d6e5223..418935f 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
@@ -47,6 +47,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.deltaspike.core.api.config.ConfigProperty;
 import org.apache.deltaspike.core.api.config.ConfigResolver;
@@ -67,6 +69,7 @@ import org.apache.deltaspike.core.util.ClassDeactivationUtils;
 import org.apache.deltaspike.core.util.ClassUtils;
 import org.apache.deltaspike.core.util.ServiceUtils;
 import org.apache.deltaspike.core.util.bean.BeanBuilder;
+import org.jboss.arquillian.config.impl.extension.ConfigExtension;
 
 /**
  * This extension handles {@link org.apache.deltaspike.core.api.config.PropertyFileConfig}s
@@ -74,6 +77,8 @@ import org.apache.deltaspike.core.util.bean.BeanBuilder;
  */
 public class ConfigurationExtension implements Extension, Deactivatable
 {
+    private static final Logger LOG = Logger.getLogger(ConfigExtension.class.getName());
+
     private static final String CANNOT_CREATE_CONFIG_SOURCE_FOR_CUSTOM_PROPERTY_FILE_CONFIG
=
         "Cannot create ConfigSource for custom property-file config ";
 
@@ -106,11 +111,6 @@ public class ConfigurationExtension implements Extension, Deactivatable
     protected void init(@Observes BeforeBeanDiscovery beforeBeanDiscovery)
     {
         isActivated = ClassDeactivationUtils.isActivated(getClass());
-
-        if (isActivated)
-        {
-            registerConfigMBean();
-        }
     }
 
     public static void registerConfigMBean()
@@ -308,6 +308,37 @@ public class ConfigurationExtension implements Extension, Deactivatable
         }
 
         processConfigurationValidation(adv);
+
+        registerConfigMBean();
+
+        logConfiguration();
+    }
+
+    private void logConfiguration()
+    {
+        Boolean logConfig = ConfigResolver.resolve(ConfigResolver.DELTASPIKE_LOG_CONFIG).as(Boolean.class).getValue();
+        if (logConfig != null && logConfig && LOG.isLoggable(Level.INFO))
+        {
+            StringBuilder sb = new StringBuilder(1 << 16);
+
+            // first log out the config sources in descendent ordinal order
+            sb.append("ConfigSources: ");
+            ConfigSource[] configSources = ConfigResolver.getConfigSources();
+            for (ConfigSource configSource : configSources)
+            {
+                sb.append("\n\t").append(configSource.getOrdinal()).append(" - ").append(configSource.getConfigName());
+            }
+
+            // and all the entries in no guaranteed order
+            Map<String, String> allProperties = ConfigResolver.getAllProperties();
+            sb.append("\n\nConfigured Values:");
+            for (Map.Entry<String, String> entry : allProperties.entrySet())
+            {
+                sb.append("\n\t").append(entry.getKey()).append(" = ").append(entry.getValue());
+            }
+
+            LOG.info(sb.toString());
+        }
     }
 
     /**


Mime
View raw message