summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Burdess <dog@bluezoo.org>2006-04-26 18:36:12 +0000
committerChris Burdess <dog@bluezoo.org>2006-04-26 18:36:12 +0000
commit9dce860a3de25d8202900b5aab8d6ae242fded7e (patch)
treef95ca195242e6965ed0f022ded6a9c99a39811a7
parent9d0c8e69a174a4f37a173cf8aadc82b8b9281ed8 (diff)
downloadclasspath-9dce860a3de25d8202900b5aab8d6ae242fded7e.tar.gz
2006-04-26 Chris Burdess <dog@gnu.org>
Fixes PR 27290 * javax/xml/datatype/DatatypeFactory.java: Use complete implementation resolution mechanism.
-rw-r--r--ChangeLog6
-rw-r--r--javax/xml/datatype/DatatypeFactory.java37
2 files changed, 40 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 6d80ecde9..988f027e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-26 Chris Burdess <dog@gnu.org>
+
+ Fixes PR 27290
+ * javax/xml/datatype/DatatypeFactory.java: Use complete
+ implementation resolution mechanism.
+
2006-04-26 Audrius Meskauskas <AudriusA@Bioinformatics.org>
* javax/swing/tree/DefaultTreeModel.java (nodeStructureChanged):
diff --git a/javax/xml/datatype/DatatypeFactory.java b/javax/xml/datatype/DatatypeFactory.java
index c5bc96ed2..14f507416 100644
--- a/javax/xml/datatype/DatatypeFactory.java
+++ b/javax/xml/datatype/DatatypeFactory.java
@@ -37,15 +37,23 @@ exception statement from your version. */
package javax.xml.datatype;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Properties;
+import gnu.classpath.ServiceFactory;
/**
* Factory class to create new datatype objects mapping XML to and from Java
* objects.
*
- * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
+ * @author Chris Burdess
* @since 1.5
*/
public abstract class DatatypeFactory
@@ -59,7 +67,7 @@ public abstract class DatatypeFactory
/**
* JAXP 1.3 default implementation class name.
*/
- public static final java.lang.String DATATYPEFACTORY_IMPLEMENTATION_CLASS = "gnu.xml.datatype.JAXPDatatypeFactory";
+ public static final String DATATYPEFACTORY_IMPLEMENTATION_CLASS = "gnu.xml.datatype.JAXPDatatypeFactory";
protected DatatypeFactory()
{
@@ -73,12 +81,35 @@ public abstract class DatatypeFactory
{
try
{
+ // 1. system property
+ String className = System.getProperty(DATATYPEFACTORY_PROPERTY);
+ if (className != null)
+ return (DatatypeFactory) Class.forName(className).newInstance();
+ // 2. jaxp.properties property
+ File javaHome = new File(System.getProperty("java.home"));
+ File javaHomeLib = new File(javaHome, "lib");
+ File jaxpProperties = new File(javaHomeLib, "jaxp.properties");
+ if (jaxpProperties.exists())
+ {
+ FileInputStream in = new FileInputStream(jaxpProperties);
+ Properties p = new Properties();
+ p.load(in);
+ in.close();
+ className = p.getProperty(DATATYPEFACTORY_PROPERTY);
+ if (className != null)
+ return (DatatypeFactory) Class.forName(className).newInstance();
+ }
+ // 3. services
+ Iterator i = ServiceFactory.lookupProviders(DatatypeFactory.class);
+ if (i.hasNext())
+ return (DatatypeFactory) i.next();
+ // 4. fallback
Class t = Class.forName(DATATYPEFACTORY_IMPLEMENTATION_CLASS);
return (DatatypeFactory) t.newInstance();
}
catch (Exception e)
{
- throw new DatatypeConfigurationException (e);
+ throw new DatatypeConfigurationException(e);
}
}