src/share/jaxws_classes/com/sun/xml/internal/ws/model/wsdl/WSDLBoundPortTypeImpl.java

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 1921
7166269ef0f1
parent 637
9c07ef4934dd
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset fdbe50121f48

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.xml.internal.ws.model.wsdl;
aoqi@0 27
aoqi@0 28 import com.sun.istack.internal.NotNull;
aoqi@0 29 import com.sun.xml.internal.ws.api.BindingID;
aoqi@0 30 import com.sun.xml.internal.ws.api.SOAPVersion;
aoqi@0 31 import com.sun.xml.internal.ws.api.model.ParameterBinding;
aoqi@0 32 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
aoqi@0 33 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundPortType;
aoqi@0 34 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
aoqi@0 35 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
aoqi@0 36 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
aoqi@0 37 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
aoqi@0 38 import com.sun.xml.internal.ws.resources.ClientMessages;
aoqi@0 39 import com.sun.xml.internal.ws.util.QNameMap;
aoqi@0 40 import com.sun.xml.internal.ws.util.exception.LocatableWebServiceException;
aoqi@0 41
aoqi@0 42 import javax.jws.WebParam.Mode;
aoqi@0 43 import javax.jws.soap.SOAPBinding;
aoqi@0 44 import javax.jws.soap.SOAPBinding.Style;
aoqi@0 45 import javax.xml.namespace.QName;
aoqi@0 46 import javax.xml.stream.XMLStreamReader;
aoqi@0 47 import javax.xml.ws.soap.MTOMFeature;
aoqi@0 48
aoqi@0 49 /**
aoqi@0 50 * Implementation of {@link WSDLBoundPortType}
aoqi@0 51 *
aoqi@0 52 * @author Vivek Pandey
aoqi@0 53 */
aoqi@0 54 public final class WSDLBoundPortTypeImpl extends AbstractFeaturedObjectImpl implements EditableWSDLBoundPortType {
aoqi@0 55 private final QName name;
aoqi@0 56 private final QName portTypeName;
aoqi@0 57 private EditableWSDLPortType portType;
aoqi@0 58 private BindingID bindingId;
aoqi@0 59 private final @NotNull EditableWSDLModel owner;
aoqi@0 60 private final QNameMap<EditableWSDLBoundOperation> bindingOperations = new QNameMap<EditableWSDLBoundOperation>();
aoqi@0 61
aoqi@0 62 /**
aoqi@0 63 * Operations keyed by the payload tag name.
aoqi@0 64 */
aoqi@0 65 private QNameMap<EditableWSDLBoundOperation> payloadMap;
aoqi@0 66 /**
aoqi@0 67 * {@link #payloadMap} doesn't allow null key, so we store the value for it here.
aoqi@0 68 */
aoqi@0 69 private EditableWSDLBoundOperation emptyPayloadOperation;
aoqi@0 70
aoqi@0 71
aoqi@0 72
aoqi@0 73 public WSDLBoundPortTypeImpl(XMLStreamReader xsr,@NotNull EditableWSDLModel owner, QName name, QName portTypeName) {
aoqi@0 74 super(xsr);
aoqi@0 75 this.owner = owner;
aoqi@0 76 this.name = name;
aoqi@0 77 this.portTypeName = portTypeName;
aoqi@0 78 owner.addBinding(this);
aoqi@0 79 }
aoqi@0 80
aoqi@0 81 public QName getName() {
aoqi@0 82 return name;
aoqi@0 83 }
aoqi@0 84
aoqi@0 85 public @NotNull EditableWSDLModel getOwner() {
aoqi@0 86 return owner;
aoqi@0 87 }
aoqi@0 88
aoqi@0 89 public EditableWSDLBoundOperation get(QName operationName) {
aoqi@0 90 return bindingOperations.get(operationName);
aoqi@0 91 }
aoqi@0 92
aoqi@0 93 /**
aoqi@0 94 * Populates the Map that holds operation name as key and {@link WSDLBoundOperation} as the value.
aoqi@0 95 *
aoqi@0 96 * @param opName Must be non-null
aoqi@0 97 * @param ptOp Must be non-null
aoqi@0 98 * @throws NullPointerException if either opName or ptOp is null
aoqi@0 99 */
aoqi@0 100 public void put(QName opName, EditableWSDLBoundOperation ptOp) {
aoqi@0 101 bindingOperations.put(opName,ptOp);
aoqi@0 102 }
aoqi@0 103
aoqi@0 104 public QName getPortTypeName() {
aoqi@0 105 return portTypeName;
aoqi@0 106 }
aoqi@0 107
aoqi@0 108 public EditableWSDLPortType getPortType() {
aoqi@0 109 return portType;
aoqi@0 110 }
aoqi@0 111
aoqi@0 112 public Iterable<EditableWSDLBoundOperation> getBindingOperations() {
aoqi@0 113 return bindingOperations.values();
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 public BindingID getBindingId() {
aoqi@0 117 //Should the default be SOAP1.1/HTTP binding? For now lets keep it for
aoqi@0 118 //JBI bug 6509800
aoqi@0 119 return (bindingId==null)?BindingID.SOAP11_HTTP:bindingId;
aoqi@0 120 }
aoqi@0 121
aoqi@0 122 public void setBindingId(BindingID bindingId) {
aoqi@0 123 this.bindingId = bindingId;
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 /**
aoqi@0 127 * sets whether the {@link WSDLBoundPortType} is rpc or lit
aoqi@0 128 */
aoqi@0 129 private Style style = Style.DOCUMENT;
aoqi@0 130 public void setStyle(Style style){
aoqi@0 131 this.style = style;
aoqi@0 132 }
aoqi@0 133
aoqi@0 134 public SOAPBinding.Style getStyle() {
aoqi@0 135 return style;
aoqi@0 136 }
aoqi@0 137
aoqi@0 138 public boolean isRpcLit(){
aoqi@0 139 return Style.RPC==style;
aoqi@0 140 }
aoqi@0 141
aoqi@0 142 public boolean isDoclit(){
aoqi@0 143 return Style.DOCUMENT==style;
aoqi@0 144 }
aoqi@0 145
aoqi@0 146
aoqi@0 147 /**
aoqi@0 148 * Gets the {@link ParameterBinding} for a given operation, part name and the direction - IN/OUT
aoqi@0 149 *
aoqi@0 150 * @param operation wsdl:operation@name value. Must be non-null.
aoqi@0 151 * @param part wsdl:part@name such as value of soap:header@part. Must be non-null.
aoqi@0 152 * @param mode {@link Mode#IN} or {@link Mode#OUT}. Must be non-null.
aoqi@0 153 * @return null if the binding could not be resolved for the part.
aoqi@0 154 */
aoqi@0 155 public ParameterBinding getBinding(QName operation, String part, Mode mode) {
aoqi@0 156 EditableWSDLBoundOperation op = get(operation);
aoqi@0 157 if (op == null) {
aoqi@0 158 //TODO throw exception
aoqi@0 159 return null;
aoqi@0 160 }
aoqi@0 161 if ((Mode.IN == mode) || (Mode.INOUT == mode))
aoqi@0 162 return op.getInputBinding(part);
aoqi@0 163 else
aoqi@0 164 return op.getOutputBinding(part);
aoqi@0 165 }
aoqi@0 166
aoqi@0 167 public EditableWSDLBoundOperation getOperation(String namespaceUri, String localName) {
aoqi@0 168 if(namespaceUri==null && localName == null)
aoqi@0 169 return emptyPayloadOperation;
aoqi@0 170 else{
aoqi@0 171 return payloadMap.get((namespaceUri==null)?"":namespaceUri,localName);
aoqi@0 172 }
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 public void freeze() {
aoqi@0 176 portType = owner.getPortType(portTypeName);
aoqi@0 177 if(portType == null){
aoqi@0 178 throw new LocatableWebServiceException(
aoqi@0 179 ClientMessages.UNDEFINED_PORT_TYPE(portTypeName), getLocation());
aoqi@0 180 }
aoqi@0 181 portType.freeze();
aoqi@0 182
aoqi@0 183 for (EditableWSDLBoundOperation op : bindingOperations.values()) {
aoqi@0 184 op.freeze(owner);
aoqi@0 185 }
aoqi@0 186
aoqi@0 187 freezePayloadMap();
aoqi@0 188 owner.finalizeRpcLitBinding(this);
aoqi@0 189 }
aoqi@0 190
aoqi@0 191 private void freezePayloadMap() {
aoqi@0 192 if(style== Style.RPC) {
aoqi@0 193 payloadMap = new QNameMap<EditableWSDLBoundOperation>();
aoqi@0 194 for(EditableWSDLBoundOperation op : bindingOperations.values()){
aoqi@0 195 payloadMap.put(op.getRequestPayloadName(), op);
aoqi@0 196 }
aoqi@0 197 } else {
aoqi@0 198 payloadMap = new QNameMap<EditableWSDLBoundOperation>();
aoqi@0 199 // For doclit The tag will be the operation that has the same input part descriptor value
aoqi@0 200 for(EditableWSDLBoundOperation op : bindingOperations.values()){
aoqi@0 201 QName name = op.getRequestPayloadName();
aoqi@0 202 if(name == null){
aoqi@0 203 //empty payload
aoqi@0 204 emptyPayloadOperation = op;
aoqi@0 205 continue;
aoqi@0 206 }
aoqi@0 207
aoqi@0 208 payloadMap.put(name, op);
aoqi@0 209 }
aoqi@0 210 }
aoqi@0 211 }
aoqi@0 212 }

mercurial