geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r516497 - in /geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream: FactoryLocator.java XMLOutputFactory.java XMLStreamException.java
Date Fri, 09 Mar 2007 18:31:59 GMT
Author: hogstrom
Date: Fri Mar  9 10:31:59 2007
New Revision: 516497

URL: http://svn.apache.org/viewvc?view=rev&rev=516497
Log:
Updated the mechanism to locate Factory classes as well as fixed the issues on XMLOutputFactory
with regard to the problems with the spec.  See JSR172 MR-1 for more information

Modified:
    geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/FactoryLocator.java
    geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLOutputFactory.java
    geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLStreamException.java

Modified: geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/FactoryLocator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/FactoryLocator.java?view=diff&rev=516497&r1=516496&r2=516497
==============================================================================
--- geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/FactoryLocator.java
(original)
+++ geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/FactoryLocator.java
Fri Mar  9 10:31:59 2007
@@ -28,7 +28,7 @@
 import java.io.InputStreamReader;
 
 /*
- * Alrighty...here is the beef on the newInstance methods:
+ * Here is the beef on the finding the Factory Class
  * 
  * 1. Use the javax.xml.stream.XMLInputFactory system property. 2. Use the
  * properties file "lib/stax.properties" in the JRE directory. This
@@ -40,8 +40,8 @@
  * META-INF/services/javax.xml.stream.XMLInputFactory in jars available to the
  * runtime. Platform default XMLInputFactory instance.
  * 
- * Once an application has obtained a reference to a XMLInputFactory it can use
- * the factory to configure and obtain stream instances.
+ * If the user provided a classloader we'll use that...if not, we'll assume the 
+ * classloader of this class.
  */
 
 class FactoryLocator {
@@ -49,32 +49,32 @@
 		return locate(factoryId, null);
 	}
 
-	static Object locate(String factoryId, String fallbackClassName)
+	static Object locate(String factoryId, String altClassName)
 			throws FactoryConfigurationError {
-		return locate(factoryId, fallbackClassName, null);
+		return locate(factoryId, altClassName, FactoryLocator.class
+				.getClassLoader());
 	}
 
-	static Object locate(String factoryId, 
-			             String fallbackClassName,
-			             ClassLoader classLoader) throws FactoryConfigurationError {
+	static Object locate(String factoryId, String altClassName,
+			ClassLoader classLoader) throws FactoryConfigurationError {
 		try {
 			String prop = System.getProperty(factoryId);
 			if (prop != null) {
-				return newInstance(prop, classLoader);
+				return loadFactory(prop, classLoader);
 			}
 		} catch (Exception e) {
 		}
 
 		try {
-			String configFile = System.getProperty("java.home") +
-					              File.separator + "lib" + File.separator +
-					              "jaxp.properties";
+			String configFile = System.getProperty("java.home")
+					+ File.separator + "lib" + File.separator
+					+ "jaxp.properties";
 			File f = new File(configFile);
 			if (f.exists()) {
 				Properties props = new Properties();
 				props.load(new FileInputStream(f));
 				String factoryClassName = props.getProperty(factoryId);
-				return newInstance(factoryClassName, classLoader);
+				return loadFactory(factoryClassName, classLoader);
 			}
 		} catch (Exception e) {
 		}
@@ -96,36 +96,33 @@
 				br.close();
 
 				if (factoryClassName != null && !"".equals(factoryClassName)) {
-					return newInstance(factoryClassName, classLoader);
+					return loadFactory(factoryClassName, classLoader);
 				}
 			}
 		} catch (Exception ex) {
 		}
 
-		if (fallbackClassName == null) {
+		if (altClassName == null) {
 			throw new FactoryConfigurationError("Unable to locate factory for "
 					+ factoryId + ".", null);
 		}
-		return newInstance(fallbackClassName, classLoader);
+		return loadFactory(altClassName, classLoader);
 	}
 
-	private static Object newInstance(String className, ClassLoader classLoader)
+	private static Object loadFactory(String className, ClassLoader classLoader)
 			throws FactoryConfigurationError {
 		try {
-			Class spiClass;
-			if (classLoader == null) {
-				spiClass = Class.forName(className);
-			} else {
-				spiClass = classLoader.loadClass(className);
-			}
-			return spiClass.newInstance();
+			Class factoryClass = classLoader == null ? Class.forName(className)
+					: classLoader.loadClass(className);
+
+			return factoryClass.newInstance();
 		} catch (ClassNotFoundException x) {
 			throw new FactoryConfigurationError("Requested factory "
-					+ className + " cannot be located.", x);
+					+ className + " cannot be located.  Classloader ="
+					+ classLoader.toString(), x);
 		} catch (Exception x) {
 			throw new FactoryConfigurationError("Requested factory "
 					+ className + " could not be instantiated: " + x, x);
 		}
 	}
-
 }

Modified: geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLOutputFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLOutputFactory.java?view=diff&rev=516497&r1=516496&r2=516497
==============================================================================
--- geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLOutputFactory.java
(original)
+++ geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLOutputFactory.java
Fri Mar  9 10:31:59 2007
@@ -1,3 +1,22 @@
+/*
+ **
+ ** 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 javax.xml.stream;
 
 public abstract class XMLOutputFactory {
@@ -7,13 +26,13 @@
 			throws FactoryConfigurationError {
 		return (XMLOutputFactory) FactoryLocator.locate(
 				"javax.xml.stream.XMLOutputFactory",
-				"com.bea.xml.stream.MXParserFactory");
+				"com.bea.xml.stream.XMLOutputFactoryBase");
 	}
 
-	public static XMLOutputFactory newInstance(String factoryId,
+	public static XMLInputFactory newInstance(String factoryId,
 			java.lang.ClassLoader classLoader) throws FactoryConfigurationError {
-		return (XMLOutputFactory) FactoryLocator.locate(factoryId,
-				"com.bea.xml.stream.MXParserFactory", classLoader);
+		return (XMLInputFactory) FactoryLocator.locate(factoryId,
+				"com.bea.xml.stream.XMLInputFactoryBase", classLoader);
 	}
 
 	public abstract XMLStreamWriter createXMLStreamWriter(java.io.Writer stream)

Modified: geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLStreamException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLStreamException.java?view=diff&rev=516497&r1=516496&r2=516497
==============================================================================
--- geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLStreamException.java
(original)
+++ geronimo/specs/trunk/geronimo-stax-api_1.0_spec/src/main/java/javax/xml/stream/XMLStreamException.java
Fri Mar  9 10:31:59 2007
@@ -1,5 +1,45 @@
 package javax.xml.stream;
 
 public class XMLStreamException extends Exception {
+	protected Throwable nested;
 
+	protected Location location;
+
+	public XMLStreamException() {
+	}
+
+	public XMLStreamException(java.lang.String msg) {
+		super(msg);
+	}
+
+	public XMLStreamException(java.lang.Throwable th) {
+		this.nested = th;
+	}
+
+	public XMLStreamException(java.lang.String msg, java.lang.Throwable th) {
+		super(msg);
+		this.nested = th;
+	}
+
+	public XMLStreamException(java.lang.String msg, Location location,
+			java.lang.Throwable th) {
+		super("ParseError at [row,col]:[" + location.getLineNumber() + ","
+				+ location.getColumnNumber() + "]\n" + "Message: " + msg);
+		this.location = location;
+		this.nested = th;
+	}
+
+	public XMLStreamException(java.lang.String msg, Location location) {
+		super("ParseError at [row,col]:[" + location.getLineNumber() + ","
+				+ location.getColumnNumber() + "]\n" + "Message: " + msg);
+		this.location = location;
+	}
+
+	public java.lang.Throwable getNestedException() {
+		return nested;
+	}
+
+	public Location getLocation() {
+		return location;
+	}
 }



Mime
View raw message