Support automatic reloading for configuration files in JBoss VFS
----------------------------------------------------------------
Key: CONFIGURATION-381
URL: https://issues.apache.org/jira/browse/CONFIGURATION-381
Project: Commons Configuration
Issue Type: Improvement
Components: File reloading
Affects Versions: 1.6
Reporter: Panagiotis Astithas
Priority: Minor
Attachments: commons-configuration-vfs.patch
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.
{code:title=FileChangedReloadingStrategy.java|borderStyle=solid}
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);
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.