1 package org.objectweb.celtix.bus.configuration.spring; 2 3 4 5 6 7 import java.io.IOException ; 8 import java.io.InputStream ; 9 import java.util.logging.Logger ; 10 11 import org.xml.sax.EntityResolver ; 12 import org.xml.sax.InputSource ; 13 14 import org.objectweb.celtix.bus.resource.ResourceManagerImpl; 15 import org.objectweb.celtix.common.i18n.Message; 16 import org.objectweb.celtix.common.logging.LogUtils; 17 import org.objectweb.celtix.configuration.ConfigurationException; 18 19 public class CeltixBeansDtdResolver implements EntityResolver { 20 21 private static final String DTD_SYSTEM_ID = 22 "http://celtix.objectweb.org/configuration/spring/celtix-spring-beans.dtd"; 23 private static final String DTD_FILE = "schemas/configuration/celtix-spring-beans.dtd"; 24 private static final Logger LOG = LogUtils.getL7dLogger(CeltixBeansDtdResolver.class); 25 26 public InputSource resolveEntity(String publicId, String systemId) throws IOException { 27 if (systemId != null && systemId.equals(DTD_SYSTEM_ID)) { 28 InputStream is = ResourceManagerImpl.instance().getResourceAsStream(getDtdFile()); 29 if (is == null) { 30 throw new ConfigurationException(new Message("COULD_NOT_RESOLVE_BEANS_DTD_EXC", LOG, 31 DTD_SYSTEM_ID)); 32 } 33 InputSource source = new InputSource (is); 34 source.setPublicId(publicId); 35 source.setSystemId(systemId); 36 return source; 37 } 38 return null; 40 } 41 42 protected String getDtdFile() { 43 return DTD_FILE; 44 } 45 } 46 | Popular Tags |