Diff of /jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java
Parent Directory
| Revision Log
| Patch
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java 2005/08/02 14:32:40 227017
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationFactory.java 2005/08/02 14:43:20 227018
@@ -25,6 +25,8 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Stack;
+import org.apache.commons.configuration.plist.PropertyListConfiguration;
+import org.apache.commons.configuration.plist.XMLPropertyListConfiguration;
import org.apache.commons.digester.AbstractObjectCreationFactory;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.ObjectCreationFactory;
@@ -286,6 +288,13 @@ public class ConfigurationFactory
setupDigesterInstance(
digester,
+ matchString + "plist",
+ new PropertyListConfigurationFactory(),
+ null,
+ additional);
+
+ setupDigesterInstance(
+ digester,
matchString + "xml",
new FileConfigurationFactory(XMLConfiguration.class),
null,
@@ -548,6 +557,34 @@ public class ConfigurationFactory
}
}
}
+
+ /**
+ * A factory that returns an XMLPropertyListConfiguration for .xml files
+ * and a PropertyListConfiguration for the others.
+ *
+ * @since 1.2
+ */
+ public class PropertyListConfigurationFactory extends FileConfigurationFactory
+ {
+ public PropertyListConfigurationFactory()
+ {
+ super(null);
+ }
+
+ protected FileConfiguration createConfiguration(Attributes attributes) throws Exception
+ {
+ String filename = attributes.getValue(ATTR_FILENAME);
+
+ if (filename != null && filename.toLowerCase().trim().endsWith(".xml"))
+ {
+ return new XMLPropertyListConfiguration();
+ }
+ else
+ {
+ return new PropertyListConfiguration();
+ }
+ }
+ }
/**
* A tiny inner class that allows the Configuration Factory to