1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/api/model/wsdl/WSDLModel.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,196 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.ws.api.model.wsdl; 1.30 + 1.31 + 1.32 +import com.sun.istack.internal.NotNull; 1.33 +import com.sun.xml.internal.ws.api.server.Container; 1.34 +import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension; 1.35 +import com.sun.xml.internal.ws.api.wsdl.parser.XMLEntityResolver; 1.36 +import com.sun.xml.internal.ws.api.policy.PolicyResolver; 1.37 +import com.sun.xml.internal.ws.api.policy.PolicyResolverFactory; 1.38 +import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser; 1.39 +import com.sun.xml.internal.ws.policy.PolicyMap; 1.40 + 1.41 +import org.xml.sax.SAXException; 1.42 + 1.43 +import javax.xml.namespace.QName; 1.44 +import javax.xml.stream.XMLStreamException; 1.45 + 1.46 +import java.io.IOException; 1.47 +import java.util.Map; 1.48 + 1.49 +/** 1.50 + * Provides abstraction of wsdl:definitions. 1.51 + * 1.52 + * @author Vivek Pandey 1.53 + */ 1.54 +public interface WSDLModel extends WSDLExtensible { 1.55 + /** 1.56 + * Gets {@link WSDLPortType} that models <code>wsdl:portType</code> 1.57 + * 1.58 + * @param name non-null quaified name of wsdl:message, where the localName is the value of <code>wsdl:portType@name</code> and 1.59 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.60 + * @return A {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType} or null if no wsdl:portType found. 1.61 + */ 1.62 + WSDLPortType getPortType(@NotNull QName name); 1.63 + 1.64 + /** 1.65 + * Gets {@link WSDLBoundPortType} that models <code>wsdl:binding</code> 1.66 + * 1.67 + * @param name non-null quaified name of wsdl:binding, where the localName is the value of <code>wsdl:binding@name</code> and 1.68 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.69 + * @return A {@link WSDLBoundPortType} or null if no wsdl:binding found 1.70 + */ 1.71 + WSDLBoundPortType getBinding(@NotNull QName name); 1.72 + 1.73 + /** 1.74 + * Give a {@link WSDLBoundPortType} for the given wsdl:service and wsdl:port names. 1.75 + * 1.76 + * @param serviceName service QName 1.77 + * @param portName port QName 1.78 + * @return A {@link WSDLBoundPortType}. null if the Binding for the given wsd:service and wsdl:port name are not 1.79 + * found. 1.80 + */ 1.81 + WSDLBoundPortType getBinding(@NotNull QName serviceName, @NotNull QName portName); 1.82 + 1.83 + /** 1.84 + * Gets {@link WSDLService} that models <code>wsdl:service</code> 1.85 + * 1.86 + * @param name non-null quaified name of wsdl:service, where the localName is the value of <code>wsdl:service@name</code> and 1.87 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.88 + * @return A {@link WSDLService} or null if no wsdl:service found 1.89 + */ 1.90 + WSDLService getService(@NotNull QName name); 1.91 + 1.92 + /** 1.93 + * Gives a {@link Map} of wsdl:portType {@link QName} and {@link WSDLPortType} 1.94 + * 1.95 + * @return an empty Map if the wsdl document has no wsdl:portType 1.96 + */ 1.97 + @NotNull Map<QName, ? extends WSDLPortType> getPortTypes(); 1.98 + 1.99 + /** 1.100 + * Gives a {@link Map} of wsdl:binding {@link QName} and {@link WSDLBoundPortType} 1.101 + * 1.102 + * @return an empty Map if the wsdl document has no wsdl:binding 1.103 + */ 1.104 + @NotNull Map<QName, ? extends WSDLBoundPortType> getBindings(); 1.105 + 1.106 + /** 1.107 + * Gives a {@link Map} of wsdl:service qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLService} 1.108 + * 1.109 + * @return an empty Map if the wsdl document has no wsdl:service 1.110 + */ 1.111 + @NotNull Map<QName, ? extends WSDLService> getServices(); 1.112 + 1.113 + /** 1.114 + * Returns the first service QName from insertion order 1.115 + */ 1.116 + public QName getFirstServiceName(); 1.117 + 1.118 + /** 1.119 + * Returns the message with the given QName 1.120 + * @param name Message name 1.121 + * @return Message 1.122 + */ 1.123 + public WSDLMessage getMessage(QName name); 1.124 + 1.125 + /** 1.126 + * Gives a {@link Map} of wsdl:message qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLMesage} 1.127 + * 1.128 + * @return an empty Map if the wsdl document has no wsdl:message 1.129 + */ 1.130 + @NotNull Map<QName, ? extends WSDLMessage> getMessages(); 1.131 + 1.132 + /** 1.133 + * Gives the PolicyMap associated with the WSDLModel 1.134 + * 1.135 + * @return PolicyMap 1.136 + * 1.137 + * @deprecated 1.138 + * Do not use this method as the PolicyMap API is not final yet and might change in next few months. 1.139 + */ 1.140 + public PolicyMap getPolicyMap(); 1.141 + 1.142 + /** 1.143 + * Main purpose of this class is to parsing of a WSDL and get the {@link WSDLModel} from it. 1.144 + */ 1.145 + public class WSDLParser{ 1.146 + /** 1.147 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.148 + * 1.149 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.150 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.151 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.152 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.153 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.154 + * @throws java.io.IOException 1.155 + * @throws javax.xml.stream.XMLStreamException 1.156 + * @throws org.xml.sax.SAXException 1.157 + */ 1.158 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.159 + return parse(wsdlEntityParser, resolver, isClientSide, Container.NONE, extensions); 1.160 + } 1.161 + 1.162 + /** 1.163 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.164 + * 1.165 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.166 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.167 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.168 + * @param container - container in which the parser is run 1.169 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.170 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.171 + * @throws java.io.IOException 1.172 + * @throws javax.xml.stream.XMLStreamException 1.173 + * @throws org.xml.sax.SAXException 1.174 + */ 1.175 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.176 + return parse(wsdlEntityParser, resolver, isClientSide, container, PolicyResolverFactory.create(),extensions); 1.177 + } 1.178 + 1.179 + 1.180 + /** 1.181 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.182 + * 1.183 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.184 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.185 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.186 + * @param container - container in which the parser is run 1.187 + * @param policyResolver - PolicyResolver for resolving effective Policy 1.188 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.189 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.190 + * @throws java.io.IOException 1.191 + * @throws javax.xml.stream.XMLStreamException 1.192 + * @throws org.xml.sax.SAXException 1.193 + */ 1.194 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.195 + return RuntimeWSDLParser.parse(wsdlEntityParser, resolver, isClientSide, container, policyResolver, extensions); 1.196 + } 1.197 + 1.198 + } 1.199 +}