1 16 package org.springframework.webflow.engine.builder.xml; 17 18 import java.io.IOException ; 19 20 import org.springframework.core.io.ClassPathResource; 21 import org.springframework.core.io.Resource; 22 import org.xml.sax.EntityResolver ; 23 import org.xml.sax.InputSource ; 24 import org.xml.sax.SAXException ; 25 26 43 public class WebFlowEntityResolver implements EntityResolver { 44 45 private static final String WEBFLOW_ELEMENT = "spring-webflow-1.0"; 46 47 public InputSource resolveEntity(String publicId, String systemId) throws SAXException , IOException { 48 if (systemId != null && systemId.indexOf(WEBFLOW_ELEMENT) > systemId.lastIndexOf("/")) { 49 String filename = systemId.substring(systemId.indexOf(WEBFLOW_ELEMENT)); 50 try { 51 Resource resource = new ClassPathResource(filename, getClass()); 52 InputSource source = new InputSource (resource.getInputStream()); 53 source.setPublicId(publicId); 54 source.setSystemId(systemId); 55 return source; 56 } 57 catch (IOException ex) { 58 } 60 } 61 return null; 63 } 64 } | Popular Tags |