servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1226832 - in /servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream: FactoryLocator.java XMLEventFactory.java XMLInputFactory.java XMLOutputFactory.java
Date Tue, 03 Jan 2012 15:42:53 GMT
Author: gnodet
Date: Tue Jan  3 15:42:53 2012
New Revision: 1226832

URL: http://svn.apache.org/viewvc?rev=1226832&view=rev
Log:
Add support for stax implementation in ibm jre

Modified:
    servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/FactoryLocator.java
    servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLEventFactory.java
    servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLInputFactory.java
    servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLOutputFactory.java

Modified: servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/FactoryLocator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/FactoryLocator.java?rev=1226832&r1=1226831&r2=1226832&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/FactoryLocator.java
(original)
+++ servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/FactoryLocator.java
Tue Jan  3 15:42:53 2012
@@ -20,6 +20,7 @@ import java.io.InputStream;
 import java.io.File;
 import java.io.FileInputStream;
 
+import java.util.Arrays;
 import java.util.Properties;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
@@ -46,13 +47,13 @@ class FactoryLocator {
 		return locate(factoryId, null);
 	}
 
-	static Object locate(String factoryId, String altClassName)
+	static Object locate(String factoryId, String[] altClassName)
 			throws FactoryConfigurationError {
 		return locate(factoryId, altClassName,
                               Thread.currentThread().getContextClassLoader());
 	}
 
-	static Object locate(String factoryId, String altClassName,
+	static Object locate(String factoryId, String[] altClassName,
                          ClassLoader classLoader) throws FactoryConfigurationError {
         try {
             // If we are deployed into an OSGi environment, leverage it
@@ -120,6 +121,22 @@ class FactoryLocator {
 		return loadFactory(altClassName, classLoader);
 	}
 
+    private static Object loadFactory(String[] classNames, ClassLoader classLoader)
+            throws FactoryConfigurationError {
+        for (String className : classNames) {
+            try {
+                Class factoryClass = classLoader == null ? Class.forName(className)
+                        : classLoader.loadClass(className);
+
+                return factoryClass.newInstance();
+            } catch (Exception x) {
+            }
+        }
+        throw new FactoryConfigurationError("Requested factory "
+                + Arrays.asList(classNames).toString()
+                + " could not be instantiated");
+    }
+
 	private static Object loadFactory(String className, ClassLoader classLoader)
 			throws FactoryConfigurationError {
 		try {

Modified: servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLEventFactory.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLEventFactory.java?rev=1226832&r1=1226831&r2=1226832&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLEventFactory.java
(original)
+++ servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLEventFactory.java
Tue Jan  3 15:42:53 2012
@@ -43,12 +43,15 @@ public abstract class XMLEventFactory {
 
 	public static XMLEventFactory newInstance()
 			throws FactoryConfigurationError {
-            return (XMLEventFactory)FactoryLocator.locate("javax.xml.stream.XMLEventFactory",
"com.sun.xml.internal.stream.events.XMLEventFactoryImpl");
+            return (XMLEventFactory)FactoryLocator.locate("javax.xml.stream.XMLEventFactory",
+                    new String[] { "com.sun.xml.internal.stream.events.XMLEventFactoryImpl",
"com.ibm.xml.xlxp.api.stax.XMLEventFactoryImpl" });
 	}
 
 	public static XMLEventFactory newInstance(String factoryId,
 			ClassLoader classLoader) throws FactoryConfigurationError {
-            return (XMLEventFactory)FactoryLocator.locate(factoryId, "com.sun.xml.internal.stream.events.XMLEventFactoryImpl",
classLoader);
+            return (XMLEventFactory)FactoryLocator.locate(factoryId,
+                    new String[] { "com.sun.xml.internal.stream.events.XMLEventFactoryImpl",
"com.ibm.xml.xlxp.api.stax.XMLEventFactoryImpl" },
+                    classLoader);
 	}
 
 	public abstract void setLocation(Location location);

Modified: servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLInputFactory.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLInputFactory.java?rev=1226832&r1=1226831&r2=1226832&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLInputFactory.java
(original)
+++ servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLInputFactory.java
Tue Jan  3 15:42:53 2012
@@ -38,13 +38,16 @@ public abstract class XMLInputFactory {
 	public static XMLInputFactory newInstance()
 			throws FactoryConfigurationError {
 		// We'll assume the XMLInputFactory from the RI as a backup.
-		return (XMLInputFactory)FactoryLocator.locate("javax.xml.stream.XMLInputFactory", "com.sun.xml.internal.stream.XMLInputFactoryImpl");
+		return (XMLInputFactory)FactoryLocator.locate("javax.xml.stream.XMLInputFactory",
+                new String[] { "com.sun.xml.internal.stream.XMLInputFactoryImpl", "com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl"
});
 	}
 
 	public static XMLInputFactory newInstance(java.lang.String factoryId,
 			java.lang.ClassLoader classLoader) throws FactoryConfigurationError {
 		// We'll assume the XMLInputFactory from the RI as a backup.
-		return (XMLInputFactory)FactoryLocator.locate(factoryId, "com.sun.xml.internal.stream.XMLInputFactoryImpl",
classLoader);
+		return (XMLInputFactory)FactoryLocator.locate(factoryId,
+                new String[] { "com.sun.xml.internal.stream.XMLInputFactoryImpl", "com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl"
},
+                classLoader);
 	}
 
 	public abstract XMLStreamReader createXMLStreamReader(java.io.Reader reader)

Modified: servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLOutputFactory.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLOutputFactory.java?rev=1226832&r1=1226831&r2=1226832&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLOutputFactory.java
(original)
+++ servicemix/smx4/specs/trunk/stax-api-1.0/src/main/java/javax/xml/stream/XMLOutputFactory.java
Tue Jan  3 15:42:53 2012
@@ -26,12 +26,15 @@ public abstract class XMLOutputFactory {
 	
 	public static XMLOutputFactory newInstance()
 			throws FactoryConfigurationError {
-		return (XMLOutputFactory) FactoryLocator.locate("javax.xml.stream.XMLOutputFactory", "com.sun.xml.internal.stream.XMLOutputFactoryImpl");
+		return (XMLOutputFactory) FactoryLocator.locate("javax.xml.stream.XMLOutputFactory",
+                new String[] { "com.sun.xml.internal.stream.XMLOutputFactoryImpl", "com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl"
});
 	}
 
 	public static XMLInputFactory newInstance(String factoryId,
 			java.lang.ClassLoader classLoader) throws FactoryConfigurationError {
-		return (XMLInputFactory) FactoryLocator.locate(factoryId, "com.sun.xml.internal.stream.XMLOutputFactoryImpl",
classLoader);
+		return (XMLInputFactory) FactoryLocator.locate(factoryId,
+                new String[] { "com.sun.xml.internal.stream.XMLOutputFactoryImpl", "com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl"
},
+                classLoader);
 	}
 
 	public abstract XMLStreamWriter createXMLStreamWriter(java.io.Writer stream)



Mime
View raw message