Class ConfigReloadManager

  • All Implemented Interfaces:
    AutoCloseable

    public class ConfigReloadManager
    extends Object
    implements AutoCloseable
    Manages configuration reloading and change notifications.

    This class coordinates file watching, configuration reloading, and notifying listeners when configuration values change.

    Since:
    1.1.0
    Author:
    Bharat Kumar Malviya, GitHub: github.com/imBharatMalviya
    • Method Detail

      • getInstance

        public static ConfigReloadManager getInstance()
        Gets the singleton instance of the reload manager.
      • registerLoadedFile

        public void registerLoadedFile​(String filePath)
        Registers a file that was loaded for potential watching.
      • addChangeListener

        public void addChangeListener​(ConfigChangeListener listener)
        Adds a configuration change listener.
      • removeChangeListener

        public void removeChangeListener​(ConfigChangeListener listener)
        Removes a configuration change listener.
      • enableAutoReload

        public void enableAutoReload()
                              throws IOException
        Enables automatic reloading when configuration files change.
        Throws:
        IOException
      • enableAutoReload

        public void enableAutoReload​(long debounceMs)
                              throws IOException
        Enables automatic reloading with custom debounce time.
        Parameters:
        debounceMs - minimum time between reloads for the same file
        Throws:
        IOException
      • disableAutoReload

        public void disableAutoReload()
        Disables automatic reloading.
      • isAutoReloadEnabled

        public boolean isAutoReloadEnabled()
        Checks if auto-reload is enabled.
      • triggerReload

        public void triggerReload​(String source)
        Manually triggers a reload and notifies listeners.
      • reset

        public static void reset()
        Resets the singleton instance. Useful for testing.