|
1 /* |
|
2 * Copyright (c) 1997, 2012, 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.tools.internal.ws.wsdl.document; |
|
27 |
|
28 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtensible; |
|
29 import com.sun.tools.internal.ws.api.wsdl.TWSDLExtension; |
|
30 import com.sun.tools.internal.ws.wsdl.framework.*; |
|
31 |
|
32 import org.xml.sax.Locator; |
|
33 |
|
34 import javax.xml.namespace.QName; |
|
35 import java.util.*; |
|
36 |
|
37 /** |
|
38 * Entity corresponding to the "definitions" WSDL element. |
|
39 * |
|
40 * @author WS Development Team |
|
41 */ |
|
42 public class Definitions extends Entity implements Defining, TWSDLExtensible { |
|
43 |
|
44 public Definitions(AbstractDocument document, Locator locator) { |
|
45 super(locator); |
|
46 _document = document; |
|
47 _bindings = new ArrayList(); |
|
48 _imports = new ArrayList(); |
|
49 _messages = new ArrayList(); |
|
50 _portTypes = new ArrayList(); |
|
51 _services = new ArrayList(); |
|
52 _importedNamespaces = new HashSet(); |
|
53 _helper = new ExtensibilityHelper(); |
|
54 } |
|
55 |
|
56 public String getName() { |
|
57 return _name; |
|
58 } |
|
59 |
|
60 public void setName(String s) { |
|
61 _name = s; |
|
62 } |
|
63 |
|
64 public String getTargetNamespaceURI() { |
|
65 return _targetNsURI; |
|
66 } |
|
67 |
|
68 public void setTargetNamespaceURI(String s) { |
|
69 _targetNsURI = s; |
|
70 } |
|
71 |
|
72 public void setTypes(Types t) { |
|
73 _types = t; |
|
74 } |
|
75 |
|
76 public Types getTypes() { |
|
77 return _types; |
|
78 } |
|
79 |
|
80 public void add(Message m) { |
|
81 _document.define(m); |
|
82 _messages.add(m); |
|
83 } |
|
84 |
|
85 public void add(PortType p) { |
|
86 _document.define(p); |
|
87 _portTypes.add(p); |
|
88 } |
|
89 |
|
90 public void add(Binding b) { |
|
91 _document.define(b); |
|
92 _bindings.add(b); |
|
93 } |
|
94 |
|
95 public void add(Service s) { |
|
96 _document.define(s); |
|
97 _services.add(s); |
|
98 } |
|
99 |
|
100 public void addServiceOveride(Service s) { |
|
101 _services.add(s); |
|
102 } |
|
103 |
|
104 public void add(Import i) { |
|
105 _imports.add(i); |
|
106 _importedNamespaces.add(i.getNamespace()); |
|
107 } |
|
108 |
|
109 public Iterator imports() { |
|
110 return _imports.iterator(); |
|
111 } |
|
112 |
|
113 public Iterator messages() { |
|
114 return _messages.iterator(); |
|
115 } |
|
116 |
|
117 public Iterator portTypes() { |
|
118 return _portTypes.iterator(); |
|
119 } |
|
120 |
|
121 public Iterator bindings() { |
|
122 return _bindings.iterator(); |
|
123 } |
|
124 |
|
125 public Iterator<Service> services() { |
|
126 return _services.iterator(); |
|
127 } |
|
128 |
|
129 public String getNameValue() { |
|
130 return getName(); |
|
131 } |
|
132 |
|
133 public String getNamespaceURI() { |
|
134 return getTargetNamespaceURI(); |
|
135 } |
|
136 |
|
137 public QName getWSDLElementName() { |
|
138 return WSDLConstants.QNAME_DEFINITIONS; |
|
139 } |
|
140 |
|
141 public Documentation getDocumentation() { |
|
142 return _documentation; |
|
143 } |
|
144 |
|
145 public void setDocumentation(Documentation d) { |
|
146 _documentation = d; |
|
147 } |
|
148 |
|
149 public void addExtension(TWSDLExtension e) { |
|
150 _helper.addExtension(e); |
|
151 } |
|
152 |
|
153 public Iterable<TWSDLExtension> extensions() { |
|
154 return _helper.extensions(); |
|
155 } |
|
156 |
|
157 /** |
|
158 * wsdl:definition is the root hence no parent so return null. |
|
159 */ |
|
160 public TWSDLExtensible getParent() { |
|
161 return null; |
|
162 } |
|
163 |
|
164 public void withAllSubEntitiesDo(EntityAction action) { |
|
165 if (_types != null) { |
|
166 action.perform(_types); |
|
167 } |
|
168 for (Iterator iter = _messages.iterator(); iter.hasNext();) { |
|
169 action.perform((Entity) iter.next()); |
|
170 } |
|
171 for (Iterator iter = _portTypes.iterator(); iter.hasNext();) { |
|
172 action.perform((Entity) iter.next()); |
|
173 } |
|
174 for (Iterator iter = _bindings.iterator(); iter.hasNext();) { |
|
175 action.perform((Entity) iter.next()); |
|
176 } |
|
177 for (Iterator iter = _services.iterator(); iter.hasNext();) { |
|
178 action.perform((Entity) iter.next()); |
|
179 } |
|
180 for (Iterator iter = _imports.iterator(); iter.hasNext();) { |
|
181 action.perform((Entity) iter.next()); |
|
182 } |
|
183 _helper.withAllSubEntitiesDo(action); |
|
184 } |
|
185 |
|
186 public void accept(WSDLDocumentVisitor visitor) throws Exception { |
|
187 visitor.preVisit(this); |
|
188 |
|
189 for (Iterator iter = _imports.iterator(); iter.hasNext();) { |
|
190 ((Import) iter.next()).accept(visitor); |
|
191 } |
|
192 |
|
193 if (_types != null) { |
|
194 _types.accept(visitor); |
|
195 } |
|
196 |
|
197 for (Iterator iter = _messages.iterator(); iter.hasNext();) { |
|
198 ((Message) iter.next()).accept(visitor); |
|
199 } |
|
200 for (Iterator iter = _portTypes.iterator(); iter.hasNext();) { |
|
201 ((PortType) iter.next()).accept(visitor); |
|
202 } |
|
203 for (Iterator iter = _bindings.iterator(); iter.hasNext();) { |
|
204 ((Binding) iter.next()).accept(visitor); |
|
205 } |
|
206 for (Iterator iter = _services.iterator(); iter.hasNext();) { |
|
207 ((Service) iter.next()).accept(visitor); |
|
208 } |
|
209 |
|
210 _helper.accept(visitor); |
|
211 visitor.postVisit(this); |
|
212 } |
|
213 |
|
214 public void validateThis() { |
|
215 } |
|
216 |
|
217 public Map resolveBindings() { |
|
218 return _document.getMap(Kinds.BINDING); |
|
219 } |
|
220 |
|
221 private AbstractDocument _document; |
|
222 private ExtensibilityHelper _helper; |
|
223 private Documentation _documentation; |
|
224 private String _name; |
|
225 private String _targetNsURI; |
|
226 private Types _types; |
|
227 private List _messages; |
|
228 private List _portTypes; |
|
229 private List _bindings; |
|
230 private List<Service> _services; |
|
231 private List _imports; |
|
232 private Set _importedNamespaces; |
|
233 |
|
234 public QName getElementName() { |
|
235 return getWSDLElementName(); |
|
236 } |
|
237 } |