01: /**
02: * EasyBeans
03: * Copyright (C) 2007 Bull S.A.S.
04: * Contact: easybeans@ow2.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 any 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: * --------------------------------------------------------------------------
22: * $Id: WAREntityResolver.java 2054 2007-11-20 14:43:55Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.deployment.xml.parsing;
25:
26: import java.io.IOException;
27: import java.io.StringReader;
28:
29: import org.ow2.easybeans.util.xml.SchemaEntityResolver;
30: import org.xml.sax.InputSource;
31: import org.xml.sax.SAXException;
32:
33: /**
34: * Entity resolver allowing to find schema within the classloader.
35: * @author Florent Benoit
36: */
37: public class WAREntityResolver extends SchemaEntityResolver implements
38: IEntityResolver {
39:
40: /**
41: * All schemas used by WARs.
42: */
43: public static final String[] WAR_SCHEMAS = new String[] {
44: PREFIX + JSP20_SCHEMA, PREFIX + JSP21_SCHEMA,
45: PREFIX + WEBAPP24_SCHEMA, PREFIX + WEBAPP25_SCHEMA,
46: PREFIX + CLIENT_SCHEMA, PREFIX + JAVAEE5_SCHEMA,
47: PREFIX + J2EE14_SCHEMA,
48: PREFIX + JAVAEE_WEBSERVICES_CLIENT_SCHEMA,
49: PREFIX + J2EE_WEBSERVICES_CLIENT_SCHEMA,
50: PREFIX + XML_SCHEMA };
51:
52: /**
53: * Constructor. Finds the XSD with classloader.
54: */
55: public WAREntityResolver() {
56: super (WAR_SCHEMAS);
57: }
58:
59: /**
60: * The Parser will call this method before opening any external entity
61: * except the top-level document entity.
62: * @param publicId The public identifier of the external entity being
63: * referenced, or null if none was supplied.
64: * @param systemId The system identifier of the external entity being
65: * referenced.
66: * @return An InputSource object describing the new input source, or null to
67: * request that the parser open a regular URI connection to the
68: * system identifier.
69: * @throws SAXException Any SAX exception, possibly wrapping another
70: * exception.
71: * @throws IOException A Java-specific IO exception, possibly the result of
72: * creating a new InputStream or Reader for the InputSource.
73: */
74: @Override
75: public InputSource resolveEntity(final String publicId,
76: final String systemId) throws IOException, SAXException {
77:
78: // Do not validate files
79: return (new InputSource(new StringReader("")));
80: }
81: }
|