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

changeset 408
b0610cd08440
parent 384
8f2986ff0235
child 637
9c07ef4934dd
equal deleted inserted replaced
405:cc682329886b 408:b0610cd08440
27 27
28 import com.sun.istack.internal.Nullable; 28 import com.sun.istack.internal.Nullable;
29 import com.sun.istack.internal.NotNull; 29 import com.sun.istack.internal.NotNull;
30 import com.sun.xml.internal.ws.api.model.ParameterBinding; 30 import com.sun.xml.internal.ws.api.model.ParameterBinding;
31 import com.sun.xml.internal.ws.api.model.wsdl.*; 31 import com.sun.xml.internal.ws.api.model.wsdl.*;
32 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundFault;
33 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
34 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
35 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
36 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel;
37 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
38 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPart;
32 import com.sun.xml.internal.ws.model.RuntimeModeler; 39 import com.sun.xml.internal.ws.model.RuntimeModeler;
33 40
34 import javax.jws.WebParam.Mode; 41 import javax.jws.WebParam.Mode;
35 import javax.jws.soap.SOAPBinding.Style; 42 import javax.jws.soap.SOAPBinding.Style;
36 import javax.xml.namespace.QName; 43 import javax.xml.namespace.QName;
37 import javax.xml.stream.XMLStreamReader; 44 import javax.xml.stream.XMLStreamReader;
45
38 import java.util.*; 46 import java.util.*;
39 47
40 /** 48 /**
41 * Implementation of {@link WSDLBoundOperation} 49 * Implementation of {@link WSDLBoundOperation}
42 * 50 *
43 * @author Vivek Pandey 51 * @author Vivek Pandey
44 */ 52 */
45 public final class WSDLBoundOperationImpl extends AbstractExtensibleImpl implements WSDLBoundOperation { 53 public final class WSDLBoundOperationImpl extends AbstractExtensibleImpl implements EditableWSDLBoundOperation {
46 private final QName name; 54 private final QName name;
47 55
48 // map of wsdl:part to the binding 56 // map of wsdl:part to the binding
49 private final Map<String, ParameterBinding> inputParts; 57 private final Map<String, ParameterBinding> inputParts;
50 private final Map<String, ParameterBinding> outputParts; 58 private final Map<String, ParameterBinding> outputParts;
59 67
60 private Boolean emptyInputBody; 68 private Boolean emptyInputBody;
61 private Boolean emptyOutputBody; 69 private Boolean emptyOutputBody;
62 private Boolean emptyFaultBody; 70 private Boolean emptyFaultBody;
63 71
64 private final Map<String, WSDLPartImpl> inParts; 72 private final Map<String, EditableWSDLPart> inParts;
65 private final Map<String, WSDLPartImpl> outParts; 73 private final Map<String, EditableWSDLPart> outParts;
66 private final List<WSDLBoundFaultImpl> wsdlBoundFaults; 74 private final List<EditableWSDLBoundFault> wsdlBoundFaults;
67 private WSDLOperationImpl operation; 75 private EditableWSDLOperation operation;
68 private String soapAction; 76 private String soapAction;
69 private ANONYMOUS anonymous; 77 private ANONYMOUS anonymous;
70 78
71 private final WSDLBoundPortTypeImpl owner; 79 private final EditableWSDLBoundPortType owner;
72 80
73 /** 81 /**
74 * 82 *
75 * @param name wsdl:operation name qualified value 83 * @param name wsdl:operation name qualified value
76 */ 84 */
77 public WSDLBoundOperationImpl(XMLStreamReader xsr, WSDLBoundPortTypeImpl owner, QName name) { 85 public WSDLBoundOperationImpl(XMLStreamReader xsr, EditableWSDLBoundPortType owner, QName name) {
78 super(xsr); 86 super(xsr);
79 this.name = name; 87 this.name = name;
80 inputParts = new HashMap<String, ParameterBinding>(); 88 inputParts = new HashMap<String, ParameterBinding>();
81 outputParts = new HashMap<String, ParameterBinding>(); 89 outputParts = new HashMap<String, ParameterBinding>();
82 faultParts = new HashMap<String, ParameterBinding>(); 90 faultParts = new HashMap<String, ParameterBinding>();
83 inputMimeTypes = new HashMap<String, String>(); 91 inputMimeTypes = new HashMap<String, String>();
84 outputMimeTypes = new HashMap<String, String>(); 92 outputMimeTypes = new HashMap<String, String>();
85 faultMimeTypes = new HashMap<String, String>(); 93 faultMimeTypes = new HashMap<String, String>();
86 inParts = new HashMap<String, WSDLPartImpl>(); 94 inParts = new HashMap<String, EditableWSDLPart>();
87 outParts = new HashMap<String, WSDLPartImpl>(); 95 outParts = new HashMap<String, EditableWSDLPart>();
88 wsdlBoundFaults = new ArrayList<WSDLBoundFaultImpl>(); 96 wsdlBoundFaults = new ArrayList<EditableWSDLBoundFault>();
89 this.owner = owner; 97 this.owner = owner;
90 } 98 }
91 99
92 @Override 100 @Override
93 public QName getName(){ 101 public QName getName(){
102 public void setSoapAction(String soapAction) { 110 public void setSoapAction(String soapAction) {
103 this.soapAction = soapAction!=null?soapAction:""; 111 this.soapAction = soapAction!=null?soapAction:"";
104 } 112 }
105 113
106 @Override 114 @Override
107 public WSDLPartImpl getPart(String partName, Mode mode) { 115 public EditableWSDLPart getPart(String partName, Mode mode) {
108 if(mode==Mode.IN){ 116 if(mode==Mode.IN){
109 return inParts.get(partName); 117 return inParts.get(partName);
110 }else if(mode==Mode.OUT){ 118 }else if(mode==Mode.OUT){
111 return outParts.get(partName); 119 return outParts.get(partName);
112 } 120 }
113 return null; 121 return null;
114 } 122 }
115 123
116 public void addPart(WSDLPartImpl part, Mode mode){ 124 public void addPart(EditableWSDLPart part, Mode mode){
117 if(mode==Mode.IN) 125 if(mode==Mode.IN)
118 inParts.put(part.getName(), part); 126 inParts.put(part.getName(), part);
119 else if(mode==Mode.OUT) 127 else if(mode==Mode.OUT)
120 outParts.put(part.getName(), part); 128 outParts.put(part.getName(), part);
121 } 129 }
147 return faultParts; 155 return faultParts;
148 } 156 }
149 157
150 // TODO: what's the difference between this and inputParts/outputParts? 158 // TODO: what's the difference between this and inputParts/outputParts?
151 @Override 159 @Override
152 public Map<String,WSDLPart> getInParts() { 160 public Map<String, ? extends EditableWSDLPart> getInParts() {
153 return Collections.<String,WSDLPart>unmodifiableMap(inParts); 161 return Collections.<String, EditableWSDLPart>unmodifiableMap(inParts);
154 } 162 }
155 163
156 @Override 164 @Override
157 public Map<String,WSDLPart> getOutParts() { 165 public Map<String, ? extends EditableWSDLPart> getOutParts() {
158 return Collections.<String,WSDLPart>unmodifiableMap(outParts); 166 return Collections.<String, EditableWSDLPart>unmodifiableMap(outParts);
159 } 167 }
160 168
161 @NotNull 169 @NotNull
162 @Override 170 @Override
163 public List<WSDLBoundFaultImpl> getFaults() { 171 public List<? extends EditableWSDLBoundFault> getFaults() {
164 return wsdlBoundFaults; 172 return wsdlBoundFaults;
165 } 173 }
166 174
167 public void addFault(@NotNull WSDLBoundFaultImpl fault){ 175 public void addFault(@NotNull EditableWSDLBoundFault fault){
168 wsdlBoundFaults.add(fault); 176 wsdlBoundFaults.add(fault);
169 } 177 }
170 178
171
172 /**
173 * Map of mime:content@part and the mime type from mime:content@type for wsdl:output
174 *
175 * @return empty Map if there is no parts
176 */
177 public Map<String, String> getInputMimeTypes() {
178 return inputMimeTypes;
179 }
180
181 /**
182 * Map of mime:content@part and the mime type from mime:content@type for wsdl:output
183 *
184 * @return empty Map if there is no parts
185 */
186 public Map<String, String> getOutputMimeTypes() {
187 return outputMimeTypes;
188 }
189
190 /**
191 * Map of mime:content@part and the mime type from mime:content@type for wsdl:fault
192 *
193 * @return empty Map if there is no parts
194 */
195 public Map<String, String> getFaultMimeTypes() {
196 return faultMimeTypes;
197 }
198 179
199 /** 180 /**
200 * Gets {@link ParameterBinding} for a given wsdl part in wsdl:input 181 * Gets {@link ParameterBinding} for a given wsdl part in wsdl:input
201 * 182 *
202 * @param part Name of wsdl:part, must be non-null 183 * @param part Name of wsdl:part, must be non-null
294 public String getMimeTypeForFaultPart(String part){ 275 public String getMimeTypeForFaultPart(String part){
295 return faultMimeTypes.get(part); 276 return faultMimeTypes.get(part);
296 } 277 }
297 278
298 @Override 279 @Override
299 public WSDLOperationImpl getOperation() { 280 public EditableWSDLOperation getOperation() {
300 return operation; 281 return operation;
301 } 282 }
302 283
303 284
304 @Override 285 @Override
305 public WSDLBoundPortType getBoundPortType() { 286 public EditableWSDLBoundPortType getBoundPortType() {
306 return owner; 287 return owner;
307 } 288 }
308 289
309 public void setInputExplicitBodyParts(boolean b) { 290 public void setInputExplicitBodyParts(boolean b) {
310 explicitInputSOAPBodyParts = b; 291 explicitInputSOAPBodyParts = b;
322 public void setStyle(Style style){ 303 public void setStyle(Style style){
323 this.style = style; 304 this.style = style;
324 } 305 }
325 306
326 @Override 307 @Override
327 public @Nullable QName getReqPayloadName() { 308 public @Nullable QName getRequestPayloadName() {
328 if (emptyRequestPayload) 309 if (emptyRequestPayload)
329 return null; 310 return null;
330 311
331 if (requestPayloadName != null) 312 if (requestPayloadName != null)
332 return requestPayloadName; 313 return requestPayloadName;
335 String ns = getRequestNamespace() != null ? getRequestNamespace() : name.getNamespaceURI(); 316 String ns = getRequestNamespace() != null ? getRequestNamespace() : name.getNamespaceURI();
336 requestPayloadName = new QName(ns, name.getLocalPart()); 317 requestPayloadName = new QName(ns, name.getLocalPart());
337 return requestPayloadName; 318 return requestPayloadName;
338 }else{ 319 }else{
339 QName inMsgName = operation.getInput().getMessage().getName(); 320 QName inMsgName = operation.getInput().getMessage().getName();
340 WSDLMessageImpl message = messages.get(inMsgName); 321 EditableWSDLMessage message = messages.get(inMsgName);
341 for(WSDLPartImpl part:message.parts()){ 322 for(EditableWSDLPart part:message.parts()){
342 ParameterBinding binding = getInputBinding(part.getName()); 323 ParameterBinding binding = getInputBinding(part.getName());
343 if(binding.isBody()){ 324 if(binding.isBody()){
344 requestPayloadName = part.getDescriptor().name(); 325 requestPayloadName = part.getDescriptor().name();
345 return requestPayloadName; 326 return requestPayloadName;
346 } 327 }
352 //empty body 333 //empty body
353 return null; 334 return null;
354 } 335 }
355 336
356 @Override 337 @Override
357 public @Nullable QName getResPayloadName() { 338 public @Nullable QName getResponsePayloadName() {
358 if (emptyResponsePayload) 339 if (emptyResponsePayload)
359 return null; 340 return null;
360 341
361 if (responsePayloadName != null) 342 if (responsePayloadName != null)
362 return responsePayloadName; 343 return responsePayloadName;
365 String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI(); 346 String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI();
366 responsePayloadName = new QName(ns, name.getLocalPart()+"Response"); 347 responsePayloadName = new QName(ns, name.getLocalPart()+"Response");
367 return responsePayloadName; 348 return responsePayloadName;
368 }else{ 349 }else{
369 QName outMsgName = operation.getOutput().getMessage().getName(); 350 QName outMsgName = operation.getOutput().getMessage().getName();
370 WSDLMessageImpl message = messages.get(outMsgName); 351 EditableWSDLMessage message = messages.get(outMsgName);
371 for(WSDLPartImpl part:message.parts()){ 352 for(EditableWSDLPart part:message.parts()){
372 ParameterBinding binding = getOutputBinding(part.getName()); 353 ParameterBinding binding = getOutputBinding(part.getName());
373 if(binding.isBody()){ 354 if(binding.isBody()){
374 responsePayloadName = part.getDescriptor().name(); 355 responsePayloadName = part.getDescriptor().name();
375 return responsePayloadName; 356 return responsePayloadName;
376 } 357 }
400 381
401 public void setRequestNamespace(String ns){ 382 public void setRequestNamespace(String ns){
402 reqNamespace = ns; 383 reqNamespace = ns;
403 } 384 }
404 385
405
406 /** 386 /**
407 * For rpclit gives namespace value on soapbinding:body@namespace 387 * For rpclit gives namespace value on soapbinding:body@namespace
408 * 388 *
409 * @return non-null for rpclit and null for doclit 389 * @return non-null for rpclit and null for doclit
410 * @see RuntimeModeler#processRpcMethod(JavaMethodImpl, String, String, Method) 390 * @see RuntimeModeler#processRpcMethod(JavaMethodImpl, String, String, Method)
416 396
417 public void setResponseNamespace(String ns){ 397 public void setResponseNamespace(String ns){
418 respNamespace = ns; 398 respNamespace = ns;
419 } 399 }
420 400
421 WSDLBoundPortTypeImpl getOwner(){ 401 EditableWSDLBoundPortType getOwner(){
422 return owner; 402 return owner;
423 } 403 }
424 404
425 private QName requestPayloadName; 405 private QName requestPayloadName;
426 private QName responsePayloadName; 406 private QName responsePayloadName;
427 private boolean emptyRequestPayload; 407 private boolean emptyRequestPayload;
428 private boolean emptyResponsePayload; 408 private boolean emptyResponsePayload;
429 private Map<QName, WSDLMessageImpl> messages; 409 private Map<QName, ? extends EditableWSDLMessage> messages;
430 410
431 void freeze(WSDLModelImpl parent) { 411 public void freeze(EditableWSDLModel parent) {
432 messages = parent.getMessages(); 412 messages = parent.getMessages();
433 operation = owner.getPortType().get(name.getLocalPart()); 413 operation = owner.getPortType().get(name.getLocalPart());
434 for(WSDLBoundFaultImpl bf : wsdlBoundFaults){ 414 for(EditableWSDLBoundFault bf : wsdlBoundFaults){
435 bf.freeze(this); 415 bf.freeze(this);
436 } 416 }
437 } 417 }
438 418
439 public void setAnonymous(ANONYMOUS anonymous) { 419 public void setAnonymous(ANONYMOUS anonymous) {

mercurial