You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2002/05/17 20:58:08 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/util ObjectFactory.java
neilg 02/05/17 11:58:08
Modified: java/src/org/apache/xerces/util ObjectFactory.java
Log:
introduce a "fallback" into our internal class loading factory. The purpose of this fallback is to permit the classloader that loaded this class to try and find a class with the desired name, if the context class loader of the current thread is either null or throws a ClassNotFoundException when attempting to find a class with the given name. This should allow better operation on JDK 1.3.x of applications that do not want to set class loaders on their threads.
Revision Changes Path
1.3 +8 -7 xml-xerces/java/src/org/apache/xerces/util/ObjectFactory.java
Index: ObjectFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/ObjectFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ObjectFactory.java 29 Jan 2002 01:15:18 -0000 1.2
+++ ObjectFactory.java 17 May 2002 18:58:08 -0000 1.3
@@ -81,7 +81,7 @@
* class and modified to be used as a general utility for creating objects
* dynamically.
*
- * @version $Id: ObjectFactory.java,v 1.2 2002/01/29 01:15:18 lehors Exp $
+ * @version $Id: ObjectFactory.java,v 1.3 2002/05/17 18:58:08 neilg Exp $
*/
public class ObjectFactory {
@@ -287,13 +287,14 @@
throws ConfigurationError
{
try {
- Class spiClass;
- if (classLoader == null) {
- spiClass = Class.forName(className);
- } else {
- spiClass = classLoader.loadClass(className);
+ if (classLoader != null) {
+ try {
+ return classLoader.loadClass(className).newInstance ();
+ } catch (ClassNotFoundException x) {
+ // try again
+ }
}
- return spiClass.newInstance();
+ return Class.forName(className).newInstance();
} catch (ClassNotFoundException x) {
throw new ConfigurationError(
"Provider " + className + " not found", x);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org