1 package com.jdon.controller.config; 2 3 import java.net.URL ; 4 import org.xml.sax.EntityResolver ; 5 import org.xml.sax.SAXException ; 6 import java.io.InputStream ; 7 import java.io.IOException ; 8 import org.xml.sax.InputSource ; 9 10 public class DTDEntityResolver implements EntityResolver { 11 13 public InputSource resolveEntity(String publicId, String systemId) throws 14 SAXException , IOException { 15 if (systemId == null) { 16 return null; 17 } 18 19 URL url = new URL (systemId); 20 String file = url.getFile(); 21 22 if ( (file != null) && (file.indexOf('/') > -1)) { 23 file = file.substring(file.lastIndexOf('/') + 1); 24 } 25 26 if ("www.jdon.com".equals(url.getHost())) { 27 InputStream is = getClass().getResourceAsStream("/META-INF/" + file); 28 29 if (is == null) { 30 is = getClass().getResourceAsStream("/" + file); 31 } 32 33 if (is != null) { 34 return new InputSource (is); 35 } 36 } 37 38 return null; 39 } 40 } 41 | Popular Tags |