/**
   * Performs a reload operation if necessary. This method is called on each access of this
   * configuration. It asks the associated reloading strategy whether a reload should be performed.
   * If this is the case, the configuration is cleared and loaded again from its source. If this
   * operation causes an exception, the registered error listeners will be notified. The error event
   * passed to the listeners is of type <code>EVENT_RELOAD</code> and contains the exception that
   * caused the event.
   */
  public void reload() {
    synchronized (reloadLock) {
      if (noReload == 0) {
        try {
          enterNoReload(); // avoid reentrant calls

          if (strategy.reloadingRequired()) {
            if (getLogger().isInfoEnabled()) {
              getLogger().info("Reloading configuration. URL is " + getURL());
            }
            fireEvent(EVENT_RELOAD, null, getURL(), true);
            setDetailEvents(false);
            boolean autoSaveBak = this.isAutoSave(); // save the current state
            this.setAutoSave(false); // deactivate autoSave to prevent information loss
            try {
              clear();
              load();
            } finally {
              this.setAutoSave(autoSaveBak); // set autoSave to previous value
              setDetailEvents(true);
            }
            fireEvent(EVENT_RELOAD, null, getURL(), false);

            // notify the strategy
            strategy.reloadingPerformed();
          }
        } catch (Exception e) {
          fireError(EVENT_RELOAD, null, null, e);
          // todo rollback the changes if the file can't be reloaded
        } finally {
          exitNoReload();
        }
      }
    }
  }
  /**
   * Save the configuration. Before this method can be called a valid file name must have been set.
   *
   * @throws ConfigurationException if an error occurs or no file name has been set yet
   */
  public void save() throws ConfigurationException {
    if (getFileName() == null) {
      throw new ConfigurationException("No file name has been set!");
    }

    if (sourceURL != null) {
      save(sourceURL);
    } else {
      save(fileName);
    }
    strategy.init();
  }
 public void setReloadingStrategy(ReloadingStrategy strategy) {
   this.strategy = strategy;
   strategy.setConfiguration(this);
   strategy.init();
 }