You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2020/06/02 07:22:02 UTC

[deltaspike] branch master updated: DELTASPIKE-1402 add a way to disable dynamic reloading

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/deltaspike.git


The following commit(s) were added to refs/heads/master by this push:
     new 118b9d3  DELTASPIKE-1402 add a way to disable dynamic reloading
118b9d3 is described below

commit 118b9d3e63970fb94038d6f9379f9c261b4e609b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Tue Jun 2 09:21:23 2020 +0200

    DELTASPIKE-1402 add a way to disable dynamic reloading
    
    by using a deltaspike_reload smaller 0 you can disable dynamic reloading.
---
 .../core/impl/config/PropertyFileConfigSource.java | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/PropertyFileConfigSource.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/PropertyFileConfigSource.java
index c600176..d549ab6 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/PropertyFileConfigSource.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/PropertyFileConfigSource.java
@@ -61,6 +61,11 @@ public class PropertyFileConfigSource extends BaseConfigSource
      * deltaspike_reload=60
      * </pre>
      * Whether the file got changed is determined by the lastModifiedDate of the underlying file.
+     * <p>
+     * You can disable the whole reloading with a negative reload time, e.g.
+     * <pre>
+     * deltaspike_reload=-1
+     * </pre>
      */
     public static final String RELOAD_PERIOD = "deltaspike_reload";
     public static final int RELOAD_PERIOD_DEFAULT = 300;
@@ -94,11 +99,18 @@ public class PropertyFileConfigSource extends BaseConfigSource
 
         if (isFile(propertyFileUrl))
         {
-            fileLastModified = getLastModified();
-            configHelper = ConfigResolver.getConfigProvider().getHelper();
 
             calculateReloadTime();
-            reloadAfterSec = getNowSeconds() + reloadAllSeconds;
+            if (reloadAllSeconds < 0 )
+            {
+                configHelper = null;
+            }
+            else
+            {
+                fileLastModified = getLastModified();
+                configHelper = ConfigResolver.getConfigProvider().getHelper();
+                reloadAfterSec = getNowSeconds() + reloadAllSeconds;
+            }
         }
         else
         {
@@ -115,7 +127,16 @@ public class PropertyFileConfigSource extends BaseConfigSource
         {
             try
             {
-                reloadAllSeconds = Integer.parseInt(reloadPeriod);
+                int reload = Integer.parseInt(reloadPeriod);
+                if (reload < 0)
+                {
+                    fileLastModified = null;
+                    log.info("Disable dynamic reloading for ConfigSource " + filePath);
+                }
+                else
+                {
+                    reloadAllSeconds = reload;
+                }
             }
             catch (NumberFormatException nfe)
             {