| /* |
| * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| * |
| * This code is free software; you can redistribute it and/or modify it |
| * under the terms of the GNU General Public License version 2 only, as |
| * published by the Free Software Foundation. Sun designates this |
| * particular file as subject to the "Classpath" exception as provided |
| * by Sun in the LICENSE file that accompanied this code. |
| * |
| * This code is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| * version 2 for more details (a copy is included in the LICENSE file that |
| * accompanied this code). |
| * |
| * You should have received a copy of the GNU General Public License version |
| * 2 along with this work; if not, write to the Free Software Foundation, |
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| * |
| * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| * CA 95054 USA or visit www.sun.com if you need additional information or |
| * have any questions. |
| */ |
| package com.sun.tools.internal.ws.processor.config.parser; |
| |
| import java.io.IOException; |
| import java.util.HashSet; |
| import java.util.Set; |
| |
| import javax.xml.parsers.DocumentBuilder; |
| import javax.xml.parsers.DocumentBuilderFactory; |
| import javax.xml.parsers.FactoryConfigurationError; |
| import javax.xml.parsers.ParserConfigurationException; |
| |
| import org.w3c.dom.Document; |
| import org.w3c.dom.Element; |
| import org.xml.sax.ErrorHandler; |
| import org.xml.sax.InputSource; |
| import org.xml.sax.SAXException; |
| import org.xml.sax.SAXParseException; |
| |
| import com.sun.tools.internal.ws.processor.util.ProcessorEnvironment; |
| import com.sun.tools.internal.ws.util.xml.NullEntityResolver; |
| import com.sun.tools.internal.ws.wsdl.framework.ParseException; |
| |
| /** |
| * @author Vivek Pandey |
| * |
| * External jaxws:bindings parser |
| */ |
| public class JAXWSBindingInfoParser { |
| |
| private ProcessorEnvironment env; |
| |
| /** |
| * @param env |
| */ |
| public JAXWSBindingInfoParser(ProcessorEnvironment env) { |
| this.env = env; |
| } |
| |
| public Document parse(InputSource source) { |
| try { |
| DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); |
| builderFactory.setNamespaceAware(true); |
| builderFactory.setValidating(false); |
| DocumentBuilder builder = builderFactory.newDocumentBuilder(); |
| builder.setErrorHandler(new ErrorHandler() { |
| public void error(SAXParseException e) |
| throws SAXParseException { |
| throw e; |
| } |
| |
| public void fatalError(SAXParseException e) |
| throws SAXParseException { |
| throw e; |
| } |
| |
| public void warning(SAXParseException err) |
| throws SAXParseException { |
| // do nothing |
| } |
| }); |
| |
| builder.setEntityResolver(new NullEntityResolver()); |
| return builder.parse(source); |
| } catch (ParserConfigurationException e) { |
| throw new ParseException("parsing.parserConfigException",e); |
| } catch (FactoryConfigurationError e) { |
| throw new ParseException("parsing.factoryConfigException",e); |
| }catch(SAXException e){ |
| throw new ParseException("parsing.saxException",e); |
| }catch(IOException e){ |
| throw new ParseException("parsing.saxException",e); |
| } |
| } |
| |
| public final Set<Element> outerBindings = new HashSet<Element>(); |
| } |