ceki 01/08/14 11:39:12
Modified: docs HISTORY
src/java/org/apache/log4j/xml DOMConfigurator.java
Log:
Enclosed is a modified version of DOMConfigurator.java, based on the current
CVS version 1.27. This modified version supports java.io.Reader objects in
the method doConfigure(), instead of only InputStream.
org.xml.sax.InputSource supports a constructor which takes a Reader object,
so the change is very simple:
- modified the existing doConfigure(InputStream, Hierarchy) method to
doConfigure(InputSource, Hierarchy) and made it protected instead of public.
- created a new public version of doConfigure(InputStream,Hierarchy) which
calls doConfigure(InputSource, Hierarchy).
- created a new public method, doConfigure(Reader, Hierarchy), which calls
doConfigure(InputSource, Hierarchy).
That's it. I needed this modification because I have a case where the xml
configuration data is coming from a string, not a file. So I need to use
the java.io.StringReader class to wrap the existing string.
Submitted by: Mark Womack
Reviewed by: Celo
Revision Changes Path
1.58 +5 -0 jakarta-log4j/docs/HISTORY
Index: HISTORY
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- HISTORY 2001/08/09 20:16:30 1.57
+++ HISTORY 2001/08/14 18:39:12 1.58
@@ -36,6 +36,11 @@
deprecated methods. They have become totally redundant after we
moved to JavaBeans style configuration in log4j 1.1.
+ - Added supports java.io.Reader objects in the method doConfigure(),
+ instead of only InputStream. Thanks to Mark Womack for submitting
+ the relevant patch. [*]
+
+
June 19, 2001
- Release of version 1.1.3
1.28 +26 -2 jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
Index: DOMConfigurator.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- DOMConfigurator.java 2001/08/06 20:21:01 1.27
+++ DOMConfigurator.java 2001/08/14 18:39:12 1.28
@@ -33,13 +33,16 @@
import org.xml.sax.InputSource;
import java.io.FileInputStream;
import java.io.InputStream;
+import java.io.Reader;
import java.io.IOException;
import java.net.URL;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.FactoryConfigurationError;
+// Contributors: Mark Womack <[EMAIL PROTECTED]>
+
/**
Use this class to initialize the log4j environment using a DOM tree.
@@ -594,6 +597,28 @@
public
void doConfigure(InputStream inputStream, Hierarchy hierarchy)
throws FactoryConfigurationError {
+ doConfigure(new InputSource(inputStream), hierarchy);
+ }
+
+ /**
+ Configure log4j by reading in a log4j.dtd compliant XML
+ configuration file.
+
+ */
+ public
+ void doConfigure(Reader reader, Hierarchy hierarchy)
+ throws FactoryConfigurationError {
+ doConfigure(new InputSource(reader), hierarchy);
+ }
+
+ /**
+ Configure log4j by reading in a log4j.dtd compliant XML
+ configuration file.
+
+ */
+ protected
+ void doConfigure(InputSource inputSource, Hierarchy hierarchy)
+ throws FactoryConfigurationError {
DocumentBuilderFactory dbf = null;
try {
LogLog.debug("System property is :"+
@@ -616,7 +641,6 @@
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
//docBuilder.setErrorHandler(new ReportParserError());
- InputSource inputSource = new InputSource(inputStream);
Class clazz = this.getClass();
URL dtdURL = clazz.getResource("/org/apache/log4j/xml/log4j.dtd");
if(dtdURL == null) {
@@ -631,7 +655,7 @@
parse(doc.getDocumentElement(), hierarchy);
} catch (Exception e) {
// I know this is miserable...
- LogLog.error("Could not parse input stream ["+inputStream+"].", e);
+ LogLog.error("Could not parse input source ["+inputSource+"].", e);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]