title: Design for reloading configuration dependency of java class
body: <p>Suppose this is a configuration data object that I read from DB/XML:</p>
  
  <pre><code>class ConfigurationClass{
  
       //some configurations
       public String getString(){
  
       }
  }
  </code></pre>
  
  <p>Now this is the class that uses this configuration object</p>
  
  <pre><code>class ConfigurationUser implements Reloadable{
  
       private ConfigurationClass configuration;
  
       //some extra logic required for making object ready to use
       public void init(){
           // some new object is created based on configuration
           SomeObject obj = new SomeObject(configuration.getString());
  
           //register to configuration manager 
       }
  
       @Override
       public void reload(){
          //does whole reloading stuff
          //creates a new instance of configuration class and reads new configuration which is not appropriate
       }
  }
  </code></pre>
  
  <p>Now when I have to reload the configuration then suppose I create a new instance of <code>ConfigurationClass</code> and inject it in <code>ConfigurationUser</code> class.
  But I will also have to re-initialize the object, so that it can create new configuration dependent objects.</p>
  
  <p>Is this a proper design to do it or there is a better approach? I thought of using Spring or Google Juice for DI, but again I will have to provide the <strong>callback</strong> to the configuration user class, that configuration has been reloaded. </p>
  
  <p>I am new to using IoC containers so dont know if it is possible. <strong>Need to use this in real time server application so have to be strict about garbage production and performance.</strong></p>
  
  <p>Current solution:</p>
  
  <pre><code>public interface Reloadable{
  
      public void reload(); 
  }
  </code></pre>
  
  <p>I have a configuration manager to which I register all the configuration user instances, and when reload is to be done, manager just calls <code>reload</code> and it reads new configuration and re initializes all dependent objects.</p>
  
  <p>Any help would be appreciated.</p>