You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rg...@apache.org on 2009/09/28 00:28:18 UTC
svn commit: r819418 [1/2] - in
/commons/proper/configuration/branches/CONFIGURATION_390: ./ conf/
src/java/org/apache/commons/configuration/
src/java/org/apache/commons/configuration/reloading/
src/test/org/apache/commons/configuration/ src/test/org/ap...
Author: rgoers
Date: Sun Sep 27 22:28:16 2009
New Revision: 819418
URL: http://svn.apache.org/viewvc?rev=819418&view=rev
Log:
Fixes for CONFIGURATION-390 and CONFIGURATION-397
Added:
commons/proper/configuration/branches/CONFIGURATION_390/conf/configA.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/configB.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/log4j-test.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder2.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder2.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration.xsd
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2001.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1004.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2002.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3001.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1001.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3002.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1002.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder2.xml
- copied, changed from r805888, commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder3.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder1.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder2.xml
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalReloadableConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/Reloadable.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileChangedReloadingStrategy.java
- copied, changed from r805888, commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/Logging.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/reloading/FileRandomReloadingStrategy.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/reloading/TestVFSFileChangedReloadingStrategy.java
- copied, changed from r805888, commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/reloading/TestVFSFileMonitorReloadingStrategy.java
Removed:
commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileMonitorConfigurationBuilder.xml
commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileMonitorConfigurationBuilder2.xml
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileMonitorReloadingStrategy.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/reloading/TestVFSFileMonitorReloadingStrategy.java
Modified:
commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_default.xml
commons/proper/configuration/branches/CONFIGURATION_390/pom.xml
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultFileSystem.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/MultiFileHierarchicalConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCatalogResolver.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCombinedConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestMultiFileHierarchicalConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestVFSConfigurationBuilder.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestWebdavConfigurationBuilder.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/reloading/TestFileChangedReloadingStrategy.java
commons/proper/configuration/branches/CONFIGURATION_390/xdocs/changes.xml
commons/proper/configuration/branches/CONFIGURATION_390/xdocs/userguide/howto_filesystems.xml
commons/proper/configuration/branches/CONFIGURATION_390/xdocs/userguide/howto_multitenant.xml
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/configA.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/configA.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/configA.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/configA.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,3 @@
+<configuration>
+ <property name="config" value="100"/>
+</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/configB.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/configB.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/configB.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/configB.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,3 @@
+<configuration>
+ <stuff>test</stuff>
+</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/log4j-test.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/log4j-test.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/log4j-test.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/log4j-test.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value ="debug" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
\ No newline at end of file
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder.xml (from r805888, commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder.xml&p1=commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder.xml Sun Sep 27 22:28:16 2009
@@ -21,15 +21,15 @@
config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="false">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
- <reloadingStrategy delay="500"
- config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"/>
+ <reloadingStrategy refreshDelay="0"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
</multifile>
<xml fileName="testMultiConfiguration_default.xml"
config-name="defaultConfig" delimiterParsingDisabled="true">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
- <reloadingStrategy
- config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"/>
+ <reloadingStrategy refreshDelay="0"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
</xml>
</override>
</configuration>
\ No newline at end of file
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder2.xml (from r805888, commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder2.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder2.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder2.xml&p1=commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder2.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testFileMonitorConfigurationBuilder2.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testFileReloadConfigurationBuilder2.xml Sun Sep 27 22:28:16 2009
@@ -21,15 +21,15 @@
config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="false">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
- <reloadingStrategy delay="500"
- config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
</multifile>
<xml fileName="testMultiConfiguration_default.xml"
config-name="defaultConfig" delimiterParsingDisabled="true">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
- <reloadingStrategy
- config-class="org.apache.commons.configuration.reloading.VFSFileMonitorReloadingStrategy"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
</xml>
</override>
</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration.xsd
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration.xsd?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration.xsd (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration.xsd Sun Sep 27 22:28:16 2009
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="configuration" type="configurationType"/>
+ <xs:complexType name="configurationType">
+ <xs:sequence>
+ <xs:element type="colorsType" name="colors" minOccurs="0"/>
+ <xs:element type="xs:integer" name="rowsPerPage" minOccurs="0"/>
+ <xs:element type="buttonsType" name="buttons" minOccurs="0"/>
+ <xs:element type="numberFormatType" name="numberFormat" minOccurs="0"/>
+ <xs:element type="splitType" name="split" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>Comma delimited lists</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element type="ChannelsType" name="Channels" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="splitType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="list1" minOccurs="0"/>
+ <xs:element type="xs:string" name="list2" minOccurs="0"/>
+ <xs:element type="list3Type" name="list3" minOccurs="0"/>
+ <xs:element type="list4Type" name="list4" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="colorsType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="background" minOccurs="0"/>
+ <xs:element type="xs:string" name="text" minOccurs="0"/>
+ <xs:element type="xs:string" name="header" minOccurs="0"/>
+ <xs:element type="linkType" name="link" minOccurs="0"/>
+ <xs:element type="xs:string" name="default" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="list4Type">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="values"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="linkType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="normal"/>
+ <xs:attribute type="xs:string" name="visited"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="list3Type">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="values"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="buttonsType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="name" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="numberFormatType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="pattern"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="ChannelType">
+ <xs:sequence>
+ <xs:element name="Name" minOccurs="0">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ <xs:element name="ChannelData" minOccurs="0">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ <xs:element name="MoreChannelData" minOccurs="0">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="id" use="optional"/>
+ </xs:complexType>
+ <xs:complexType name="ChannelsType">
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element type="ChannelType" name="Channel" minOccurs="0"/>
+ </xs:choice>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2001.xml (from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1004.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2001.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2001.xml&p1=commons/proper/configuration/trunk/conf/testMultiConfiguration_1004.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testMultiConfiguration_1004.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2001.xml Sun Sep 27 22:28:16 2009
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
-<configuration>
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://commons.apache.org/testMultiConfiguration.xsd">
<colors>
- <default>${colors.header4}</default>
+ <undefined>This will throw a schema exception</undefined>
</colors>
<buttons>
<name>OK-1,Cancel-2,Help-3</name>
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2002.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2002.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2002.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_2002.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://commons.apache.org/testMultiConfiguration.xsd">
+ <colors>
+ <background>#2222222</background>
+ <text>#000000</text>
+ <header>#222222</header>
+ <link normal="#020202" visited="#202020"/>
+ <default>${colors.header3}</default>
+ </colors>
+ <rowsPerPage>25</rowsPerPage>
+ <buttons>
+ <name>OK-2,Cancel-2,Help-2</name>
+ </buttons>
+ <numberFormat pattern="###\,###.##"/>
+</configuration>
\ No newline at end of file
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3001.xml (from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1001.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3001.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3001.xml&p1=commons/proper/configuration/trunk/conf/testMultiConfiguration_1001.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testMultiConfiguration_1001.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3001.xml Sun Sep 27 22:28:16 2009
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
-<configuration>
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://commons.apache.org/testMultiConfiguration.xsd">
<colors>
<background>#808080</background>
<text>#000000</text>
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3002.xml (from r805888, commons/proper/configuration/trunk/conf/testMultiConfiguration_1002.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3002.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3002.xml&p1=commons/proper/configuration/trunk/conf/testMultiConfiguration_1002.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testMultiConfiguration_1002.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_3002.xml Sun Sep 27 22:28:16 2009
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
-<configuration>
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://commons.apache.org/testMultiConfiguration.xsd">
<colors>
<background>#2222222</background>
<text>#000000</text>
Modified: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_default.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_default.xml?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_default.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiConfiguration_default.xml Sun Sep 27 22:28:16 2009
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
-<configuration>
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://commons.apache.org/testMultiConfiguration.xsd">
<colors>
<background>#40404040</background>
<text>#000000</text>
Copied: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder2.xml (from r805888, commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder2.xml?p2=commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder2.xml&p1=commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/conf/testMultiTenentConfigurationBuilder.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder2.xml Sun Sep 27 22:28:16 2009
@@ -9,6 +9,7 @@
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
</result>
+ <entity-resolver catalogFiles="catalog.xml"/>
<providers>
<provider config-tag="multifile"
config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
@@ -17,14 +18,18 @@
</header>
<override>
<multifile filePattern="testMultiConfiguration_$$${sys:Id}.xml"
- config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="false">
+ config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="true">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
</multifile>
<xml fileName="testMultiConfiguration_default.xml"
- config-name="defaultConfig" delimiterParsingDisabled="true">
+ config-name="defaultConfig" delimiterParsingDisabled="true" schemaValidation="true">
<expressionEngine
config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
</xml>
</override>
</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder3.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder3.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder3.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testMultiTenentConfigurationBuilder3.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!-- Test configuration definition file that demonstrates complex initialization -->
+<configuration>
+ <header>
+ <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger"
+ config-class="org.apache.commons.configuration.DynamicCombinedConfiguration"
+ keyPattern="$${sys:Id}">
+ <nodeCombiner config-class="org.apache.commons.configuration.tree.MergeCombiner"/>
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ </result>
+ <entity-resolver catalogFiles="catalog.xml"/>
+ <providers>
+ <provider config-tag="multifile"
+ config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
+ configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration"/>
+ </providers>
+ </header>
+ <override>
+ <multifile filePattern="testwrite/testMultiConfiguration_$$${sys:Id}.xml"
+ config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
+ </multifile>
+ <xml fileName="testMultiConfiguration_default.xml"
+ config-name="defaultConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.FileChangedReloadingStrategy"/>
+ </xml>
+ </override>
+</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder1.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder1.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder1.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder1.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!-- Test configuration definition file that demonstrates complex initialization -->
+<configuration>
+ <header>
+ <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger"
+ config-class="org.apache.commons.configuration.DynamicCombinedConfiguration"
+ keyPattern="$${sys:Id}">
+ <nodeCombiner config-class="org.apache.commons.configuration.tree.MergeCombiner"/>
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ </result>
+ <fileSystem config-class="org.apache.commons.configuration.VFSFileSystem"/>
+ <entity-resolver catalogFiles="catalog.xml"/>
+ <providers>
+ <provider config-tag="multifile"
+ config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
+ configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration"/>
+ </providers>
+ </header>
+ <override>
+ <multifile filePattern="testMultiConfiguration_$$${sys:Id}.xml"
+ config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
+ </multifile>
+ <xml fileName="testMultiConfiguration_default.xml"
+ config-name="defaultConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
+ </xml>
+ </override>
+</configuration>
\ No newline at end of file
Added: commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder2.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder2.xml?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder2.xml (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/conf/testVFSMultiTenentConfigurationBuilder2.xml Sun Sep 27 22:28:16 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!-- Test configuration definition file that demonstrates complex initialization -->
+<configuration>
+ <header>
+ <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger"
+ config-class="org.apache.commons.configuration.DynamicCombinedConfiguration"
+ keyPattern="$${sys:Id}">
+ <nodeCombiner config-class="org.apache.commons.configuration.tree.MergeCombiner"/>
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ </result>
+ <fileSystem config-class="org.apache.commons.configuration.VFSFileSystem"/>
+ <entity-resolver catalogFiles="catalog.xml"/>
+ <providers>
+ <provider config-tag="multifile"
+ config-class="org.apache.commons.configuration.DefaultConfigurationBuilder$FileConfigurationProvider"
+ configurationClass="org.apache.commons.configuration.MultiFileHierarchicalConfiguration"/>
+ </providers>
+ </header>
+ <override>
+ <multifile filePattern="testwrite/testMultiConfiguration_$$${sys:Id}.xml"
+ config-name="clientConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
+ </multifile>
+ <xml fileName="testMultiConfiguration_default.xml"
+ config-name="defaultConfig" delimiterParsingDisabled="true" schemaValidation="true">
+ <expressionEngine
+ config-class="org.apache.commons.configuration.tree.xpath.XPathExpressionEngine"/>
+ <reloadingStrategy refreshDelay="500"
+ config-class="org.apache.commons.configuration.reloading.VFSFileChangedReloadingStrategy"/>
+ </xml>
+ </override>
+</configuration>
\ No newline at end of file
Modified: commons/proper/configuration/branches/CONFIGURATION_390/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/pom.xml?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/pom.xml (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/pom.xml Sun Sep 27 22:28:16 2009
@@ -462,6 +462,7 @@
<include>testdb.script</include>
<include>*.properties</include>
<include>*.dtd</include>
+ <include>*.xsd</include>
</includes>
</testResource>
<testResource>
@@ -494,6 +495,10 @@
<name>java.awt.headless</name>
<value>true</value>
</property>
+ <property>
+ <name>org.apache.commons.logging.Log</name>
+ <value>org.apache.commons.configuration.Logging</value>
+ </property>
</systemProperties>
</configuration>
</plugin>
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractFileConfiguration.java Sun Sep 27 22:28:16 2009
@@ -103,7 +103,7 @@
protected ReloadingStrategy strategy;
/** A lock object for protecting reload operations.*/
- private Object reloadLock = new Object();
+ protected Object reloadLock = new Object();
/** Stores the encoding of the configuration file.*/
private String encoding;
@@ -207,6 +207,11 @@
return this.fileSystem;
}
+ public Object getReloadLock()
+ {
+ return reloadLock;
+ }
+
/**
* Load the configuration from the underlying location.
@@ -747,8 +752,11 @@
*/
public void addProperty(String key, Object value)
{
- super.addProperty(key, value);
- possiblySave();
+ synchronized(reloadLock)
+ {
+ super.addProperty(key, value);
+ possiblySave();
+ }
}
/**
@@ -761,14 +769,20 @@
*/
public void setProperty(String key, Object value)
{
- super.setProperty(key, value);
- possiblySave();
+ synchronized(reloadLock)
+ {
+ super.setProperty(key, value);
+ possiblySave();
+ }
}
public void clearProperty(String key)
{
- super.clearProperty(key);
- possiblySave();
+ synchronized(reloadLock)
+ {
+ super.clearProperty(key);
+ possiblySave();
+ }
}
public ReloadingStrategy getReloadingStrategy()
@@ -795,6 +809,11 @@
*/
public void reload()
{
+ reload(false);
+ }
+
+ public boolean reload(boolean checkReload)
+ {
synchronized (reloadLock)
{
if (noReload == 0)
@@ -833,6 +852,10 @@
{
fireError(EVENT_RELOAD, null, null, e);
// todo rollback the changes if the file can't be reloaded
+ if (checkReload)
+ {
+ return false;
+ }
}
finally
{
@@ -840,6 +863,7 @@
}
}
}
+ return true;
}
/**
@@ -920,13 +944,19 @@
public boolean isEmpty()
{
reload();
- return super.isEmpty();
+ synchronized(reloadLock)
+ {
+ return super.isEmpty();
+ }
}
public boolean containsKey(String key)
{
reload();
- return super.containsKey(key);
+ synchronized(reloadLock)
+ {
+ return super.containsKey(key);
+ }
}
/**
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/AbstractHierarchicalFileConfiguration.java Sun Sep 27 22:28:16 2009
@@ -29,7 +29,10 @@
import org.apache.commons.configuration.event.ConfigurationEvent;
import org.apache.commons.configuration.event.ConfigurationListener;
+import org.apache.commons.configuration.event.ConfigurationErrorListener;
+import org.apache.commons.configuration.event.ConfigurationErrorEvent;
import org.apache.commons.configuration.reloading.ReloadingStrategy;
+import org.apache.commons.configuration.reloading.Reloadable;
/**
* <p>Base class for implementing file based hierarchical configurations.</p>
@@ -45,7 +48,8 @@
*/
public abstract class AbstractHierarchicalFileConfiguration
extends HierarchicalConfiguration
-implements FileConfiguration, ConfigurationListener, FileSystemBased
+implements FileConfiguration, ConfigurationListener, ConfigurationErrorListener, FileSystemBased,
+ Reloadable
{
/** Stores the delegate used for implementing functionality related to the
* <code>FileConfiguration</code> interface.
@@ -137,26 +141,38 @@
protected void addPropertyDirect(String key, Object obj)
{
- super.addPropertyDirect(key, obj);
- delegate.possiblySave();
+ synchronized(delegate.getReloadLock())
+ {
+ super.addPropertyDirect(key, obj);
+ delegate.possiblySave();
+ }
}
public void clearProperty(String key)
{
- super.clearProperty(key);
- delegate.possiblySave();
+ synchronized(delegate.getReloadLock())
+ {
+ super.clearProperty(key);
+ delegate.possiblySave();
+ }
}
public void clearTree(String key)
{
- super.clearTree(key);
- delegate.possiblySave();
+ synchronized(delegate.getReloadLock())
+ {
+ super.clearTree(key);
+ delegate.possiblySave();
+ }
}
public void setProperty(String key, Object value)
{
- super.setProperty(key, value);
- delegate.possiblySave();
+ synchronized(delegate.getReloadLock())
+ {
+ super.setProperty(key, value);
+ delegate.possiblySave();
+ }
}
public void load() throws ConfigurationException
@@ -281,10 +297,15 @@
public void reload()
{
+ reload(false);
+ }
+
+ private boolean reload(boolean checkReload)
+ {
setDetailEvents(false);
try
{
- delegate.reload();
+ return delegate.reload(checkReload);
}
finally
{
@@ -302,34 +323,58 @@
delegate.setEncoding(encoding);
}
+ public Object getReloadLock()
+ {
+ return delegate.getReloadLock();
+ }
+
public boolean containsKey(String key)
{
reload();
- return super.containsKey(key);
+ synchronized(delegate.getReloadLock())
+ {
+ return super.containsKey(key);
+ }
}
public Iterator getKeys()
{
reload();
- return super.getKeys();
+ synchronized(delegate.getReloadLock())
+ {
+ return super.getKeys();
+ }
}
public Iterator getKeys(String prefix)
{
reload();
- return super.getKeys(prefix);
+ synchronized(delegate.getReloadLock())
+ {
+ return super.getKeys(prefix);
+ }
}
public Object getProperty(String key)
{
- reload();
- return super.getProperty(key);
+ if (reload(true))
+ {
+ // Avoid reloading again and getting the same error.
+ synchronized(delegate.getReloadLock())
+ {
+ return super.getProperty(key);
+ }
+ }
+ return null;
}
public boolean isEmpty()
{
reload();
- return super.isEmpty();
+ synchronized(delegate.getReloadLock())
+ {
+ return super.isEmpty();
+ }
}
/**
@@ -342,8 +387,11 @@
*/
public void addNodes(String key, Collection nodes)
{
- super.addNodes(key, nodes);
- delegate.possiblySave();
+ synchronized(delegate.getReloadLock())
+ {
+ super.addNodes(key, nodes);
+ delegate.possiblySave();
+ }
}
/**
@@ -356,7 +404,10 @@
protected List fetchNodeList(String key)
{
reload();
- return super.fetchNodeList(key);
+ synchronized(delegate.getReloadLock())
+ {
+ return super.fetchNodeList(key);
+ }
}
/**
@@ -394,6 +445,8 @@
private void initDelegate(FileConfigurationDelegate del)
{
del.addConfigurationListener(this);
+ del.addErrorListener(this);
+ del.setLogger(getLogger());
}
/**
@@ -418,6 +471,12 @@
}
}
+ public void configurationError(ConfigurationErrorEvent event)
+ {
+ fireError(event.getType(), event.getPropertyName(), event.getPropertyValue(),
+ event.getCause());
+ }
+
/**
* Returns the file configuration delegate.
*
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/CombinedConfiguration.java Sun Sep 27 22:28:16 2009
@@ -37,6 +37,7 @@
import org.apache.commons.configuration.tree.UnionCombiner;
import org.apache.commons.configuration.tree.ViewNode;
import org.apache.commons.configuration.tree.TreeUtils;
+import org.apache.commons.configuration.reloading.Reloadable;
/**
* <p>
@@ -169,7 +170,7 @@
* @since 1.3
* @version $Id$
*/
-public class CombinedConfiguration extends HierarchicalConfiguration implements
+public class CombinedConfiguration extends HierarchicalReloadableConfiguration implements
ConfigurationListener, Cloneable
{
/**
@@ -204,6 +205,13 @@
/** Stores a map with the named configurations. */
private Map namedConfigurations;
+ /** The default behavior is to ignore exceptions that occur during reload */
+ private boolean ignoreReloadExceptions = true;
+
+ //private final Object reloadLock = new Object();
+
+ private boolean reloadRequired = false;
+
/**
* An expression engine used for converting child configurations to
* hierarchical ones.
@@ -237,6 +245,12 @@
this(null);
}
+ /*
+ public Object getReloadLock()
+ {
+ return reloadLock;
+ } */
+
/**
* Returns the node combiner that is used for creating the combined node
* structure.
@@ -330,6 +344,26 @@
}
/**
+ * Retrieves the value of the ignoreReloadExceptions flag.
+ * @return true if exceptions are ignored, false otherwise.
+ */
+ public boolean isIgnoreReloadExceptions()
+ {
+ return ignoreReloadExceptions;
+ }
+
+ /**
+ * If set to true then exceptions that occur during reloading will be
+ * ignored. If false then the exceptions will be allowed to be thrown
+ * back to the caller.
+ * @param ignoreReloadExceptions true if exceptions should be ignored.
+ */
+ public void setIgnoreReloadExceptions(boolean ignoreReloadExceptions)
+ {
+ this.ignoreReloadExceptions = ignoreReloadExceptions;
+ }
+
+ /**
* Adds a new configuration to this combined configuration. It is possible
* (but not mandatory) to give the new configuration a name. This name must
* be unique, otherwise a <code>ConfigurationRuntimeException</code> will
@@ -546,7 +580,7 @@
*/
public void invalidate()
{
- combinedRoot = null;
+ reloadRequired = true;
fireEvent(EVENT_COMBINED_INVALIDATE, null, null, false);
}
@@ -578,13 +612,153 @@
*/
public ConfigurationNode getRootNode()
{
- if (combinedRoot == null)
+ synchronized(getReloadLock())
+ {
+ if (reloadRequired || combinedRoot == null)
+ {
+ combinedRoot = constructCombinedNode();
+ reloadRequired = false;
+ }
+ return combinedRoot;
+ }
+ }
+ /*
+ public Object getProperty(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getProperty(key);
+ }
+ }
+
+ protected void addPropertyDirect(String key, Object obj)
+ {
+ synchronized(reloadLock)
+ {
+ super.addPropertyDirect(key, obj);
+ }
+ }
+
+ public void addNodes(String key, Collection nodes)
+ {
+ synchronized(reloadLock)
+ {
+ super.addNodes(key, nodes);
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ synchronized(reloadLock)
+ {
+ return super.isEmpty();
+ }
+ }
+
+ public Configuration subset(String prefix)
+ {
+ synchronized(reloadLock)
+ {
+ return super.subset(prefix);
+ }
+ }
+
+ public SubnodeConfiguration configurationAt(String key, boolean supportUpdates)
+ {
+ synchronized(reloadLock)
+ {
+ return super.configurationAt(key, supportUpdates);
+ }
+ }
+
+ public SubnodeConfiguration configurationAt(String key)
+ {
+ synchronized(reloadLock)
{
- combinedRoot = constructCombinedNode();
+ return super.configurationAt(key);
}
- return combinedRoot;
}
+ public List configurationsAt(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.configurationsAt(key);
+ }
+ }
+
+ protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node)
+ {
+ synchronized(reloadLock)
+ {
+ return super.createSubnodeConfiguration(node);
+ }
+ }
+
+ protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node, String subnodeKey)
+ {
+ synchronized(reloadLock)
+ {
+ return super.createSubnodeConfiguration(node, subnodeKey);
+ }
+ }
+
+ public boolean containsKey(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.containsKey(key);
+ }
+ }
+
+ public void setProperty(String key, Object value)
+ {
+ synchronized(reloadLock)
+ {
+ super.setProperty(key, value);
+ }
+ }
+
+ public void clearTree(String key)
+ {
+ synchronized(reloadLock)
+ {
+ super.clearTree(key);
+ }
+ }
+
+ public void clearProperty(String key)
+ {
+ synchronized(reloadLock)
+ {
+ super.clearProperty(key);
+ }
+ }
+
+ public Iterator getKeys()
+ {
+ synchronized(reloadLock)
+ {
+ return super.getKeys();
+ }
+ }
+
+ public Iterator getKeys(String prefix)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getKeys(prefix);
+ }
+ }
+
+ public int getMaxIndex(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getMaxIndex(key);
+ }
+ } */
+
/**
* Clears this configuration. All contained configurations will be removed.
*/
@@ -716,8 +890,10 @@
}
catch (Exception ex)
{
- // ignore all exceptions, e.g. missing property exceptions
- ;
+ if (!ignoreReloadExceptions)
+ {
+ throw new ConfigurationRuntimeException(ex);
+ }
}
}
}
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultFileSystem.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultFileSystem.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultFileSystem.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DefaultFileSystem.java Sun Sep 27 22:28:16 2009
@@ -16,6 +16,9 @@
*/
package org.apache.commons.configuration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import java.io.InputStream;
import java.io.File;
import java.io.IOException;
@@ -35,6 +38,11 @@
*/
public class DefaultFileSystem extends FileSystem
{
+ /**
+ * The Log for diagnostic messages.
+ */
+ private Log log = LogFactory.getLog(DefaultFileSystem.class);
+
public InputStream getInputStream(String basePath, String fileName)
throws ConfigurationException
{
@@ -254,6 +262,10 @@
}
catch (IOException e)
{
+ if (log.isDebugEnabled())
+ {
+ log.debug("Could not locate file " + fileName + " at " + basePath + ": " + e.getMessage());
+ }
return null;
}
}
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/DynamicCombinedConfiguration.java Sun Sep 27 22:28:16 2009
@@ -87,6 +87,7 @@
{
super();
setNodeCombiner(comb);
+ setIgnoreReloadExceptions(false);
}
/**
@@ -98,6 +99,7 @@
public DynamicCombinedConfiguration()
{
super();
+ setIgnoreReloadExceptions(false);
}
public void setKeyPattern(String pattern)
@@ -768,6 +770,7 @@
config.setLogger(log);
}
}
+ config.setIgnoreReloadExceptions(isIgnoreReloadExceptions());
config.setExpressionEngine(this.getExpressionEngine());
config.setDelimiterParsingDisabled(isDelimiterParsingDisabled());
config.setConversionExpressionEngine(getConversionExpressionEngine());
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalConfiguration.java Sun Sep 27 22:28:16 2009
@@ -194,6 +194,16 @@
}
/**
+ * Object to synchronize on a reload. This class is not reloadable so this
+ * object isn't important
+ * @return
+ */
+ public Object getReloadLock()
+ {
+ return this;
+ }
+
+ /**
* Returns the root node of this hierarchical configuration. This method
* exists for backwards compatibility only. New code should use the
* <code>{@link #getRootNode()}</code> method instead, which operates on
Added: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalReloadableConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalReloadableConfiguration.java?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalReloadableConfiguration.java (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/HierarchicalReloadableConfiguration.java Sun Sep 27 22:28:16 2009
@@ -0,0 +1,206 @@
+package org.apache.commons.configuration;
+
+import org.apache.commons.configuration.tree.ConfigurationNode;
+import org.apache.commons.configuration.event.ConfigurationEvent;
+import org.apache.commons.configuration.reloading.Reloadable;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ *
+ */
+public class HierarchicalReloadableConfiguration extends HierarchicalConfiguration
+ implements Reloadable
+{
+ private final Object reloadLock;
+
+ /**
+ * Creates a new instance of <code>HierarchicalReloadableConfiguration</code>.
+ */
+ public HierarchicalReloadableConfiguration()
+ {
+ super();
+ reloadLock = new Object();
+ }
+
+ public HierarchicalReloadableConfiguration(Object lock)
+ {
+ super();
+ reloadLock = lock == null ? new Object() : lock;
+ }
+
+ /**
+ * Creates a new instance of <code>HierarchicalConfiguration</code> and
+ * copies all data contained in the specified configuration into the new
+ * one.
+ *
+ * @param c the configuration that is to be copied (if <b>null</b>, this
+ * constructor will behave like the standard constructor)
+ * @since 1.4
+ */
+ public HierarchicalReloadableConfiguration(HierarchicalConfiguration c)
+ {
+ super(c);
+ reloadLock = new Object();
+ }
+
+
+ public Object getReloadLock()
+ {
+ return reloadLock;
+ }
+
+ public Object getProperty(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getProperty(key);
+ }
+ }
+
+ protected void addPropertyDirect(String key, Object obj)
+ {
+ synchronized(reloadLock)
+ {
+ super.addPropertyDirect(key, obj);
+ }
+ }
+
+ public void addNodes(String key, Collection nodes)
+ {
+ synchronized(reloadLock)
+ {
+ super.addNodes(key, nodes);
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ synchronized(reloadLock)
+ {
+ return super.isEmpty();
+ }
+ }
+
+ public Configuration subset(String prefix)
+ {
+ synchronized(reloadLock)
+ {
+ return super.subset(prefix);
+ }
+ }
+
+ public SubnodeConfiguration configurationAt(String key, boolean supportUpdates)
+ {
+ synchronized(reloadLock)
+ {
+ return super.configurationAt(key, supportUpdates);
+ }
+ }
+
+ public SubnodeConfiguration configurationAt(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.configurationAt(key);
+ }
+ }
+
+ public List configurationsAt(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.configurationsAt(key);
+ }
+ }
+
+ protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node)
+ {
+ synchronized(reloadLock)
+ {
+ return super.createSubnodeConfiguration(node);
+ }
+ }
+
+ protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node, String subnodeKey)
+ {
+ synchronized(reloadLock)
+ {
+ return super.createSubnodeConfiguration(node, subnodeKey);
+ }
+ }
+
+ protected void subnodeConfigurationChanged(ConfigurationEvent event)
+ {
+ synchronized(reloadLock)
+ {
+ super.subnodeConfigurationChanged(event);
+ }
+ }
+
+ void registerSubnodeConfiguration(SubnodeConfiguration config)
+ {
+ synchronized(reloadLock)
+ {
+ super.registerSubnodeConfiguration(config);
+ }
+ }
+
+ public boolean containsKey(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.containsKey(key);
+ }
+ }
+
+ public void setProperty(String key, Object value)
+ {
+ synchronized(reloadLock)
+ {
+ super.setProperty(key, value);
+ }
+ }
+
+ public void clearTree(String key)
+ {
+ synchronized(reloadLock)
+ {
+ super.clearTree(key);
+ }
+ }
+
+ public void clearProperty(String key)
+ {
+ synchronized(reloadLock)
+ {
+ super.clearProperty(key);
+ }
+ }
+
+ public Iterator getKeys()
+ {
+ synchronized(reloadLock)
+ {
+ return super.getKeys();
+ }
+ }
+
+ public Iterator getKeys(String prefix)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getKeys(prefix);
+ }
+ }
+
+ public int getMaxIndex(String key)
+ {
+ synchronized(reloadLock)
+ {
+ return super.getMaxIndex(key);
+ }
+ }
+}
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/MultiFileHierarchicalConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/MultiFileHierarchicalConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/MultiFileHierarchicalConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/MultiFileHierarchicalConfiguration.java Sun Sep 27 22:28:16 2009
@@ -43,6 +43,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.EntityResolver;
+import org.xml.sax.SAXParseException;
/**
* This class provides access to multiple configuration files that reside in a location that
@@ -92,7 +93,7 @@
private boolean attributeSplittingDisabled;
/** The Logger name to use */
- private String loggerName = "";
+ private String loggerName = MultiFileHierarchicalConfiguration.class.getName();
/** The Reloading strategy to use on created configurations */
private ReloadingStrategy fileStrategy;
@@ -107,6 +108,7 @@
{
super();
this.init = true;
+ setLogger(LogFactory.getLog(loggerName));
}
/**
@@ -621,6 +623,14 @@
listener.configurationError(event);
}
}
+
+ if (event.getType() == AbstractFileConfiguration.EVENT_RELOAD)
+ {
+ if (isThrowable(event.getCause()))
+ {
+ throw new ConfigurationRuntimeException(event.getCause());
+ }
+ }
}
/*
@@ -730,7 +740,7 @@
}
catch (ConfigurationException ce)
{
- if (!ignoreException)
+ if (isThrowable(ce))
{
throw new ConfigurationRuntimeException(ce);
}
@@ -746,6 +756,20 @@
return configuration;
}
+ private boolean isThrowable(Throwable throwable)
+ {
+ if (!ignoreException)
+ {
+ return true;
+ }
+ Throwable cause = throwable.getCause();
+ while (cause != null && !(cause instanceof SAXParseException))
+ {
+ cause = cause.getCause();
+ }
+ return cause != null;
+ }
+
/**
* Clone the FileReloadingStrategy since each file needs its own.
* @return A new FileReloadingStrategy.
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/SubnodeConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/SubnodeConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/SubnodeConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/SubnodeConfiguration.java Sun Sep 27 22:28:16 2009
@@ -23,6 +23,7 @@
import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
import org.apache.commons.configuration.tree.ConfigurationNode;
+import org.apache.commons.configuration.reloading.Reloadable;
/**
* <p>
@@ -114,7 +115,7 @@
* @author Oliver Heger
* @version $Id$
*/
-public class SubnodeConfiguration extends HierarchicalConfiguration
+public class SubnodeConfiguration extends HierarchicalReloadableConfiguration
{
/**
* The serial version UID.
@@ -136,6 +137,7 @@
*/
public SubnodeConfiguration(HierarchicalConfiguration parent, ConfigurationNode root)
{
+ super(parent instanceof Reloadable ? ((Reloadable) parent).getReloadLock() : null);
if (parent == null)
{
throw new IllegalArgumentException(
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/XMLConfiguration.java Sun Sep 27 22:28:16 2009
@@ -939,11 +939,11 @@
}
catch (SAXParseException spe)
{
- this.getLogger().debug("Error parsing " + source.getSystemId(), spe);
throw new ConfigurationException("Error parsing " + source.getSystemId(), spe);
}
catch (Exception e)
{
+ this.getLogger().debug("Unable to load the configuraton", e);
throw new ConfigurationException("Unable to load the configuration", e);
}
}
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java Sun Sep 27 22:28:16 2009
@@ -23,6 +23,8 @@
import org.apache.commons.configuration.ConfigurationUtils;
import org.apache.commons.configuration.FileConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* <p>A reloading strategy that will reload the configuration every time its
@@ -64,6 +66,9 @@
/** A flag whether a reload is required.*/
private boolean reloading;
+ /** The Log to use for diagnostic messages */
+ private Log logger = LogFactory.getLog(FileChangedReloadingStrategy.class);
+
public void setConfiguration(FileConfiguration configuration)
{
this.configuration = configuration;
@@ -85,6 +90,10 @@
lastChecked = now;
if (hasChanged())
{
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("File change detected: " + getName());
+ }
reloading = true;
}
}
@@ -141,6 +150,11 @@
File file = getFile();
if (file == null || !file.exists())
{
+ if (logger.isWarnEnabled() && lastModified != 0)
+ {
+ logger.warn("File was deleted: " + getName(file));
+ lastModified = 0;
+ }
return false;
}
@@ -186,4 +200,27 @@
return ConfigurationUtils.fileFromURL(url);
}
}
+
+ private String getName()
+ {
+ return getName(getFile());
+ }
+
+ private String getName(File file)
+ {
+ String name = configuration.getURL().toString();
+ if (name == null)
+ {
+ if (file != null)
+ {
+ name = file.getAbsolutePath();
+ }
+ else
+ {
+ name = "base: " + configuration.getBasePath()
+ + "file: " + configuration.getFileName();
+ }
+ }
+ return name;
+ }
}
Added: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/Reloadable.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/Reloadable.java?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/Reloadable.java (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/Reloadable.java Sun Sep 27 22:28:16 2009
@@ -0,0 +1,9 @@
+package org.apache.commons.configuration.reloading;
+
+/**
+ * Interface that allows other objects to synchronize on a root lock.
+ */
+public interface Reloadable
+{
+ Object getReloadLock();
+}
Copied: commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileChangedReloadingStrategy.java (from r805888, commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java)
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileChangedReloadingStrategy.java?p2=commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileChangedReloadingStrategy.java&p1=commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java&r1=805888&r2=819418&rev=819418&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/reloading/FileChangedReloadingStrategy.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/java/org/apache/commons/configuration/reloading/VFSFileChangedReloadingStrategy.java Sun Sep 27 22:28:16 2009
@@ -17,12 +17,16 @@
package org.apache.commons.configuration.reloading;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.configuration.ConfigurationUtils;
import org.apache.commons.configuration.FileConfiguration;
+import org.apache.commons.configuration.FileSystemBased;
+import org.apache.commons.configuration.FileSystem;
+import org.apache.commons.configuration.ConfigurationRuntimeException;
+import org.apache.commons.vfs.FileSystemManager;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.VFS;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* <p>A reloading strategy that will reload the configuration every time its
@@ -41,11 +45,8 @@
* @version $Revision$, $Date$
* @since 1.1
*/
-public class FileChangedReloadingStrategy implements ReloadingStrategy
+public class VFSFileChangedReloadingStrategy implements ReloadingStrategy
{
- /** Constant for the jar URL protocol.*/
- private static final String JAR_PROTOCOL = "jar";
-
/** Constant for the default refresh delay.*/
private static final int DEFAULT_REFRESH_DELAY = 5000;
@@ -64,6 +65,9 @@
/** A flag whether a reload is required.*/
private boolean reloading;
+ /** Stores the logger.*/
+ private Log log = LogFactory.getLog(getClass());
+
public void setConfiguration(FileConfiguration configuration)
{
this.configuration = configuration;
@@ -71,6 +75,14 @@
public void init()
{
+ if (configuration.getURL() == null && configuration.getFileName() == null)
+ {
+ return;
+ }
+ if (this.configuration == null)
+ {
+ throw new IllegalStateException("No configuration has been set for this strategy");
+ }
updateLastModified();
}
@@ -123,10 +135,17 @@
*/
protected void updateLastModified()
{
- File file = getFile();
+ FileObject file = getFile();
if (file != null)
{
- lastModified = file.lastModified();
+ try
+ {
+ lastModified = file.getContent().getLastModifiedTime();
+ }
+ catch (FileSystemException fse)
+ {
+ log.error("Unable to get last modified time for" + file.getName().getURI());
+ }
}
reloading = false;
}
@@ -138,13 +157,21 @@
*/
protected boolean hasChanged()
{
- File file = getFile();
- if (file == null || !file.exists())
+ FileObject file = getFile();
+ try
{
+ if (file == null || !file.exists())
+ {
+ return false;
+ }
+
+ return file.getContent().getLastModifiedTime() > lastModified;
+ }
+ catch (FileSystemException ex)
+ {
+ log.error("Unable to get last modified time for" + file.getName().getURI());
return false;
}
-
- return file.lastModified() > lastModified;
}
/**
@@ -153,37 +180,25 @@
*
* @return the monitored file
*/
- protected File getFile()
+ protected FileObject getFile()
{
- return (configuration.getURL() != null) ? fileFromURL(configuration
- .getURL()) : configuration.getFile();
- }
-
- /**
- * Helper method for transforming a URL into a file object. This method
- * handles file: and jar: URLs.
- *
- * @param url the URL to be converted
- * @return the resulting file or <b>null </b>
- */
- private File fileFromURL(URL url)
- {
- if (JAR_PROTOCOL.equals(url.getProtocol()))
+ try
{
- String path = url.getPath();
- try
- {
- return ConfigurationUtils.fileFromURL(new URL(path.substring(0,
- path.indexOf('!'))));
- }
- catch (MalformedURLException mex)
+ FileSystemManager fsManager = VFS.getManager();
+ FileSystem fs = ((FileSystemBased) configuration).getFileSystem();
+ String uri = fs.getPath(null, configuration.getURL(), configuration.getBasePath(),
+ configuration.getFileName());
+ if (uri == null)
{
- return null;
+ throw new ConfigurationRuntimeException("Unable to determine file to monitor");
}
+ return fsManager.resolveFile(uri);
}
- else
+ catch (FileSystemException fse)
{
- return ConfigurationUtils.fileFromURL(url);
+ String msg = "Unable to monitor " + configuration.getURL().toString();
+ log.error(msg);
+ throw new ConfigurationRuntimeException(msg, fse);
}
}
}
Added: commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/Logging.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/Logging.java?rev=819418&view=auto
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/Logging.java (added)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/Logging.java Sun Sep 27 22:28:16 2009
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.configuration;
+
+import org.apache.commons.logging.impl.Log4JLogger;
+import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
+import org.apache.log4j.Appender;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.ConsoleAppender;
+
+/**
+ * Configures logging for tests.
+ *
+ * When running with Maven do -Dmaven.surefire.debug="LogLevel=level" to set the
+ * Log Level to the desired value.
+ */
+public class Logging extends Log4JLogger
+{
+ /**
+ * The fully qualified name of the Log4JLogger class.
+ */
+ private static final String FQCN = Logging.class.getName();
+
+ private static Priority traceLevel;
+
+ static
+ {
+ // Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
+ // versions do not. If TRACE is not available, then we have to map
+ // calls to Log.trace(...) onto the DEBUG level.
+
+ try
+ {
+ traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
+ }
+ catch (Exception ex)
+ {
+ // ok, trace not available
+ traceLevel = Priority.DEBUG;
+ }
+
+ String level = System.getProperty("LogLevel");
+ if (level != null)
+ {
+ org.apache.log4j.Logger log = org.apache.log4j.Logger.getRootLogger();
+ log.setLevel(Level.toLevel(level));
+ Appender appender = new ConsoleAppender(new PatternLayout("%p - %m%n"), ConsoleAppender.SYSTEM_OUT);
+ log.addAppender(appender);
+ }
+ }
+
+ public Logging()
+ {
+ super();
+ }
+
+
+ /**
+ * Base constructor.
+ */
+ public Logging(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * For use with a log4j factory.
+ */
+ public Logging(org.apache.log4j.Logger logger)
+ {
+ super(logger);
+ }
+
+ // ---------------------------------------------------------
+ // Implementation
+ //
+ // Note that in the methods below the Priority class is used to define
+ // levels even though the Level class is supported in 1.2. This is done
+ // so that at compile time the call definitely resolves to a call to
+ // a method that takes a Priority rather than one that takes a Level.
+ //
+ // The Category class (and hence its subclass Logging) in version 1.2 only
+ // has methods that take Priority objects. The Category class (and hence
+ // Logging class) in version 1.3 has methods that take both Priority and
+ // Level objects. This means that if we use Level here, and compile
+ // against log4j 1.3 then calls would be bound to the versions of
+ // methods taking Level objects and then would fail to run against
+ // version 1.2 of log4j.
+ // ---------------------------------------------------------
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.TRACE</code>.
+ * When using a log4j version that does not support the <code>TRACE</code>
+ * level, the message will be logged at the <code>DEBUG</code> level.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#trace(Object)
+ */
+ public void trace(Object message)
+ {
+ getLogger().log(FQCN, traceLevel, message, null);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.TRACE</code>.
+ * When using a log4j version that does not support the <code>TRACE</code>
+ * level, the message will be logged at the <code>DEBUG</code> level.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#trace(Object, Throwable)
+ */
+ public void trace(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, traceLevel, message, t);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.DEBUG</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#debug(Object)
+ */
+ public void debug(Object message)
+ {
+ getLogger().log(FQCN, Priority.DEBUG, message, null);
+ }
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.DEBUG</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#debug(Object, Throwable)
+ */
+ public void debug(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, Priority.DEBUG, message, t);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.INFO</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#info(Object)
+ */
+ public void info(Object message)
+ {
+ getLogger().log(FQCN, Priority.INFO, message, null);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.INFO</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#info(Object, Throwable)
+ */
+ public void info(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, Priority.INFO, message, t);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.WARN</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#warn(Object)
+ */
+ public void warn(Object message)
+ {
+ getLogger().log(FQCN, Priority.WARN, message, null);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.WARN</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#warn(Object, Throwable)
+ */
+ public void warn(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, Priority.WARN, message, t);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.ERROR</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#error(Object)
+ */
+ public void error(Object message)
+ {
+ getLogger().log(FQCN, Priority.ERROR, message, null);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.ERROR</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#error(Object, Throwable)
+ */
+ public void error(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, Priority.ERROR, message, t);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.FATAL</code>.
+ *
+ * @param message to log
+ * @see org.apache.commons.logging.Log#fatal(Object)
+ */
+ public void fatal(Object message)
+ {
+ getLogger().log(FQCN, Priority.FATAL, message, null);
+ }
+
+
+ /**
+ * Logs a message with <code>org.apache.log4j.Priority.FATAL</code>.
+ *
+ * @param message to log
+ * @param t log this cause
+ * @see org.apache.commons.logging.Log#fatal(Object, Throwable)
+ */
+ public void fatal(Object message, Throwable t)
+ {
+ getLogger().log(FQCN, Priority.FATAL, message, t);
+ }
+
+}
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestAbstractConfiguration.java Sun Sep 27 22:28:16 2009
@@ -152,7 +152,7 @@
assertNotNull("Default logger is null", config.getLogger());
Log log = LogFactory.getLog(config.getClass());
config.setLogger(log);
- assertSame("Logger was not set", log, config.getLogger());
+ assertSame("Logging was not set", log, config.getLogger());
}
/**
Modified: commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCatalogResolver.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCatalogResolver.java?rev=819418&r1=819417&r2=819418&view=diff
==============================================================================
--- commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCatalogResolver.java (original)
+++ commons/proper/configuration/branches/CONFIGURATION_390/src/test/org/apache/commons/configuration/TestCatalogResolver.java Sun Sep 27 22:28:16 2009
@@ -85,8 +85,8 @@
{
Log log = LogFactory.getLog(this.getClass());
resolver.setLogger(log);
- assertNotNull("No Logger returned", resolver.getLogger());
- assertTrue("Incorrect Logger", log == resolver.getLogger());
+ assertNotNull("No Logging returned", resolver.getLogger());
+ assertTrue("Incorrect Logging", log == resolver.getLogger());
}
}