001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: package com.sun.tools.internal.ws.processor.config.parser;
026:
027: import java.io.IOException;
028: import java.util.HashSet;
029: import java.util.Set;
030:
031: import javax.xml.parsers.DocumentBuilder;
032: import javax.xml.parsers.DocumentBuilderFactory;
033: import javax.xml.parsers.FactoryConfigurationError;
034: import javax.xml.parsers.ParserConfigurationException;
035:
036: import org.w3c.dom.Document;
037: import org.w3c.dom.Element;
038: import org.xml.sax.ErrorHandler;
039: import org.xml.sax.InputSource;
040: import org.xml.sax.SAXException;
041: import org.xml.sax.SAXParseException;
042:
043: import com.sun.tools.internal.ws.processor.util.ProcessorEnvironment;
044: import com.sun.tools.internal.ws.util.xml.NullEntityResolver;
045: import com.sun.tools.internal.ws.wsdl.framework.ParseException;
046:
047: /**
048: * @author Vivek Pandey
049: *
050: * External jaxws:bindings parser
051: */
052: public class JAXWSBindingInfoParser {
053:
054: private ProcessorEnvironment env;
055:
056: /**
057: * @param env
058: */
059: public JAXWSBindingInfoParser(ProcessorEnvironment env) {
060: this .env = env;
061: }
062:
063: public Document parse(InputSource source) {
064: try {
065: DocumentBuilderFactory builderFactory = DocumentBuilderFactory
066: .newInstance();
067: builderFactory.setNamespaceAware(true);
068: builderFactory.setValidating(false);
069: DocumentBuilder builder = builderFactory
070: .newDocumentBuilder();
071: builder.setErrorHandler(new ErrorHandler() {
072: public void error(SAXParseException e)
073: throws SAXParseException {
074: throw e;
075: }
076:
077: public void fatalError(SAXParseException e)
078: throws SAXParseException {
079: throw e;
080: }
081:
082: public void warning(SAXParseException err)
083: throws SAXParseException {
084: // do nothing
085: }
086: });
087:
088: builder.setEntityResolver(new NullEntityResolver());
089: return builder.parse(source);
090: } catch (ParserConfigurationException e) {
091: throw new ParseException("parsing.parserConfigException", e);
092: } catch (FactoryConfigurationError e) {
093: throw new ParseException("parsing.factoryConfigException",
094: e);
095: } catch (SAXException e) {
096: throw new ParseException("parsing.saxException", e);
097: } catch (IOException e) {
098: throw new ParseException("parsing.saxException", e);
099: }
100: }
101:
102: public final Set<Element> outerBindings = new HashSet<Element>();
103: }
|