Uploaded image for project: 'Commons Configuration'
  1. Commons Configuration
  2. CONFIGURATION-381

Support automatic reloading for configuration files in JBoss VFS

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: File reloading
    • Labels:
      None

      Description

      Using Commons Configuration with JBoss 5 presents problems when storing files in the JBoss directories and referencing them with relative paths. This applies to configuration files stored in the traditional spot for JBoss configuration, like JBOSS_HOME/server/default/conf/. More specifically, when FileChangedReloadingStrategy tries to resolve the file path it gets a vfsfile: URL from the JBoss-modified context classloader, that it can't parse. The following patch adds support for this URL scheme by fixing the resource URL to avoid VFS, and allows Commons Configuration to properly recognize file modifications in the file system.

      FileChangedReloadingStrategy.java
      Index: FileChangedReloadingStrategy.java
      ===================================================================
      --- FileChangedReloadingStrategy.java	(revision 764760)
      +++ FileChangedReloadingStrategy.java	(working copy)
      @@ -46,6 +46,9 @@
           /** Constant for the jar URL protocol.*/
           private static final String JAR_PROTOCOL = "jar";
       
      +    /** Constant for the JBoss MC VFSFile URL protocol.*/
      +    private static final String VFSFILE_PROTOCOL = "vfsfile";
      +
           /** Constant for the default refresh delay.*/
           private static final int DEFAULT_REFRESH_DELAY = 5000;
       
      @@ -161,7 +164,8 @@
       
           /**
            * Helper method for transforming a URL into a file object. This method
      -     * handles file: and jar: URLs.
      +     * handles file: and jar: URLs, as well as JBoss VFS-specific vfsfile:
      +     * URLs.
            *
            * @param url the URL to be converted
            * @return the resulting file or <b>null </b>
      @@ -181,6 +185,18 @@
                       return null;
                   }
               }
      +        else if (VFSFILE_PROTOCOL.equals(url.getProtocol()))
      +        {
      +            String path = url.getPath();
      +            try
      +            {
      +                return ConfigurationUtils.fileFromURL(new URL("file:" + path));
      +            }
      +            catch (MalformedURLException mex)
      +            {
      +                return null;
      +            }
      +        }
               else
               {
                   return ConfigurationUtils.fileFromURL(url);
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              past Panagiotis Astithas
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: