Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
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 */
26 package com.sun.tools.internal.ws.wsdl.document;
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.Entity;
31 import com.sun.tools.internal.ws.wsdl.framework.EntityAction;
32 import com.sun.tools.internal.ws.wsdl.framework.ExtensibilityHelper;
33 import org.xml.sax.Locator;
35 import javax.xml.namespace.QName;
36 import java.util.ArrayList;
37 import java.util.List;
39 /**
40 * Entity corresponding to the "operation" child element of a WSDL "binding" element.
41 *
42 * @author WS Development Team
43 */
44 public class BindingOperation extends Entity implements TWSDLExtensible {
46 public BindingOperation(Locator locator) {
47 super(locator);
48 _faults = new ArrayList<BindingFault>();
49 _helper = new ExtensibilityHelper();
50 }
52 public String getName() {
53 return _name;
54 }
56 public void setName(String name) {
57 _name = name;
58 }
60 public String getUniqueKey() {
61 if (_uniqueKey == null) {
62 StringBuffer sb = new StringBuffer();
63 sb.append(_name);
64 sb.append(' ');
65 if (_input != null) {
66 sb.append(_input.getName());
67 } else {
68 sb.append(_name);
69 if (_style == OperationStyle.REQUEST_RESPONSE) {
70 sb.append("Request");
71 } else if (_style == OperationStyle.SOLICIT_RESPONSE) {
72 sb.append("Response");
73 }
74 }
75 sb.append(' ');
76 if (_output != null) {
77 sb.append(_output.getName());
78 } else {
79 sb.append(_name);
80 if (_style == OperationStyle.SOLICIT_RESPONSE) {
81 sb.append("Solicit");
82 } else if (_style == OperationStyle.REQUEST_RESPONSE) {
83 sb.append("Response");
84 }
85 }
86 _uniqueKey = sb.toString();
87 }
89 return _uniqueKey;
90 }
92 public OperationStyle getStyle() {
93 return _style;
94 }
96 public void setStyle(OperationStyle s) {
97 _style = s;
98 }
100 public BindingInput getInput() {
101 return _input;
102 }
104 public void setInput(BindingInput i) {
105 _input = i;
106 }
108 public BindingOutput getOutput() {
109 return _output;
110 }
112 public void setOutput(BindingOutput o) {
113 _output = o;
114 }
116 public void addFault(BindingFault f) {
117 _faults.add(f);
118 }
120 public Iterable<BindingFault> faults() {
121 return _faults;
122 }
124 public QName getElementName() {
125 return WSDLConstants.QNAME_OPERATION;
126 }
128 public Documentation getDocumentation() {
129 return _documentation;
130 }
132 public void setDocumentation(Documentation d) {
133 _documentation = d;
134 }
136 public String getNameValue() {
137 return getName();
138 }
140 public String getNamespaceURI() {
141 return parent.getNamespaceURI();
142 }
144 public QName getWSDLElementName() {
145 return getElementName();
146 }
148 public void addExtension(TWSDLExtension e) {
149 _helper.addExtension(e);
150 }
152 public Iterable<TWSDLExtension> extensions() {
153 return _helper.extensions();
154 }
156 public TWSDLExtensible getParent() {
157 return parent;
158 }
160 public void withAllSubEntitiesDo(EntityAction action) {
161 if (_input != null) {
162 action.perform(_input);
163 }
164 if (_output != null) {
165 action.perform(_output);
166 }
167 for (BindingFault _fault : _faults) {
168 action.perform(_fault);
169 }
170 _helper.withAllSubEntitiesDo(action);
171 }
173 public void accept(WSDLDocumentVisitor visitor) throws Exception {
174 visitor.preVisit(this);
175 //bug fix: 4947340, extensions should be the first element
176 _helper.accept(visitor);
177 if (_input != null) {
178 _input.accept(visitor);
179 }
180 if (_output != null) {
181 _output.accept(visitor);
182 }
183 for (BindingFault _fault : _faults) {
184 _fault.accept(visitor);
185 }
186 visitor.postVisit(this);
187 }
189 public void validateThis() {
190 if (_name == null) {
191 failValidation("validation.missingRequiredAttribute", "name");
192 }
193 if (_style == null) {
194 failValidation("validation.missingRequiredProperty", "style");
195 }
197 // verify operation style
198 if (_style == OperationStyle.ONE_WAY) {
199 if (_input == null) {
200 failValidation("validation.missingRequiredSubEntity", "input");
201 }
202 if (_output != null) {
203 failValidation("validation.invalidSubEntity", "output");
204 }
205 if (_faults != null && _faults.size() != 0) {
206 failValidation("validation.invalidSubEntity", "fault");
207 }
208 }
209 }
211 private ExtensibilityHelper _helper;
212 private Documentation _documentation;
213 private String _name;
214 private BindingInput _input;
215 private BindingOutput _output;
216 private List<BindingFault> _faults;
217 private OperationStyle _style;
218 private String _uniqueKey;
220 public void setParent(TWSDLExtensible parent) {
221 this.parent = parent;
222 }
224 private TWSDLExtensible parent;
225 }