1 16 17 package org.apache.log4j.xml; 18 19 import java.io.InputStream ; 20 import java.io.ByteArrayOutputStream ; 21 import java.io.ByteArrayInputStream ; 22 import java.io.IOException ; 23 24 import org.xml.sax.EntityResolver ; 25 import org.xml.sax.InputSource ; 26 27 import org.apache.log4j.helpers.LogLog; 28 29 36 public class Log4jEntityResolver implements EntityResolver { 37 38 public InputSource resolveEntity (String publicId, String systemId) { 39 if (systemId.endsWith("log4j.dtd")) { 40 Class clazz = getClass(); 41 InputStream in = clazz.getResourceAsStream("/org/apache/log4j/xml/log4j.dtd"); 42 if (in == null) { 43 LogLog.error("Could not find [log4j.dtd]. Used [" + clazz.getClassLoader() 44 + "] class loader in the search."); 45 return null; 46 } else { 47 return new InputSource (in); 48 } 49 } else { 50 return null; 51 } 52 } 53 } 54 | Popular Tags |