Author: scabanovich
Date: 2010-09-08 07:09:24 -0400 (Wed, 08 Sep 2010)
New Revision: 24810
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
Log:
https://jira.jboss.org/browse/JBIDE-7026
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-08
10:13:45 UTC (rev 24809)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/impl/MetaLibLoader.java 2010-09-08
11:09:24 UTC (rev 24810)
@@ -28,6 +28,7 @@
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLInputSource;
+import org.eclipse.core.runtime.Platform;
import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
@@ -35,6 +36,7 @@
import org.jboss.tools.common.xml.XMLEntityResolver;
import org.jboss.tools.common.xml.XMLEntityResolverImpl;
import org.jboss.tools.common.xml.XMLUtilities;
+import org.osgi.framework.Bundle;
public class MetaLibLoader {
public static String DOC_PUBLICID = "-//Red Hat, Inc.//DTD Meta 1.0//EN";
//$NON-NLS-1$
@@ -249,14 +251,40 @@
ModelPlugin.getPluginLog().logError(e);
}
}
+
+ XMLReader newInstance() throws SAXException {
+ Bundle b = Platform.getBundle("org.apache.xerces");
+ if(b == null) {
+ System.out.println("Cannot find plugin org.apache.xerces");
+ throw new SAXException("Cannot find plugin org.apache.xerces");
+ }
+ try {
+ return (XMLReader) b.loadClass(DEFAULT_SAX_PARSER_CLASS_NAME).newInstance();
+ } catch (ClassNotFoundException e1) {
+ throw new SAXException("SAX2 driver class " +
DEFAULT_SAX_PARSER_CLASS_NAME +
+ " not found", e1);
+ } catch (IllegalAccessException e2) {
+ throw new SAXException("SAX2 driver class " +
DEFAULT_SAX_PARSER_CLASS_NAME +
+ " found but cannot be loaded", e2);
+ } catch (InstantiationException e3) {
+ throw new SAXException("SAX2 driver class " +
DEFAULT_SAX_PARSER_CLASS_NAME +
+ " loaded but cannot be instantiated (no empty public constructor?)",
+ e3);
+ } catch (ClassCastException e4) {
+ throw new SAXException("SAX2 driver class " +
DEFAULT_SAX_PARSER_CLASS_NAME +
+ " does not implement XMLReader", e4);
+ }
+ }
XMLReader createParser() {
DefaultHandler handler = new DefaultHandler();
XMLReader parserInstance = null;
try {
- parserInstance =
XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME);
+ parserInstance = newInstance();
+ //XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME);
} catch (SAXException e) {
+ System.out.println("default parser failed: " + e.getMessage());
return null;
}