01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or 1any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * Initial developer: Florent BENOIT
22: * --------------------------------------------------------------------------
23: * $Id: JEntityResolverWithDigester.java 7486 2005-10-07 22:30:10Z glapouch $
24: * --------------------------------------------------------------------------
25: */package org.objectweb.jonas_lib.deployment.digester;
26:
27: import java.io.IOException;
28:
29: import org.objectweb.jonas_lib.deployment.validation.JEntityResolver;
30: import org.xml.sax.EntityResolver;
31: import org.xml.sax.InputSource;
32: import org.xml.sax.SAXException;
33:
34: /**
35: * This class defines the entity resolver used to resolve DTDs/Schemas during
36: * the xml parsing. It extends the JEntityResolver in jonas_lib/deployment/validation
37: * in order to allow for that parser to be used without having the digester classes.
38: */
39: public class JEntityResolverWithDigester extends JEntityResolver
40: implements EntityResolver {
41:
42: /**
43: * JDigester Object associated
44: */
45: private JDigester jDigester = null;
46:
47: /**
48: * Constructor
49: *
50: * @param jd linked JDigester object
51: */
52: public JEntityResolverWithDigester(JDigester jd) {
53: super ();
54: jDigester = jd;
55: }
56:
57: /**
58: * The Parser will call this method before opening any external entity except
59: * the top-level document entity.
60: * @param publicId The public identifier of the external entity being referenced,
61: * or null if none was supplied.
62: * @param systemId The system identifier of the external entity being referenced.
63: * @return An InputSource object describing the new input source, or null to request that
64: * the parser open a regular URI connection to the system identifier.
65: * @throws SAXException Any SAX exception, possibly wrapping another exception.
66: * @throws IOException A Java-specific IO exception, possibly the result of creating
67: * a new InputStream or Reader for the InputSource.
68: */
69: public InputSource resolveEntity(String publicId, String systemId)
70: throws IOException, SAXException {
71:
72: if (jDigester != null) {
73: jDigester.setPublicId(publicId);
74: }
75:
76: return super.resolveEntity(publicId, systemId);
77: }
78: }
|