01: package org.objectweb.celtix.bus.configuration.spring;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.util.logging.Logger;
06:
07: import org.xml.sax.EntityResolver;
08: import org.xml.sax.InputSource;
09:
10: import org.objectweb.celtix.bus.resource.ResourceManagerImpl;
11: import org.objectweb.celtix.common.i18n.Message;
12: import org.objectweb.celtix.common.logging.LogUtils;
13: import org.objectweb.celtix.configuration.ConfigurationException;
14:
15: public class CeltixBeansDtdResolver implements EntityResolver {
16:
17: private static final String DTD_SYSTEM_ID = "http://celtix.objectweb.org/configuration/spring/celtix-spring-beans.dtd";
18: private static final String DTD_FILE = "schemas/configuration/celtix-spring-beans.dtd";
19: private static final Logger LOG = LogUtils
20: .getL7dLogger(CeltixBeansDtdResolver.class);
21:
22: public InputSource resolveEntity(String publicId, String systemId)
23: throws IOException {
24: if (systemId != null && systemId.equals(DTD_SYSTEM_ID)) {
25: InputStream is = ResourceManagerImpl.instance()
26: .getResourceAsStream(getDtdFile());
27: if (is == null) {
28: throw new ConfigurationException(new Message(
29: "COULD_NOT_RESOLVE_BEANS_DTD_EXC", LOG,
30: DTD_SYSTEM_ID));
31: }
32: InputSource source = new InputSource(is);
33: source.setPublicId(publicId);
34: source.setSystemId(systemId);
35: return source;
36: }
37: // Use the default behavior -> download from website or wherever.
38: return null;
39: }
40:
41: protected String getDtdFile() {
42: return DTD_FILE;
43: }
44: }
|