1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/document/Operation.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,255 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, 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.tools.internal.ws.wsdl.document; 1.30 + 1.31 +import com.sun.codemodel.internal.JClass; 1.32 +import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; 1.33 +import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; 1.34 +import com.sun.tools.internal.ws.api.wsdl.TWSDLOperation; 1.35 +import com.sun.tools.internal.ws.wsdl.framework.Entity; 1.36 +import com.sun.tools.internal.ws.wsdl.framework.EntityAction; 1.37 +import com.sun.tools.internal.ws.wsdl.framework.ExtensibilityHelper; 1.38 +import org.xml.sax.Locator; 1.39 + 1.40 +import javax.xml.namespace.QName; 1.41 +import java.util.*; 1.42 + 1.43 +/** 1.44 + * Entity corresponding to the "operation" child element of a "portType" WSDL element. 1.45 + * 1.46 + * @author WS Development Team 1.47 + */ 1.48 +public class Operation extends Entity implements TWSDLOperation { 1.49 + 1.50 + public Operation(Locator locator) { 1.51 + super(locator); 1.52 + _faults = new ArrayList<Fault>(); 1.53 + _helper = new ExtensibilityHelper(); 1.54 + } 1.55 + 1.56 + public String getName() { 1.57 + return _name; 1.58 + } 1.59 + 1.60 + public void setName(String name) { 1.61 + _name = name; 1.62 + } 1.63 + 1.64 + public String getUniqueKey() { 1.65 + if (_uniqueKey == null) { 1.66 + StringBuffer sb = new StringBuffer(); 1.67 + sb.append(_name); 1.68 + sb.append(' '); 1.69 + if (_input != null) { 1.70 + sb.append(_input.getName()); 1.71 + } else { 1.72 + sb.append(_name); 1.73 + if (_style == OperationStyle.REQUEST_RESPONSE) { 1.74 + sb.append("Request"); 1.75 + } else if (_style == OperationStyle.SOLICIT_RESPONSE) { 1.76 + sb.append("Response"); 1.77 + } 1.78 + } 1.79 + sb.append(' '); 1.80 + if (_output != null) { 1.81 + sb.append(_output.getName()); 1.82 + } else { 1.83 + sb.append(_name); 1.84 + if (_style == OperationStyle.SOLICIT_RESPONSE) { 1.85 + sb.append("Solicit"); 1.86 + } else if (_style == OperationStyle.REQUEST_RESPONSE) { 1.87 + sb.append("Response"); 1.88 + } 1.89 + } 1.90 + _uniqueKey = sb.toString(); 1.91 + } 1.92 + 1.93 + return _uniqueKey; 1.94 + } 1.95 + 1.96 + public OperationStyle getStyle() { 1.97 + return _style; 1.98 + } 1.99 + 1.100 + public void setStyle(OperationStyle s) { 1.101 + _style = s; 1.102 + } 1.103 + 1.104 + public Input getInput() { 1.105 + return _input; 1.106 + } 1.107 + 1.108 + public void setInput(Input i) { 1.109 + _input = i; 1.110 + } 1.111 + 1.112 + public Output getOutput() { 1.113 + return _output; 1.114 + } 1.115 + 1.116 + public void setOutput(Output o) { 1.117 + _output = o; 1.118 + } 1.119 + 1.120 + public void addFault(Fault f) { 1.121 + _faults.add(f); 1.122 + } 1.123 + 1.124 + public Iterable<Fault> faults() { 1.125 + return _faults; 1.126 + } 1.127 + 1.128 + public String getParameterOrder() { 1.129 + return _parameterOrder; 1.130 + } 1.131 + 1.132 + public void setParameterOrder(String s) { 1.133 + _parameterOrder = s; 1.134 + } 1.135 + 1.136 + public QName getElementName() { 1.137 + return WSDLConstants.QNAME_OPERATION; 1.138 + } 1.139 + 1.140 + public Documentation getDocumentation() { 1.141 + return _documentation; 1.142 + } 1.143 + 1.144 + public void setDocumentation(Documentation d) { 1.145 + _documentation = d; 1.146 + } 1.147 + 1.148 + public void withAllSubEntitiesDo(EntityAction action) { 1.149 + super.withAllSubEntitiesDo(action); 1.150 + 1.151 + if (_input != null) { 1.152 + action.perform(_input); 1.153 + } 1.154 + if (_output != null) { 1.155 + action.perform(_output); 1.156 + } 1.157 + for (Fault _fault : _faults) { 1.158 + action.perform(_fault); 1.159 + } 1.160 + _helper.withAllSubEntitiesDo(action); 1.161 + } 1.162 + 1.163 + public void accept(WSDLDocumentVisitor visitor) throws Exception { 1.164 + visitor.preVisit(this); 1.165 + if (_input != null) { 1.166 + _input.accept(visitor); 1.167 + } 1.168 + if (_output != null) { 1.169 + _output.accept(visitor); 1.170 + } 1.171 + for (Fault _fault : _faults) { 1.172 + _fault.accept(visitor); 1.173 + } 1.174 + visitor.postVisit(this); 1.175 + } 1.176 + 1.177 + public void validateThis() { 1.178 + if (_name == null) { 1.179 + failValidation("validation.missingRequiredAttribute", "name"); 1.180 + } 1.181 + if (_style == null) { 1.182 + failValidation("validation.missingRequiredProperty", "style"); 1.183 + } 1.184 + 1.185 + // verify operation style 1.186 + if (_style == OperationStyle.ONE_WAY) { 1.187 + if (_input == null) { 1.188 + failValidation("validation.missingRequiredSubEntity", "input"); 1.189 + } 1.190 + if (_output != null) { 1.191 + failValidation("validation.invalidSubEntity", "output"); 1.192 + } 1.193 + if (_faults != null && _faults.size() != 0) { 1.194 + failValidation("validation.invalidSubEntity", "fault"); 1.195 + } 1.196 + } else if (_style == OperationStyle.NOTIFICATION) { 1.197 + if (_parameterOrder != null) { 1.198 + failValidation("validation.invalidAttribute", "parameterOrder"); 1.199 + } 1.200 + } 1.201 + } 1.202 + 1.203 + public String getNameValue() { 1.204 + return getName(); 1.205 + } 1.206 + 1.207 + public String getNamespaceURI() { 1.208 + return parent.getNamespaceURI(); 1.209 + } 1.210 + 1.211 + public QName getWSDLElementName() { 1.212 + return getElementName(); 1.213 + } 1.214 + 1.215 + /* (non-Javadoc) 1.216 + * @see TWSDLExtensible#addExtension(ExtensionImpl) 1.217 + */ 1.218 + public void addExtension(TWSDLExtension e) { 1.219 + _helper.addExtension(e); 1.220 + 1.221 + } 1.222 + 1.223 + /* (non-Javadoc) 1.224 + * @see TWSDLExtensible#extensions() 1.225 + */ 1.226 + public Iterable<? extends TWSDLExtension> extensions() { 1.227 + return _helper.extensions(); 1.228 + } 1.229 + 1.230 + public TWSDLExtensible getParent() { 1.231 + return parent; 1.232 + } 1.233 + 1.234 + public void setParent(TWSDLExtensible parent) { 1.235 + this.parent = parent; 1.236 + } 1.237 + 1.238 + public Map<String, JClass> getFaults() { 1.239 + return unmodifiableFaultClassMap; 1.240 + } 1.241 + 1.242 + public void putFault(String faultName, JClass exception){ 1.243 + faultClassMap.put(faultName, exception); 1.244 + } 1.245 + 1.246 + private TWSDLExtensible parent; 1.247 + private Documentation _documentation; 1.248 + private String _name; 1.249 + private Input _input; 1.250 + private Output _output; 1.251 + private List<Fault> _faults; 1.252 + private OperationStyle _style; 1.253 + private String _parameterOrder; 1.254 + private String _uniqueKey; 1.255 + private ExtensibilityHelper _helper; 1.256 + private final Map<String, JClass> faultClassMap = new HashMap<String, JClass>(); 1.257 + private final Map<String, JClass> unmodifiableFaultClassMap = Collections.unmodifiableMap(faultClassMap); 1.258 +}