conor 2003/08/06 07:12:29 Modified: src/main/org/apache/tools/ant/types XMLCatalog.java Log: Change the check for the external resolver catalog impl to ensure it can be loaded by the resolver classes. Revision Changes Path 1.29 +36 -9 ant/src/main/org/apache/tools/ant/types/XMLCatalog.java Index: XMLCatalog.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/XMLCatalog.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -w -u -r1.28 -r1.29 --- XMLCatalog.java 17 Jul 2003 15:44:43 -0000 1.28 +++ XMLCatalog.java 6 Aug 2003 14:12:29 -0000 1.29 @@ -188,6 +188,12 @@ public static final String APACHE_RESOLVER = "org.apache.tools.ant.types.resolver.ApacheCatalogResolver"; + /** + * Resolver base class + */ + public static final String CATALOG_RESOLVER + = "org.apache.xml.resolver.tools.CatalogResolver"; + //-- Methods --------------------------------------------------------------- /** @@ -534,13 +540,34 @@ loader = getProject().createClassLoader(Path.systemClasspath); try { - Class clazz = loader.forceLoadSystemClass(APACHE_RESOLVER); + Class clazz = Class.forName(CATALOG_RESOLVER, true, loader); + Class clazz = Class.forName(APACHE_RESOLVER, true, loader); + + // The Apache resolver is present - Need to check if it can + // be seen by the catalog resolver class. Start by getting + // the actual loader + ClassLoader apacheResolverLoader = clazz.getClassLoader(); + + // load the base class through this loader. + Class baseResolverClass + = Class.forName(CATALOG_RESOLVER, true, apacheResolverLoader); + + // and find its actual loader + ClassLoader baseResolverLoader + = baseResolverClass.getClassLoader(); + + // We have the loader which is being used to load the + // CatalogResolver. Can it see the ApacheResolver? The + // base resolver will only be able to create the ApacheResolver + // if it can see it - doesn't use the context loader. + clazz = Class.forName(APACHE_RESOLVER, true, baseResolverLoader); + Object obj = clazz.newInstance(); // // Success! The xml-commons resolver library is // available, so use it. // - catalogResolver = new ApacheResolver(clazz, obj); + catalogResolver = new ExternalResolver(clazz, obj); } catch (Throwable ex) { // // The xml-commons resolver library is not @@ -789,7 +816,7 @@ /** * Interface implemented by both the InternalResolver strategy and - * the ApacheResolver strategy. + * the ExternalResolver strategy. */ private interface CatalogResolver extends URIResolver, EntityResolver { @@ -894,13 +921,13 @@ } /** - * The ApacheResolver strategy is used if the Apache resolver + * The ExternalResolver strategy is used if the Apache resolver * library (Norm Walsh's library from xml-commons) is available in - * the classpath. The ApacheResolver is a essentially a superset + * the classpath. The ExternalResolver is a essentially a superset * of the InternalResolver. * */ - private class ApacheResolver implements CatalogResolver { + private class ExternalResolver implements CatalogResolver { private Method setXMLCatalog = null; private Method parseCatalog = null; @@ -912,7 +939,7 @@ private boolean externalCatalogsProcessed = false; - public ApacheResolver(Class resolverImplClass, + public ExternalResolver(Class resolverImplClass, Object resolverImpl) { this.resolverImpl = resolverImpl;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]