xml-commons-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mrgla...@apache.org
Subject svn commit: r670431 - in /xml/commons/trunk/java/external/src/javax/xml: datatype/ parsers/ transform/ validation/ xpath/
Date Mon, 23 Jun 2008 01:40:03 GMT
Author: mrglavas
Date: Sun Jun 22 18:40:03 2008
New Revision: 670431

URL: http://svn.apache.org/viewvc?rev=670431&view=rev
Log:
Adding newInstance(String, ClassLoader) methods to 
each of the factory classes as specified by JAXP 1.4.

Modified:
    xml/commons/trunk/java/external/src/javax/xml/datatype/DatatypeFactory.java
    xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java
    xml/commons/trunk/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java
    xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java
    xml/commons/trunk/java/external/src/javax/xml/parsers/SAXParserFactory.java
    xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java
    xml/commons/trunk/java/external/src/javax/xml/transform/TransformerFactory.java
    xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java
    xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java
    xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java
    xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java

Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/DatatypeFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/DatatypeFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/datatype/DatatypeFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/datatype/DatatypeFactory.java Sun Jun 22
18:40:03 2008
@@ -91,7 +91,6 @@
      */
     public static DatatypeFactory newInstance()
         throws DatatypeConfigurationException {
-
         try {
             return (DatatypeFactory) FactoryFinder.find(
                     /* The default property name according to the JAXP spec */
@@ -103,6 +102,22 @@
             throw new DatatypeConfigurationException(e.getMessage(), e.getException());
         }
     }
+    
+    public static DatatypeFactory newInstance(String factoryClassName,
+            ClassLoader classLoader) throws DatatypeConfigurationException {
+        if (factoryClassName == null) {
+            throw new DatatypeConfigurationException("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        try {
+            return (DatatypeFactory) FactoryFinder.newInstance(factoryClassName, classLoader);
+        }
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new DatatypeConfigurationException(e.getMessage(), e.getException());
+        }
+    }
 
     /**
      * <p>Obtain a new instance of a <code>Duration</code>

Modified: xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/datatype/FactoryFinder.java Sun Jun 22 18:40:03
2008
@@ -141,7 +141,7 @@
      * 
      * @throws ConfigurationError If class could not be created.
      */
-    private static Object newInstance(
+    static Object newInstance(
     	String className,
         ClassLoader classLoader)
         throws ConfigurationError {

Modified: xml/commons/trunk/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/parsers/DocumentBuilderFactory.java Sun
Jun 22 18:40:03 2008
@@ -105,11 +105,26 @@
                 "javax.xml.parsers.DocumentBuilderFactory",
                 /* The fallback implementation class name */
                 "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
+        } 
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new FactoryConfigurationError(e.getException(), e.getMessage());
+        }
+    }
+    
+    public static DocumentBuilderFactory newInstance(String factoryClassName,
+            ClassLoader classLoader) {
+        if (factoryClassName == null) {
+            throw new FactoryConfigurationError("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        try {
+            return (DocumentBuilderFactory) FactoryFinder.newInstance(factoryClassName, classLoader,
false);
+        }
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new FactoryConfigurationError(e.getException(), e.getMessage());
         }
-
     }
 
     /**

Modified: xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/parsers/FactoryFinder.java Sun Jun 22 18:40:03
2008
@@ -93,7 +93,7 @@
      * @param doFallback true if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
      */
-    private static Object newInstance(String className, ClassLoader cl,
+    static Object newInstance(String className, ClassLoader cl,
                                       boolean doFallback)
         throws ConfigurationError
     {

Modified: xml/commons/trunk/java/external/src/javax/xml/parsers/SAXParserFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/parsers/SAXParserFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/parsers/SAXParserFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/parsers/SAXParserFactory.java Sun Jun 22
18:40:03 2008
@@ -117,9 +117,25 @@
                 "javax.xml.parsers.SAXParserFactory",
                 /* The fallback implementation class name */
                 "org.apache.xerces.jaxp.SAXParserFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new FactoryConfigurationError(e.getException(),
-                                                e.getMessage());
+        } 
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new FactoryConfigurationError(e.getException(), e.getMessage());
+        }
+    }
+    
+    public static SAXParserFactory newInstance(String factoryClassName,
+            ClassLoader classLoader) {
+        if (factoryClassName == null) {
+            throw new FactoryConfigurationError("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        try {
+            return (SAXParserFactory) FactoryFinder.newInstance(factoryClassName, classLoader,
false);
+        }
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new FactoryConfigurationError(e.getException(), e.getMessage());
         }
     }
     

Modified: xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/transform/FactoryFinder.java Sun Jun 22
18:40:03 2008
@@ -93,7 +93,7 @@
      * @param doFallback true if the current ClassLoader should be tried as
      * a fallback if the class is not found using cl
      */
-    private static Object newInstance(String className, ClassLoader cl,
+    static Object newInstance(String className, ClassLoader cl,
                                       boolean doFallback)
         throws ConfigurationError
     {

Modified: xml/commons/trunk/java/external/src/javax/xml/transform/TransformerFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/transform/TransformerFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/transform/TransformerFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/transform/TransformerFactory.java Sun Jun
22 18:40:03 2008
@@ -116,10 +116,25 @@
             "javax.xml.transform.TransformerFactory",
             /* The fallback implementation class name */
             "org.apache.xalan.processor.TransformerFactoryImpl");
-        } catch (FactoryFinder.ConfigurationError e) {
-            throw new TransformerFactoryConfigurationError(
-                e.getException(),
-                e.getMessage());
+        } 
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new TransformerFactoryConfigurationError(e.getException(), e.getMessage());
+        }
+    }
+    
+    public static TransformerFactory newInstance(String factoryClassName,
+            ClassLoader classLoader) throws TransformerFactoryConfigurationError {
+        if (factoryClassName == null) {
+            throw new TransformerFactoryConfigurationError("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        try {
+            return (TransformerFactory) FactoryFinder.newInstance(factoryClassName, classLoader,
false);
+        }
+        catch (FactoryFinder.ConfigurationError e) {
+            throw new TransformerFactoryConfigurationError(e.getException(), e.getMessage());
         }
     }
 

Modified: xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactory.java Sun Jun 22
18:40:03 2008
@@ -196,6 +196,24 @@
         return f;
     }
     
+    public static SchemaFactory newInstance(String schemaLanguage,
+            String factoryClassName, ClassLoader classLoader) {
+        if (schemaLanguage == null) {      
+            throw new NullPointerException();
+        }
+        if (factoryClassName == null) {
+            throw new IllegalArgumentException("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        SchemaFactory f = new SchemaFactoryFinder(classLoader).createInstance(factoryClassName);
+        if (f == null || !f.isSchemaLanguageSupported(schemaLanguage)) {
+            throw new IllegalArgumentException(schemaLanguage);
+        }
+        return f;
+    }
+    
 	/**
 	 * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
 	 * 

Modified: xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/validation/SchemaFactoryFinder.java Sun
Jun 22 18:40:03 2008
@@ -268,7 +268,7 @@
      * @return null
      *      if it fails. Error messages will be printed by this method. 
      */
-    private SchemaFactory createInstance( String className ) {
+    SchemaFactory createInstance( String className ) {
         try {
             if (debug) debugPrintln("instanciating "+className);
             Class clazz;

Modified: xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactory.java Sun Jun 22 18:40:03
2008
@@ -64,10 +64,10 @@
      * @return Instance of an <code>XPathFactory</code>.
      */
     public static final XPathFactory newInstance() {
-    	
     	try {
         	return newInstance(DEFAULT_OBJECT_MODEL_URI);
-    	} catch (XPathFactoryConfigurationException xpathFactoryConfigurationException) {
+    	} 
+    	catch (XPathFactoryConfigurationException xpathFactoryConfigurationException) {
     		throw new RuntimeException(
     			"XPathFactory#newInstance() failed to create an XPathFactory for the default object
model: "
     			+ DEFAULT_OBJECT_MODEL_URI
@@ -131,36 +131,57 @@
     */
     public static final XPathFactory newInstance(final String uri)
         throws XPathFactoryConfigurationException {
-        	
         if (uri == null) {
-        	throw new NullPointerException(
-        		"XPathFactory#newInstance(String uri) cannot be called with uri == null"
-        	);
+            throw new NullPointerException(
+                "XPathFactory#newInstance(String uri) cannot be called with uri == null"
+            );
         }
-
-		if (uri.length() == 0) {
-			throw new IllegalArgumentException(
-				"XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
-			);
-		}
-		
-		ClassLoader classLoader = SecuritySupport.getContextClassLoader();
-        
+        if (uri.length() == 0) {
+            throw new IllegalArgumentException(
+                "XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
+            );
+        }
+        ClassLoader classLoader = SecuritySupport.getContextClassLoader();
         if (classLoader == null) {            
             //use the current class loader
             classLoader = XPathFactory.class.getClassLoader();
         } 
-		
-		XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
-		
-		if (xpathFactory == null) {
-			throw new XPathFactoryConfigurationException(
-				"No XPathFctory implementation found for the object model: "
-				+ uri
-			);
-		}
-		
-		return xpathFactory;
+        XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri);
+        if (xpathFactory == null) {
+            throw new XPathFactoryConfigurationException(
+                "No XPathFctory implementation found for the object model: "
+                + uri
+            );
+        }
+        return xpathFactory;
+    }
+    
+    public static XPathFactory newInstance(String uri, String factoryClassName,
+            ClassLoader classLoader) throws XPathFactoryConfigurationException {
+        if (uri == null) {
+            throw new NullPointerException(
+                "XPathFactory#newInstance(String uri) cannot be called with uri == null"
+            );
+        }
+        if (uri.length() == 0) {
+            throw new IllegalArgumentException(
+                "XPathFactory#newInstance(String uri) cannot be called with uri == \"\""
+            );
+        }
+        if (factoryClassName == null) {
+            throw new XPathFactoryConfigurationException("factoryClassName cannot be null.");
+        }
+        if (classLoader == null) {
+            classLoader = SecuritySupport.getContextClassLoader();
+        }
+        XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).createInstance(factoryClassName);
+        if (xpathFactory == null || !xpathFactory.isObjectModelSupported(uri)) {
+            throw new XPathFactoryConfigurationException(
+                "No XPathFctory implementation found for the object model: "
+                + uri
+            );
+        }
+        return xpathFactory;
     }
 
 	/**

Modified: xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java
URL: http://svn.apache.org/viewvc/xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java?rev=670431&r1=670430&r2=670431&view=diff
==============================================================================
--- xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java (original)
+++ xml/commons/trunk/java/external/src/javax/xml/xpath/XPathFactoryFinder.java Sun Jun 22
18:40:03 2008
@@ -248,7 +248,7 @@
      * @return null
      *      if it fails. Error messages will be printed by this method. 
      */
-    private XPathFactory createInstance( String className ) {
+    XPathFactory createInstance( String className ) {
         try {
             if (debug) debugPrintln("instanciating "+className);
             Class clazz;



Mime
View raw message