|
1 /* |
|
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.model; |
|
27 |
|
28 import com.sun.xml.internal.ws.api.model.ParameterBinding; |
|
29 import com.sun.xml.internal.ws.binding.WebServiceFeatureList; |
|
30 |
|
31 import javax.jws.WebParam.Mode; |
|
32 import javax.xml.namespace.QName; |
|
33 import javax.xml.ws.WebServiceFeature; |
|
34 import java.util.HashSet; |
|
35 import java.util.Iterator; |
|
36 import java.util.Set; |
|
37 |
|
38 /** |
|
39 * Creates SOAP specific RuntimeModel |
|
40 * |
|
41 * @author Vivek Pandey |
|
42 */ |
|
43 public class SOAPSEIModel extends AbstractSEIModelImpl { |
|
44 |
|
45 public SOAPSEIModel(WebServiceFeatureList features) { |
|
46 super(features); |
|
47 } |
|
48 |
|
49 @Override |
|
50 protected void populateMaps() { |
|
51 int emptyBodyCount = 0; |
|
52 for(JavaMethodImpl jm : getJavaMethods()){ |
|
53 put(jm.getMethod(), jm); |
|
54 boolean bodyFound = false; |
|
55 for(ParameterImpl p:jm.getRequestParameters()){ |
|
56 ParameterBinding binding = p.getBinding(); |
|
57 if(binding.isBody()){ |
|
58 put(p.getName(), jm); |
|
59 bodyFound = true; |
|
60 } |
|
61 } |
|
62 if(!bodyFound){ |
|
63 put(emptyBodyName, jm); |
|
64 // System.out.println("added empty body for: "+jm.getMethod().getName()); |
|
65 emptyBodyCount++; |
|
66 } |
|
67 } |
|
68 if(emptyBodyCount > 1){ |
|
69 //TODO throw exception |
|
70 // System.out.println("Error: Unqiue signature violation - more than 1 empty body!"); |
|
71 } |
|
72 } |
|
73 |
|
74 public Set<QName> getKnownHeaders() { |
|
75 Set<QName> headers = new HashSet<QName>(); |
|
76 for (JavaMethodImpl method : getJavaMethods()) { |
|
77 // fill in request headers |
|
78 Iterator<ParameterImpl> params = method.getRequestParameters().iterator(); |
|
79 fillHeaders(params, headers, Mode.IN); |
|
80 |
|
81 // fill in response headers |
|
82 params = method.getResponseParameters().iterator(); |
|
83 fillHeaders(params, headers, Mode.OUT); |
|
84 } |
|
85 return headers; |
|
86 } |
|
87 |
|
88 /** |
|
89 * @param params |
|
90 * @param headers |
|
91 */ |
|
92 private void fillHeaders(Iterator<ParameterImpl> params, Set<QName> headers, Mode mode) { |
|
93 while (params.hasNext()) { |
|
94 ParameterImpl param = params.next(); |
|
95 ParameterBinding binding = (mode == Mode.IN)?param.getInBinding():param.getOutBinding(); |
|
96 QName name = param.getName(); |
|
97 if (binding.isHeader() && !headers.contains(name)) { |
|
98 headers.add(name); |
|
99 } |
|
100 } |
|
101 } |
|
102 } |