ceki 2005/01/05 09:16:11 Modified: src/java/org/apache/log4j/joran/util JoranDocument.java src/java/org/apache/log4j/joran JoranConfigurator.java Log: JoranDocument now conform to the log4j internal logging guidelines. Revision Changes Path 1.5 +21 -11 logging-log4j/src/java/org/apache/log4j/joran/util/JoranDocument.java Index: JoranDocument.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/util/JoranDocument.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- JoranDocument.java 15 Dec 2004 15:14:28 -0000 1.4 +++ JoranDocument.java 5 Jan 2005 17:16:11 -0000 1.5 @@ -20,6 +20,9 @@ import org.apache.log4j.Logger; import org.apache.log4j.helpers.Constants; import org.apache.log4j.spi.ErrorItem; +import org.apache.log4j.spi.LoggerRepository; + +import org.apache.ugli.ULogger; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; @@ -51,9 +54,11 @@ private final List events = new ArrayList(20); private SAXParseException fatalError; private Locator location; + private final LoggerRepository repository; - public JoranDocument(final List errorList) { + public JoranDocument(final List errorList, LoggerRepository repository) { this.errorList = errorList; + this.repository = repository; } public void error(final SAXParseException spe) { @@ -109,7 +114,7 @@ event.replay(handler, replayLocation); } } - + public InputSource resolveEntity( final String publicId, final String systemId) throws SAXException { // @@ -118,32 +123,29 @@ // We aren't validating and do not need anything from // the dtd and do not want a failure if it isn't present. if ((systemId != null) && systemId.endsWith("log4j.dtd")) { - Logger logger = LogManager.getLogger(this.getClass().getName()); - logger.warn("The 'log4j.dtd' is no longer used nor needed."); - logger.warn("See {}#log4j_dtd for more details.", Constants.CODES_HREF); + getLogger().warn("The 'log4j.dtd' is no longer used nor needed."); + getLogger().warn("See {}#log4j_dtd for more details.", Constants.CODES_HREF); return new InputSource(new ByteArrayInputStream(new byte[0])); } - + // If the systemId is not for us to handle, we delegate to our super // class, at leasts that's the basic idea. However, the code below // needs to be more complicated. - // Due to inexplicable voodoo, the original resolveEntity method in // org.xml.sax.helpers.DefaultHandler declares throwing an IOException, // whereas the org.xml.sax.helpers.DefaultHandler class included in // JDK 1.4 masks this exception. In JDK 1.5, the IOException has been // put back... - // In order to compile under JDK 1.4, we are forced to mask the IOException // as well. Since its signatures varies, we cannot call our super class' // resolveEntity method. We are forced to implement the default behavior // ourselves, which in this case, is just returning null. try { return super.resolveEntity(publicId, systemId); - } catch(Exception e) { - if(e instanceof SAXException) { + } catch (Exception e) { + if (e instanceof SAXException) { throw (SAXException) e; - } else if(e instanceof java.io.IOException) { + } else if (e instanceof java.io.IOException) { // fall back to the default "implementation" Logger logger = LogManager.getLogger(this.getClass().getName()); logger.error("Default entity resolver threw an IOException", e); @@ -157,6 +159,14 @@ public void setDocumentLocator(Locator location) { this.location = location; + } + + protected ULogger getLogger() { + if (repository != null) { + return repository.getLogger(this.getClass().getName()); + } else { + return LogManager.SIMPLE_LOGGER_FA.getLogger(this.getClass().getName()); + } } private abstract static class ElementEvent { 1.32 +1 -1 logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java Index: JoranConfigurator.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- JoranConfigurator.java 4 Jan 2005 19:48:37 -0000 1.31 +++ JoranConfigurator.java 5 Jan 2005 17:16:11 -0000 1.32 @@ -148,7 +148,7 @@ return; } - JoranDocument document = new JoranDocument(errorList); + JoranDocument document = new JoranDocument(errorList, repository); try { action.parse(saxParser, document);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]