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

Fri, 04 Oct 2013 16:21:34 +0100

author
mkos
date
Fri, 04 Oct 2013 16:21:34 +0100
changeset 408
b0610cd08440
parent 368
0989ad8c0860
child 637
9c07ef4934dd
permissions
-rw-r--r--

8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar

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

mercurial