ilene 2003/01/15 11:44:45
Modified: java/src/org/apache/xml/dtm Tag: xslt20 DTMManager.java
Added: java/src/org/apache/xml/dtm Tag: xslt20 FactoryFinder.java
SecuritySupport12.java SecuritySupport.java
Log:
Propogating patch for bugzilla #12481.
Revision Changes Path
No revision
No revision
1.10.2.1.2.1 +15 -175 xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java
Index: DTMManager.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/DTMManager.java,v
retrieving revision 1.10.2.1
retrieving revision 1.10.2.1.2.1
diff -u -r1.10.2.1 -r1.10.2.1.2.1
--- DTMManager.java 14 Aug 2002 19:45:33 -0000 1.10.2.1
+++ DTMManager.java 15 Jan 2003 19:44:45 -0000 1.10.2.1.2.1
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,22 +56,10 @@
*/
package org.apache.xml.dtm;
-import java.io.IOException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.BufferedReader;
-
-import java.util.Properties;
-import java.util.Enumeration;
-
-import org.apache.xml.utils.PrefixResolver;
-import org.apache.xml.utils.XMLString;
-import org.apache.xml.utils.XMLStringFactory;
-
import org.apache.xalan.res.XSLMessages;
import org.apache.xalan.res.XSLTErrorResources;
+import org.apache.xml.utils.PrefixResolver;
+import org.apache.xml.utils.XMLStringFactory;
/**
* A DTMManager instance can be used to create DTM and
@@ -176,34 +164,22 @@
throws DTMConfigurationException
{
- String classname = findFactory(defaultPropName,
- "org.apache.xml.dtm.ref.DTMManagerDefault");
+
+ DTMManager factoryImpl = null;
+ try {
+ factoryImpl = (DTMManager) FactoryFinder.find(defaultPropName,
+ /* The fallback implementation class name */
+ "org.apache.xml.dtm.ref.DTMManagerDefault");
+ } catch (FactoryFinder.ConfigurationError e) {
+ throw new
DTMConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_DEFAULT_IMPL,
null)); //"No default implementation found");
+ }
- if (classname == null)
+
+ if (factoryImpl == null)
{
throw new
DTMConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_NO_DEFAULT_IMPL,
null)); //"No default implementation found");
}
- DTMManager factoryImpl;
-
- try
- {
- Class clazz = Class.forName(classname);
-
- factoryImpl = (DTMManager) clazz.newInstance();
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new DTMConfigurationException(cnfe);
- }
- catch (IllegalAccessException iae)
- {
- throw new DTMConfigurationException(iae);
- }
- catch (InstantiationException ie)
- {
- throw new DTMConfigurationException(ie);
- }
factoryImpl.setXMLStringFactory(xsf);
return factoryImpl;
@@ -365,14 +341,7 @@
// -------------------- private methods --------------------
- /**
- * Avoid reading all the files when the findFactory
- * method is called the second time (cache the result of
- * finding the default impl).
- */
- private static String foundFactory = null;
-
- /**
+ /**
* Temp debug code - this will be removed after we test everything
*/
private static boolean debug;
@@ -385,135 +354,6 @@
}
catch (SecurityException ex){}
}
-
- /**
- * Private implementation method - will find the implementation
- * class in the specified order.
- *
- * @param factoryId Name of the factory interface.
- * @param xmlProperties Name of the properties file based on JAVA/lib.
- * @param defaultFactory Default implementation, if nothing else is found.
- *
- * @return The factory class name.
- */
- private static String findFactory(String factoryId, String defaultFactory)
- {
-
- // Use the system property first
- try
- {
- String systemProp = null;
-
- try
- {
- systemProp = System.getProperty(factoryId);
- }
- catch (SecurityException se){}
-
- if (systemProp != null)
- {
- if (debug)
- {
- System.err.println("DTM: found system property" + systemProp);
- }
-
- return systemProp;
- }
- }
- catch (SecurityException se){}
-
- if (foundFactory != null)
- {
- return foundFactory;
- }
-
- // try to read from $java.home/lib/jaxp.properties
- try
- {
- String javah = System.getProperty("java.home");
- String configFile = javah + File.separator + "lib" + File.separator
- + "jaxp.properties";
- File f = new File(configFile);
-
- if (f.exists())
- {
- Properties props = new Properties();
-
- props.load(new FileInputStream(f));
-
- foundFactory = props.getProperty(factoryId);
-
- if (debug)
- {
- System.err.println("DTM: found java.home property " + foundFactory);
- }
-
- if (foundFactory != null)
- {
- return foundFactory;
- }
- }
- }
- catch (Exception ex)
- {
- if (debug)
- {
- ex.printStackTrace();
- }
- }
-
- String serviceId = "META-INF/services/" + factoryId;
-
- // try to find services in CLASSPATH
- try
- {
- ClassLoader cl = DTMManager.class.getClassLoader();
- InputStream is = null;
-
- if (cl == null)
- {
- is = ClassLoader.getSystemResourceAsStream(serviceId);
- }
- else
- {
- is = cl.getResourceAsStream(serviceId);
- }
-
- if (is != null)
- {
- if (debug)
- {
- System.err.println("DTM: found " + serviceId);
- }
-
- BufferedReader rd = new BufferedReader(new InputStreamReader(is,"UTF-8"));
-
- foundFactory = rd.readLine();
-
- rd.close();
-
- if (debug)
- {
- System.err.println("DTM: loaded from services: " + foundFactory);
- }
-
- if ((foundFactory != null) &&!"".equals(foundFactory))
- {
- return foundFactory;
- }
- }
- }
- catch (Exception ex)
- {
- if (debug)
- {
- ex.printStackTrace();
- }
- }
-
- return defaultFactory;
- }
-
/** This value, set at compile time, controls how many bits of the
* DTM node identifier numbers are used to identify a node within a
No revision
No revision
1.1.2.1 +1 -1 xml-xalan/java/src/org/apache/xml/dtm/FactoryFinder.java
Index: FactoryFinder.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/FactoryFinder.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- FactoryFinder.java 14 Jan 2003 21:32:33 -0000 1.1
+++ FactoryFinder.java 15 Jan 2003 19:44:45 -0000 1.1.2.1
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
1.1.2.1 +0 -0 xml-xalan/java/src/org/apache/xml/dtm/SecuritySupport12.java
Index: SecuritySupport12.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/SecuritySupport12.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
1.1.2.1 +0 -0 xml-xalan/java/src/org/apache/xml/dtm/SecuritySupport.java
Index: SecuritySupport.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/SecuritySupport.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]