Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 34719 invoked from network); 2 Jan 2004 23:32:43 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 2 Jan 2004 23:32:43 -0000 Received: (qmail 86658 invoked by uid 500); 2 Jan 2004 23:32:27 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 86508 invoked by uid 500); 2 Jan 2004 23:32:26 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 86495 invoked from network); 2 Jan 2004 23:32:25 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 2 Jan 2004 23:32:25 -0000 Received: (qmail 34693 invoked by uid 1712); 2 Jan 2004 23:32:39 -0000 Date: 2 Jan 2004 23:32:39 -0000 Message-ID: <20040102233239.34692.qmail@minotaur.apache.org> From: djencks@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/core/src/test-data/xml/deployment resolver-catalog.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N djencks 2004/01/02 15:32:39 Modified: modules/core project.xml modules/core/src/conf boot-service.xml modules/core/src/java/org/apache/geronimo/xml/deployment AppClientLoader.java LoaderUtil.java LocalEntityResolver.java StorerUtil.java modules/core/src/test/org/apache/geronimo/security EjbModuleConfigurationTest.java WebModuleConfigurationTest.java modules/core/src/test/org/apache/geronimo/xml/deployment AppClientLoaderTest.java ConnectorLoaderTest.java EjbJarLoaderTest.java EjbJarStorerTest.java EntityResolverTest.java GeronimoAppClientLoaderTest.java GeronimoConnectorLoaderTest.java GeronimoEjbJarLoaderTest.java GeronimoEjbJarStorerTest.java Added: modules/core/src/conf resolver-catalog.xml modules/core/src/test/org/apache/geronimo/xml/deployment AbstractLoaderUtilTest.java modules/core/src/test-data/xml/deployment resolver-catalog.xml Log: Most of Geronimo-133. We will see if it is sufficient Revision Changes Path 1.31 +13 -2 incubator-geronimo/modules/core/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/project.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- project.xml 10 Dec 2003 10:54:07 -0000 1.30 +++ project.xml 2 Jan 2004 23:32:38 -0000 1.31 @@ -150,7 +150,7 @@ true - + geronimo-spec geronimo-spec-servlet @@ -326,6 +326,17 @@ true + + + xml-commons-resolver + xml-commons-resolver + 1.1 + http://xml.apache.org/commons + + true + + + 1.25 +25 -8 incubator-geronimo/modules/core/src/conf/boot-service.xml Index: boot-service.xml =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/src/conf/boot-service.xml,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- boot-service.xml 9 Dec 2003 04:20:48 -0000 1.24 +++ boot-service.xml 2 Jan 2004 23:32:38 -0000 1.25 @@ -9,16 +9,33 @@ + + - - - src/schema - + + ${geronimo.home}/etc/resolver-catalog.xml + + + ${geronimo.home}/etc/xml + + + false - - ${geronimo.home}/etc/resolver.properties - + 1.1 incubator-geronimo/modules/core/src/conf/resolver-catalog.xml Index: resolver-catalog.xml =================================================================== 1.6 +2 -2 incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/AppClientLoader.java Index: AppClientLoader.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/AppClientLoader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AppClientLoader.java 7 Dec 2003 03:39:05 -0000 1.5 +++ AppClientLoader.java 2 Jan 2004 23:32:38 -0000 1.6 @@ -65,7 +65,7 @@ * @version $Revision$ $Date$ */ public class AppClientLoader { - public ApplicationClient load(Document doc) { + public static ApplicationClient load(Document doc) { Element root = doc.getDocumentElement(); if (!"application-client".equals(root.getLocalName())) { throw new IllegalArgumentException("Document is not an application-client instance"); 1.11 +78 -8 incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/LoaderUtil.java Index: LoaderUtil.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/LoaderUtil.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- LoaderUtil.java 1 Jan 2004 22:42:48 -0000 1.10 +++ LoaderUtil.java 2 Jan 2004 23:32:38 -0000 1.11 @@ -64,12 +64,19 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.EntityResolver; + +import org.apache.xerces.parsers.DOMParser; /** * Holds utility methods for parsing a DOM tree. @@ -78,6 +85,14 @@ */ public final class LoaderUtil { + private static final Log log = LogFactory.getLog(LoaderUtil.class); + + private static EntityResolver entityResolver; + + public static void setEntityResolver(EntityResolver entityResolver) { + LoaderUtil.entityResolver = entityResolver; + } + public static String getContent(Element element) { if (element == null) { return null; @@ -89,7 +104,9 @@ Node node = (Node) nodes.removeFirst(); switch (node.getNodeType()) { case Node.ELEMENT_NODE: - for (Node child = node.getLastChild(); child != null; child = child.getPreviousSibling()) { + for (Node child = node.getLastChild(); + child != null; + child = child.getPreviousSibling()) { nodes.addFirst(child); } break; @@ -118,7 +135,9 @@ if (element == null || child == null) { return null; } - for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { + for (Node node = element.getFirstChild(); + node != null; + node = node.getNextSibling()) { if (node instanceof Element == false) { continue; } @@ -143,7 +162,8 @@ LinkedList list = new LinkedList(); for (int i = 0; i < max; i++) { Node n = nl.item(i); - if (n.getNodeType() == Node.ELEMENT_NODE && n.getLocalName().equals(childName)) { + if (n.getNodeType() == Node.ELEMENT_NODE + && n.getLocalName().equals(childName)) { list.add(n); } } @@ -189,19 +209,69 @@ * @throws SAXException if there was a parsing problem * @throws IOException if there was a problem reading the input */ - public static Document parseXML(Reader reader) throws SAXException, IOException { + public static Document parseXML2(Reader reader) + throws SAXException, IOException { + DOMParser parser = new DOMParser(); + parser.setFeature("http://xml.org/sax/features/validation", true); + parser.setFeature( + "http://apache.org/xml/features/validation/schema", + true); + parser.setEntityResolver(entityResolver); + parser.setErrorHandler(new ErrorHandler() { + public void error(SAXParseException exception) + throws SAXException { + log.warn("SAX parse error (ignored)", exception); + //throw exception; + } + + public void fatalError(SAXParseException exception) + throws SAXException { + log.warn("Fatal SAX parse error (ignored)", exception); + //throw exception; + } + + public void warning(SAXParseException exception) + throws SAXException { + log.warn("SAX parse warning", exception); + } + }); + parser.parse(new InputSource(new BufferedReader(reader))); + return parser.getDocument(); + } + + //It looks to me as if this does the same things, but with jaxp. + public static Document parseXML(Reader reader) + throws SAXException, IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(true); - factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", + factory.setAttribute( + "http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); try { DocumentBuilder builder = factory.newDocumentBuilder(); - builder.setEntityResolver(new LocalEntityResolver()); + builder.setEntityResolver(entityResolver); + builder.setErrorHandler(new ErrorHandler() { + public void error(SAXParseException exception) + throws SAXException { + log.warn("SAX parse error (ignored)", exception); + //throw exception; + } + + public void fatalError(SAXParseException exception) + throws SAXException { + log.warn("Fatal SAX parse error (ignored)", exception); + //throw exception; + } + + public void warning(SAXParseException exception) + throws SAXException { + log.warn("SAX parse warning", exception); + } + }); return builder.parse(new InputSource(new BufferedReader(reader))); } catch (ParserConfigurationException e) { throw new AssertionError("Unable to obtain suitable DocumentBuilder"); } } } - 1.6 +341 -120 incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/LocalEntityResolver.java Index: LocalEntityResolver.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/LocalEntityResolver.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- LocalEntityResolver.java 9 Dec 2003 04:19:38 -0000 1.5 +++ LocalEntityResolver.java 2 Jan 2004 23:32:38 -0000 1.6 @@ -57,14 +57,24 @@ import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Hashtable; -import java.util.Properties; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Vector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xml.resolver.Catalog; +import org.apache.xml.resolver.CatalogEntry; +import org.apache.xml.resolver.CatalogException; +import org.apache.xml.resolver.CatalogManager; +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo; +import org.apache.geronimo.kernel.service.GeronimoAttributeInfo; +import org.apache.geronimo.kernel.service.GeronimoOperationInfo; +import org.apache.geronimo.kernel.service.GeronimoParameterInfo; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -72,171 +82,382 @@ /** * Implementation of EntityResolver that looks to the local filesystem. * - * @jmx:mbean + * The implementation tries to resolve an entity via the following steps: + * + *
    + *
  • using a catalog file
  • + *
  • using a local repository
  • + *
  • using JAR files in Classpath
  • + *
+ * + * The catalog resolving is based on the OASIS XML Catalog Standard. + * (see http://www.oasis-open.org/committees/entity/spec-2001-08-01.html + * and http://www.oasis-open.org/html/a401.htm) * * @version $Revision$ $Date$ */ -public class LocalEntityResolver implements EntityResolver, LocalEntityResolverMBean { +public class LocalEntityResolver implements EntityResolver { + + /** + * used Logger + */ private static final Log log = LogFactory.getLog(LocalEntityResolver.class); - private File root; - private String configFile; - private Properties mappings = new Properties(); /** - * @jmx:managed-constructor + * The used Catalog Manager + */ + private final CatalogManager manager = new CatalogManager(); + + /** + * the XML Catalog + */ + private Catalog catalog = null; + + /** + * the URI of the catalog file + */ + private URI catalogFileURI = null; + + /** + * Local Repository where DTDs and Schemas are located + */ + private String localRepository = null; + + /** + * Flag indicating if this resolver may return null to signal + * the parser to open a regular URI connection to the system + * identifier. Otherwise an exception is thrown. + */ + private boolean failOnUnresolvable = false; + + public static GeronimoMBeanInfo getGeronimoMBeanInfo() { + GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo(); + mbeanInfo.setTargetClass(LocalEntityResolver.class); + mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("FailOnUnresolvable", true, true, "Should null be returned or an exception thrown when an entity cannot be resolved")); + mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("LocalRepository", true, true, "Location of dtds and schemas")); + mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("CatalogFile", true, true, "Location of xml catalog file")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("resolveEntity", new GeronimoParameterInfo[]{ + new GeronimoParameterInfo("PublicID", String.class, "PublicID of entity to resolve"), + new GeronimoParameterInfo("SystemID", String.class, "SystemID of entity to resolve")}, + GeronimoOperationInfo.ACTION, + "resolve supplied entity")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("addPublicMapping", new GeronimoParameterInfo[]{ + new GeronimoParameterInfo("PublicID", String.class, "PublicID to map"), + new GeronimoParameterInfo("URI", String.class, "Actual location of dtd/schema")}, + GeronimoOperationInfo.ACTION, + "resolve supplied entity")); + mbeanInfo.addOperationInfo(new GeronimoOperationInfo("addSystemMapping", new GeronimoParameterInfo[]{ + new GeronimoParameterInfo("SystemID", String.class, "SystemID to map"), + new GeronimoParameterInfo("URI", String.class, "Actual location of dtd/schema")}, + GeronimoOperationInfo.ACTION, + "resolve supplied entity")); + mbeanInfo.setAutostart(true); + return mbeanInfo; + } + + public LocalEntityResolver(String catalogFile, String localRepository, boolean failOnUnresolvable) { + setLocalRepository(localRepository); + setFailOnUnresolvable(failOnUnresolvable); + setCatalogFile(catalogFile); + LoaderUtil.setEntityResolver(this); + StorerUtil.setEntityResolver(this); + } + + /** + * Sets the setFailOnUnresolvable flag. + * + * @param b value (true means that a SAXException is thrown + * if the entity could not be resolved) */ - public LocalEntityResolver(File root) { - this.root = root; - log.info("root=" + root); + public void setFailOnUnresolvable(final boolean b) { + failOnUnresolvable = b; + } + + public boolean isFailOnUnresolvable() { + return failOnUnresolvable; } - public LocalEntityResolver() { - root = null; + public void setCatalogFile(final String catalogFile) { + + try { + URL url = new URL(catalogFile); + this.catalogFileURI = new URI(url.toExternalForm()); + } catch (MalformedURLException e) { + throw new IllegalArgumentException("could not parse url: " + catalogFile); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("could not parse url: " + catalogFile); + } + init(); } - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - InputSource is = null; + public String getCatalogFile() { + if (catalogFileURI != null) { + return this.catalogFileURI.toString(); + } + return null; + } + + public String getLocalRepository() { + return localRepository; + } + + public void setLocalRepository(String string) { + localRepository = string; + } + + public void addPublicMapping(final String publicId, final String uri) { + + Vector args = new Vector(); + args.add(publicId); + args.add(uri); + + addEntry("PUBLIC", args); + + } + + public void addSystemMapping(final String systemId, final String uri) { + + Vector args = new Vector(); + args.add(systemId); + args.add(uri); + + addEntry("SYSTEM", args); + + } + + /** + * Attempt to resolve the entity based on the supplied publicId and systemId. + * First the catalog is queried with both publicId and systemId. + * Then the local repository is queried with the file name part of the systemId + * Then the classpath is queried with the file name part of the systemId. + * + * Then, if failOnUnresolvable is true, an exception is thrown: otherwise null is returned. + * @param publicId + * @param systemId + * @return + * @throws SAXException + * @throws IOException + */ + public InputSource resolveEntity( + final String publicId, + final String systemId) + throws SAXException, IOException { + + if (log.isTraceEnabled()) { + log.trace( + "start resolving for " + + entityMessageString(publicId, systemId)); + } + + InputSource source = resolveWithCatalog(publicId, systemId); + if (source != null) { + return source; + } + + source = resolveWithRepository(publicId, systemId); + if (source != null) { + return source; + } + + source = resolveWithClasspath(publicId, systemId); + if (source != null) { + return source; + } + + String message = + "could not resolve " + entityMessageString(publicId, systemId); + + if (failOnUnresolvable) { + throw new SAXException(message); + } else { + log.debug(message); + } - is = resolveEntityLocally(publicId, systemId); - if (is != null) { - return is; - } - if (publicId != null || systemId == null) { - if (log.isDebugEnabled()) { - log.debug("Not attempting to locally resolve entity S=" + systemId + " P=" + publicId); + return null; + } + + /** + * Try to resolve using the catalog file + * + * @param publicId the PublicId + * @param systemId the SystemId + * @return InputSource if the entity could be resolved. null otherwise + * @throws MalformedURLException + * @throws IOException + */ + private InputSource resolveWithCatalog( + final String publicId, + final String systemId) + throws MalformedURLException, IOException { + + if (catalogFileURI == null) { + return null; + } + + String resolvedSystemId = + catalog.resolvePublic(guaranteeNotNull(publicId), systemId); + + if (resolvedSystemId != null) { + if (log.isTraceEnabled()) { + log.trace( + "resolved " + + entityMessageString(publicId, systemId) + + " using the catalog file. result: " + + resolvedSystemId); } + return new InputSource(resolvedSystemId); + } + + return null; + } + + /** + * Try to resolve using the local repository and only the supplied systemID filename. + * Any path in the systemID will be removed. + * + * @param publicId the PublicId + * @param systemId the SystemId + * @return InputSource if the entity could be resolved. null otherwise + */ + private InputSource resolveWithRepository( + final String publicId, + final String systemId) { + + if (localRepository == null) { return null; } - String message = null; - if (log.isDebugEnabled()) { - message = "Resolving entity S=" + systemId + " P=" + publicId + ": "; + + String fileName = getSystemIdFileName(systemId); + + if (fileName == null) { + return null; } - int index = systemId.lastIndexOf("/"); - String fileName = systemId.substring(index + 1); - if (root != null) { - File file = new File(root, fileName); - if (file.exists()) { - if (log.isDebugEnabled()) { - log.debug(message + "found file relative to " + root); - } - is = new InputSource(new BufferedInputStream(new FileInputStream(file))); - is.setSystemId(systemId); - return is; + + String resolvedSystemId = null; + + File file = new File(localRepository, fileName); + if (file.exists()) { + resolvedSystemId = file.getAbsolutePath(); + if (log.isTraceEnabled()) { + log.trace( + "resolved " + + entityMessageString(publicId, systemId) + + "with file relative to " + + localRepository + + resolvedSystemId); } + return new InputSource(resolvedSystemId); + } + return null; + } + + /** + * Try to resolve using the the classpath and only the supplied systemID. + * Any path in the systemID will be removed. + * + * @param publicId the PublicId + * @param systemId the SystemId + * @return InputSource if the entity could be resolved. null otherwise + */ + private InputSource resolveWithClasspath( + final String publicId, + final String systemId) { + + String fileName = getSystemIdFileName(systemId); + + if (fileName == null) { + return null; } - InputStream in = getClass().getClassLoader().getResourceAsStream(fileName); + + InputStream in = + getClass().getClassLoader().getResourceAsStream(fileName); if (in != null) { - if (log.isDebugEnabled()) { - log.debug(message + "found file on classpath"); + if (log.isTraceEnabled()) { + log.trace( + "resolved " + + entityMessageString(publicId, systemId) + + " via file found file on classpath: " + + fileName); } - is = new InputSource(new BufferedInputStream(in)); + InputSource is = new InputSource(new BufferedInputStream(in)); is.setSystemId(systemId); return is; } - if (log.isDebugEnabled()) { - log.debug(message + "not found"); - } + return null; } /** - * @jmx:managed-attribute + * Guarantees a not null value */ - public void setConfigFile(String configFile) { - this.configFile = configFile; - init(); + private String guaranteeNotNull(final String string) { + return string != null ? string : ""; } /** - * @jmx:managed-attribute + * Returns the SystemIds filename + * + * @param systemId SystemId + * @return filename */ - public String getConfigFile() { - return this.configFile; + private String getSystemIdFileName(final String systemId) { + + if (systemId == null) { + return null; + } + + int indexBackSlash = systemId.lastIndexOf(File.separator); + int indexSlash = systemId.lastIndexOf("/"); + + int index = Math.max(indexBackSlash, indexSlash); + + String fileName = systemId.substring(index + 1); + return fileName; } /** - * @jmx:managed-operation + * Constructs a debugging message string */ - public void addMapping(String publicId, String systemId) { - if ( publicId == null || systemId == null ) - { - if (log.isDebugEnabled()) { - log.debug("publicId or systemId are null"); - } - return; - } - if (log.isDebugEnabled()) { - log.debug("Adding entity P=" + publicId + " and its S=" + systemId); - } - mappings.put(publicId, systemId); + private String entityMessageString( + final String publicId, + final String systemId) { + + StringBuffer buffer = new StringBuffer("entity with publicId '"); + buffer.append(publicId); + buffer.append("' and systemId '"); + buffer.append(systemId); + buffer.append("'"); + return buffer.toString(); + } /** - * Resolve entities locally. - * - * TODO: Look for the systemIds in jar(s) beside their file representatives - * - * @param publicId - * @param systemId - * @return input source of the local representative of systemId - * @throws SAXException - * @throws IOException + * Adds a new Entry to the catalog */ - private InputSource resolveEntityLocally(String publicId, String systemId) throws SAXException, IOException { - System.out.println("publicId: " + publicId + ", systemId: " + systemId); - if ( publicId == null || publicId.length() == 0) - { - if (log.isDebugEnabled()) { - log.debug("publicId is null or empty; skipping resolving"); - } - return null; - } - if (log.isDebugEnabled()) { - log.debug("Resolving entity locally S=" + systemId + " P=" + publicId); - } - String publicIdPath = (String) mappings.get(publicId); - if (publicIdPath != null && publicIdPath.length() != 0) { - File file = new File(publicIdPath); - if (file.exists()) { - if (log.isDebugEnabled()) { - log.debug("found file: " + publicIdPath); - } - InputSource is = new InputSource(new BufferedInputStream(new FileInputStream(file))); - is.setSystemId(systemId); - return is; - } + private void addEntry(String type, Vector args) { + try { + CatalogEntry entry = new CatalogEntry(type, args); + catalog.addEntry(entry); + } catch (CatalogException e) { + throw new RuntimeException(e); } - return null; } /** * Loads mappings from configuration file */ private void init() { - mappings.clear(); - try { - if (this.configFile == null || this.configFile.length() == 0) { - if (log.isDebugEnabled()) { - log.debug("No configuration file provided"); - } - return; - } - if (log.isDebugEnabled()) { - log.debug("Loading configuration file=" + this.configFile); - } - mappings.load(new BufferedInputStream(new FileInputStream(this.configFile))); - } catch (IOException ioe) { - if (log.isDebugEnabled()) { - log.debug("Exception occured: " + ioe.getMessage() + "; ignore it"); - } + + if (log.isDebugEnabled()) { + log.debug("init catalog file " + this.catalogFileURI); } - } - /** - * @jmx:managed-operation - */ - public Hashtable showMappings() { - return mappings; + manager.setUseStaticCatalog(false); + manager.setCatalogFiles(this.catalogFileURI.toString()); + manager.setIgnoreMissingProperties(true); + catalog = manager.getCatalog(); + } + } 1.2 +27 -18 incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/StorerUtil.java Index: StorerUtil.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/StorerUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- StorerUtil.java 1 Oct 2003 19:03:40 -0000 1.1 +++ StorerUtil.java 2 Jan 2004 23:32:38 -0000 1.2 @@ -57,6 +57,7 @@ import java.io.Writer; import java.util.Properties; + import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.Transformer; @@ -66,10 +67,12 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.ParserConfigurationException; + import org.w3c.dom.Element; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.w3c.dom.Node; +import org.xml.sax.EntityResolver; /** * Holds utility methods for writing to a DOM tree @@ -77,6 +80,8 @@ * @version $Revision$ $Date$ */ public class StorerUtil { + private static EntityResolver entityResolver; + /** * Creates a new child of the specified element, adds it as a child, and * returns it. @@ -114,9 +119,9 @@ * @param parent The parent element for the new child * @param name The name of the new child element * @param value The text to set on the new element - */ + */ public static void createOptionalChildText(Element parent, String name, String value) { - if(value == null || value.equals("")) + if (value == null || value.equals("")) return; Element child = parent.getOwnerDocument().createElement(name); parent.appendChild(child); @@ -153,7 +158,7 @@ fac.setNamespaceAware(true); fac.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); DocumentBuilder builder = fac.newDocumentBuilder(); - builder.setEntityResolver(new LocalEntityResolver()); + builder.setEntityResolver(entityResolver); return builder.newDocument(); } @@ -162,18 +167,18 @@ */ public static void setText(Element e, String s) { boolean cdata = s != null && (s.indexOf('>') > -1 || - s.indexOf('<') > -1 || - s.indexOf('&') > -1); + s.indexOf('<') > -1 || + s.indexOf('&') > -1); NodeList nl = e.getChildNodes(); boolean found = false; int max = nl.getLength(); - if(cdata) { - for(int i=0; i. * * ==================================================================== */ package org.apache.geronimo.xml.deployment; import java.io.File; import junit.framework.TestCase; /** * @version $Revision: 1.1 $ $Date: 2004/01/02 23:32:39 $ */ public abstract class AbstractLoaderUtilTest extends TestCase { private static final File repoDir = new File("src/schema"); private static final File docDir = new File("src/test-data/xml/deployment"); private static final File catalogFile = new File(docDir, "resolver-catalog.xml"); protected LocalEntityResolver resolver; protected void setUp() throws Exception { setUp(catalogFile.toURI().toString(), repoDir.toURI().toString()); resolver.setFailOnUnresolvable(false); } protected void setUp(String catalogFile, String docDirectory) { resolver = new LocalEntityResolver(catalogFile, docDirectory, true); } /** * @see junit.framework.TestCase#tearDown() */ protected void tearDown() throws Exception { resolver = null; LoaderUtil.setEntityResolver(null); StorerUtil.setEntityResolver(null); } } 1.1 incubator-geronimo/modules/core/src/test-data/xml/deployment/resolver-catalog.xml Index: resolver-catalog.xml ===================================================================