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 Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,176 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2010, 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 +import org.xml.sax.SAXException; 1.41 + 1.42 +import javax.xml.namespace.QName; 1.43 +import javax.xml.stream.XMLStreamException; 1.44 +import java.io.IOException; 1.45 +import java.util.Map; 1.46 + 1.47 +/** 1.48 + * Provides abstraction of wsdl:definitions. 1.49 + * 1.50 + * @author Vivek Pandey 1.51 + */ 1.52 +public interface WSDLModel extends WSDLExtensible { 1.53 + /** 1.54 + * Gets {@link WSDLPortType} that models <code>wsdl:portType</code> 1.55 + * 1.56 + * @param name non-null quaified name of wsdl:message, where the localName is the value of <code>wsdl:portType@name</code> and 1.57 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.58 + * @return A {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLPortType} or null if no wsdl:portType found. 1.59 + */ 1.60 + WSDLPortType getPortType(@NotNull QName name); 1.61 + 1.62 + /** 1.63 + * Gets {@link WSDLBoundPortType} that models <code>wsdl:binding</code> 1.64 + * 1.65 + * @param name non-null quaified name of wsdl:binding, where the localName is the value of <code>wsdl:binding@name</code> and 1.66 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.67 + * @return A {@link WSDLBoundPortType} or null if no wsdl:binding found 1.68 + */ 1.69 + WSDLBoundPortType getBinding(@NotNull QName name); 1.70 + 1.71 + /** 1.72 + * Give a {@link WSDLBoundPortType} for the given wsdl:service and wsdl:port names. 1.73 + * 1.74 + * @param serviceName service QName 1.75 + * @param portName port QName 1.76 + * @return A {@link WSDLBoundPortType}. null if the Binding for the given wsd:service and wsdl:port name are not 1.77 + * found. 1.78 + */ 1.79 + WSDLBoundPortType getBinding(@NotNull QName serviceName, @NotNull QName portName); 1.80 + 1.81 + /** 1.82 + * Gets {@link WSDLService} that models <code>wsdl:service</code> 1.83 + * 1.84 + * @param name non-null quaified name of wsdl:service, where the localName is the value of <code>wsdl:service@name</code> and 1.85 + * the namespaceURI is the value of wsdl:definitions@targetNamespace 1.86 + * @return A {@link WSDLService} or null if no wsdl:service found 1.87 + */ 1.88 + WSDLService getService(@NotNull QName name); 1.89 + 1.90 + /** 1.91 + * Gives a {@link Map} of wsdl:portType {@link QName} and {@link WSDLPortType} 1.92 + * 1.93 + * @return an empty Map if the wsdl document has no wsdl:portType 1.94 + */ 1.95 + @NotNull Map<QName, ? extends WSDLPortType> getPortTypes(); 1.96 + 1.97 + /** 1.98 + * Gives a {@link Map} of wsdl:binding {@link QName} and {@link WSDLBoundPortType} 1.99 + * 1.100 + * @return an empty Map if the wsdl document has no wsdl:binding 1.101 + */ 1.102 + @NotNull Map<QName, WSDLBoundPortType> getBindings(); 1.103 + 1.104 + /** 1.105 + * Gives a {@link Map} of wsdl:service qualified name and {@link com.sun.xml.internal.ws.api.model.wsdl.WSDLService} 1.106 + * 1.107 + * @return an empty Map if the wsdl document has no wsdl:service 1.108 + */ 1.109 + @NotNull Map<QName, ? extends WSDLService> getServices(); 1.110 + 1.111 + /** 1.112 + * Gives the PolicyMap associated with the WSDLModel 1.113 + * 1.114 + * @return PolicyMap 1.115 + * 1.116 + * @deprecated 1.117 + * Do not use this method as the PolicyMap API is not final yet and might change in next few months. 1.118 + */ 1.119 + public PolicyMap getPolicyMap(); 1.120 + 1.121 + 1.122 + /** 1.123 + * Main purpose of this class is to parsing of a WSDL and get the {@link WSDLModel} from it. 1.124 + */ 1.125 + public class WSDLParser{ 1.126 + /** 1.127 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.128 + * 1.129 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.130 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.131 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.132 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.133 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.134 + * @throws java.io.IOException 1.135 + * @throws javax.xml.stream.XMLStreamException 1.136 + * @throws org.xml.sax.SAXException 1.137 + */ 1.138 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.139 + return parse(wsdlEntityParser, resolver, isClientSide, Container.NONE, extensions); 1.140 + } 1.141 + 1.142 + /** 1.143 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.144 + * 1.145 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.146 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.147 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.148 + * @param container - container in which the parser is run 1.149 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.150 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.151 + * @throws java.io.IOException 1.152 + * @throws javax.xml.stream.XMLStreamException 1.153 + * @throws org.xml.sax.SAXException 1.154 + */ 1.155 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.156 + return parse(wsdlEntityParser, resolver, isClientSide, container, PolicyResolverFactory.create(),extensions); 1.157 + } 1.158 + 1.159 + 1.160 + /** 1.161 + * Parses WSDL from the given wsdlLoc and gives a {@link WSDLModel} built from it. 1.162 + * 1.163 + * @param wsdlEntityParser Works like an entityResolver to resolve WSDLs 1.164 + * @param resolver {@link XMLEntityResolver}, works at XML infoset level 1.165 + * @param isClientSide true - its invoked on the client, false means its invoked on the server 1.166 + * @param container - container in which the parser is run 1.167 + * @param policyResolver - PolicyResolver for resolving effective Policy 1.168 + * @param extensions var args of {@link com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension}s 1.169 + * @return A {@link WSDLModel} built from the given wsdlLocation} 1.170 + * @throws java.io.IOException 1.171 + * @throws javax.xml.stream.XMLStreamException 1.172 + * @throws org.xml.sax.SAXException 1.173 + */ 1.174 + public static @NotNull WSDLModel parse(XMLEntityResolver.Parser wsdlEntityParser, XMLEntityResolver resolver, boolean isClientSide, @NotNull Container container, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws IOException, XMLStreamException, SAXException { 1.175 + return RuntimeWSDLParser.parse(wsdlEntityParser, resolver, isClientSide, container, policyResolver, extensions); 1.176 + } 1.177 + 1.178 + } 1.179 +}