1 22 package org.jboss.mx.metadata; 23 24 import java.io.InputStream ; 25 26 import org.jboss.logging.Logger; 27 import org.jboss.mx.service.ServiceConstants; 28 import org.xml.sax.EntityResolver ; 29 import org.xml.sax.InputSource ; 30 31 41 public class XMBeanEntityResolver 42 implements EntityResolver , ServiceConstants 43 { 44 private static final Logger log = Logger.getLogger(XMBeanEntityResolver.class); 45 46 public InputSource resolveEntity(String publicId, String systemId) 47 { 48 if (log.isTraceEnabled()) 49 { 50 log.trace("resolveEntity() : publicId=" + publicId + ", systemId=" + systemId); 51 } 52 53 if (publicId == null) 54 { 55 return null; 57 } 58 59 try 60 { 61 if (publicId.equals(PUBLIC_JBOSSMX_XMBEAN_DTD_1_0)) 62 { 63 InputStream dtdStream = getClass().getResourceAsStream("/dtd/" + JBOSSMX_XMBEAN_DTD_1_0); 64 return new InputSource (dtdStream); 65 } 66 else if (publicId.equals(PUBLIC_JBOSSMX_XMBEAN_DTD_1_1)) 67 { 68 InputStream dtdStream = getClass().getResourceAsStream("/dtd/" + JBOSSMX_XMBEAN_DTD_1_1); 69 return new InputSource (dtdStream); 70 } 71 else if (publicId.equals(PUBLIC_JBOSSMX_XMBEAN_DTD_1_2)) 72 { 73 InputStream dtdStream = getClass().getResourceAsStream("/dtd/" + JBOSSMX_XMBEAN_DTD_1_2); 74 return new InputSource (dtdStream); 75 } 76 else 77 { 78 log.warn ("Cannot resolve entity: " + publicId); 79 } 80 } 81 catch (Exception ignore) 82 { 83 log.error ("Cannot load local entity resource for: " + publicId); 84 } 85 return null; 86 } 87 } 88 | Popular Tags |