Mercurial > hg > release > icedtea7-forest-2.4 > jaxp
changeset 742:399c58bf22ad jdk7u45-b03
8013503: Improve stream factories
Reviewed-by: alanb, dfuchs, mullan
author | joehw |
---|---|
date | Thu, 11 Jul 2013 09:01:18 -0700 |
parents | 2e6d1ceda5ee |
children | 41b81353608d |
files | src/javax/xml/stream/FactoryFinder.java src/javax/xml/stream/XMLEventFactory.java src/javax/xml/stream/XMLInputFactory.java src/javax/xml/stream/XMLOutputFactory.java |
diffstat | 4 files changed, 38 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/javax/xml/stream/FactoryFinder.java Wed Jul 10 17:07:02 2013 -0700 +++ b/src/javax/xml/stream/FactoryFinder.java Thu Jul 11 09:01:18 2013 -0700 @@ -204,13 +204,15 @@ * a property name * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. + * @param standardId Indicate whether the factoryId is standard + * or user specified. * * Package private so this code can be shared. */ - static Object find(String factoryId, String fallbackClassName) + static Object find(String factoryId, String fallbackClassName, boolean standardId) throws ConfigurationError { - return find(factoryId, null, fallbackClassName); + return find(factoryId, null, fallbackClassName, standardId); } /** @@ -227,23 +229,34 @@ * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * + * @param standardId Indicate whether the factoryId is standard + * or user specified. + * * Package private so this code can be shared. */ - static Object find(String factoryId, ClassLoader cl, String fallbackClassName) + static Object find(String factoryId, ClassLoader cl, String fallbackClassName, + boolean standardId) throws ConfigurationError { dPrint("find factoryId =" + factoryId); // Use the system property first try { - String systemProp = ss.getSystemProperty(factoryId); + String systemProp; + if (standardId) { + systemProp = ss.getSystemProperty(factoryId); + } else { + systemProp = System.getProperty(factoryId); + } + if (systemProp != null) { dPrint("found system property, value=" + systemProp); return newInstance(systemProp, null, true); } } catch (SecurityException se) { - if (debug) se.printStackTrace(); + throw new ConfigurationError( + "Failed to read factoryId '" + factoryId + "'", se); } // Try read $java.home/lib/stax.properties followed by
--- a/src/javax/xml/stream/XMLEventFactory.java Wed Jul 10 17:07:02 2013 -0700 +++ b/src/javax/xml/stream/XMLEventFactory.java Thu Jul 11 09:01:18 2013 -0700 @@ -60,9 +60,7 @@ public static XMLEventFactory newInstance() throws FactoryConfigurationError { - return (XMLEventFactory) FactoryFinder.find( - JAXPFACTORYID, - DEFAULIMPL); + return (XMLEventFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -93,9 +91,7 @@ public static XMLEventFactory newFactory() throws FactoryConfigurationError { - return (XMLEventFactory) FactoryFinder.find( - JAXPFACTORYID, - DEFAULIMPL); + return (XMLEventFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -118,7 +114,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); @@ -145,7 +142,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLEventFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage());
--- a/src/javax/xml/stream/XMLInputFactory.java Wed Jul 10 17:07:02 2013 -0700 +++ b/src/javax/xml/stream/XMLInputFactory.java Thu Jul 11 09:01:18 2013 -0700 @@ -139,6 +139,7 @@ public static final String ALLOCATOR= "javax.xml.stream.allocator"; + static final String JAXPFACTORYID = "javax.xml.stream.XMLInputFactory"; static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl"; protected XMLInputFactory(){} @@ -150,9 +151,7 @@ public static XMLInputFactory newInstance() throws FactoryConfigurationError { - return (XMLInputFactory) FactoryFinder.find( - "javax.xml.stream.XMLInputFactory", - DEFAULIMPL); + return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -183,9 +182,7 @@ public static XMLInputFactory newFactory() throws FactoryConfigurationError { - return (XMLInputFactory) FactoryFinder.find( - "javax.xml.stream.XMLInputFactory", - DEFAULIMPL); + return (XMLInputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -208,7 +205,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); @@ -235,7 +233,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage());
--- a/src/javax/xml/stream/XMLOutputFactory.java Wed Jul 10 17:07:02 2013 -0700 +++ b/src/javax/xml/stream/XMLOutputFactory.java Thu Jul 11 09:01:18 2013 -0700 @@ -115,6 +115,7 @@ public static final String IS_REPAIRING_NAMESPACES= "javax.xml.stream.isRepairingNamespaces"; + static final String JAXPFACTORYID = "javax.xml.stream.XMLOutputFactory"; static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl"; protected XMLOutputFactory(){} @@ -126,8 +127,7 @@ public static XMLOutputFactory newInstance() throws FactoryConfigurationError { - return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory", - DEFAULIMPL); + return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -158,8 +158,7 @@ public static XMLOutputFactory newFactory() throws FactoryConfigurationError { - return (XMLOutputFactory) FactoryFinder.find("javax.xml.stream.XMLOutputFactory", - DEFAULIMPL); + return (XMLOutputFactory) FactoryFinder.find(JAXPFACTORYID, DEFAULIMPL, true); } /** @@ -181,7 +180,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLInputFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); @@ -210,7 +210,8 @@ throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception - return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader, null); + return (XMLOutputFactory) FactoryFinder.find(factoryId, classLoader, + null, factoryId.equals(JAXPFACTORYID) ? true : false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage());