Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7812823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:38:20+00:00 2026-06-02T04:38:20+00:00

I’m having an issue with my configuration management class, it is not getting reloaded.

  • 0

I’m having an issue with my configuration management class, it is not getting reloaded.

Let me show you part of my code:

public class ConfigurationManager extends XMLConfiguration
{
   private static final Logger log = LoggerFactory.getLogger(ConfigurationManager.class);

   private static final long serialVersionUID = 1L;
   public static final String CONFIG_FILE_PATH = "/config.xml";
   private static volatile ConfigurationManager instance = null;
   private static Object lock = new Object();

   // Instance management methods
   public static ConfigurationManager getInstance()
   {
      return getInstance(CONFIG_FILE_PATH);
   }

   public static ConfigurationManager getInstance(String cfg)
   {
      if(instance == null)
      {
         synchronized(lock)
         {
            if(instance == null)
            {
               try
               {
                  instance = new ConfigurationManager(cfg);
                  instance.dumpConfigurationToLog();
               }
               catch(Exception e)
               {
                  log.error("Error calling getInstance. Method params", e);
               }
            }
         }
      }
      return instance;
   }

   private Object loadedCfg;

   private int reloadInterval;

   private void dumpConfigurationToLog()
   {
      ByteArrayOutputStream bos = new ByteArrayOutputStream();

      try
      {
         this.save(bos);
         bos.flush();
      }
      catch(Exception e)
      {
         log.error("Error calling dumpConfigurationToLog. Method params", e);
      }

   }

   @Override
   public void configurationChanged(ConfigurationEvent event)
   {
      log.info("Enter Method configurationChanged params: {}", event);
      if(event.isBeforeUpdate() == false)
      {
         makeUpdates();

         log.info("Configuration file: {} has changed and reloaded...", loadedCfg);
         dumpConfigurationToLog();
      }
      log.info("Return Method configurationChanged");
   }

   private void updateReloadInterval()
   {
      int newReloadInterval = getInt("global.reloadInterval") * 1000;
      if(reloadInterval != newReloadInterval)
      {
         reloadInterval = newReloadInterval;
         if(getReloadInterval() > 0)
         {
            FileChangedReloadingStrategy reloadStrategy = new FileChangedReloadingStrategy();
            reloadStrategy.setRefreshDelay(getReloadInterval());
            this.setReloadingStrategy(reloadStrategy);
         }
         else
            if(getReloadInterval() == 0)
            {
               this.setReloadingStrategy(new InvariantReloadingStrategy());
            }
            else
            {
               log.error("Invalid reload interval for ConfigurationManager: {}", getReloadInterval());
            }
      }
   }

   private ConfigurationManager(String cfgFile) throws Exception, ConfigurationException
   {
      super();
      loadedCfg = cfgFile;
      if(System.class.getResource(cfgFile) != null)
         this.setURL(System.class.getResource(cfgFile));
      else
         this.setURL(getClass().getResource(cfgFile));
      this.load();
      makeUpdates();
      this.addConfigurationListener(this);
      this.setThrowExceptionOnMissing(true);
   }

   private void makeUpdates()
   {
      updateReloadInterval();
   }

   public int getReloadInterval()
   {
      return reloadInterval;
   }
}

Now that code works perfectly fine, I can read the configuration file, and work with it with no major problems, the issue is that it never gets reloaded on configuration changes. I’ve tried setting breakpoints and so, but it never gets into configurationChanged method.

Does anybody see something wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:38:25+00:00Added an answer on June 2, 2026 at 4:38 am

    Well, after testing and analyzing, I’ve got to this conclusion, in order to have configurationChanged called, I need to make an explicit call to get values from configuration.
    And that is something I was not doing.

    The thing got fixed when I did that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.