src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/WSDLParserExtensionFacade.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.wsdl.parser;
ohair@286 27
ohair@286 28 import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension;
ohair@286 29 import com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtensionContext;
mkos@408 30 import com.sun.xml.internal.ws.api.model.wsdl.editable.*;
ohair@286 31 import com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil;
ohair@286 32
ohair@286 33 import javax.xml.stream.XMLStreamReader;
ohair@286 34 import javax.xml.stream.Location;
ohair@286 35
ohair@286 36 import org.xml.sax.Locator;
ohair@286 37 import org.xml.sax.helpers.LocatorImpl;
ohair@286 38
ohair@286 39 /**
ohair@286 40 * {@link WSDLParserExtension} that delegates to
ohair@286 41 * multiple {@link WSDLParserExtension}s.
ohair@286 42 *
ohair@286 43 * <p>
ohair@286 44 * This simplifies {@link RuntimeWSDLParser} since it now
ohair@286 45 * only needs to work with one {@link WSDLParserExtension}.
ohair@286 46 *
ohair@286 47 * <p>
ohair@286 48 * This class is guaranteed to return true from
ohair@286 49 * all the extension callback methods.
ohair@286 50 *
ohair@286 51 * @author Kohsuke Kawaguchi
ohair@286 52 */
ohair@286 53 final class WSDLParserExtensionFacade extends WSDLParserExtension {
ohair@286 54 private final WSDLParserExtension[] extensions;
ohair@286 55
ohair@286 56 WSDLParserExtensionFacade(WSDLParserExtension... extensions) {
ohair@286 57 assert extensions!=null;
ohair@286 58 this.extensions = extensions;
ohair@286 59 }
ohair@286 60
ohair@286 61 public void start(WSDLParserExtensionContext context) {
ohair@286 62 for (WSDLParserExtension e : extensions) {
ohair@286 63 e.start(context);
ohair@286 64 }
ohair@286 65 }
ohair@286 66
mkos@408 67 public boolean serviceElements(EditableWSDLService service, XMLStreamReader reader) {
ohair@286 68 for (WSDLParserExtension e : extensions) {
ohair@286 69 if(e.serviceElements(service,reader))
ohair@286 70 return true;
ohair@286 71 }
ohair@286 72 XMLStreamReaderUtil.skipElement(reader);
ohair@286 73 return true;
ohair@286 74 }
ohair@286 75
mkos@408 76 public void serviceAttributes(EditableWSDLService service, XMLStreamReader reader) {
ohair@286 77 for (WSDLParserExtension e : extensions)
ohair@286 78 e.serviceAttributes(service,reader);
ohair@286 79 }
ohair@286 80
mkos@408 81 public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
ohair@286 82 for (WSDLParserExtension e : extensions) {
ohair@286 83 if(e.portElements(port,reader))
ohair@286 84 return true;
ohair@286 85 }
ohair@286 86 //extension is not understood by any WSDlParserExtension
ohair@286 87 //Check if it must be understood.
ohair@286 88 if(isRequiredExtension(reader)) {
mkos@408 89 port.addNotUnderstoodExtension(reader.getName(),getLocator(reader));
ohair@286 90 }
ohair@286 91 XMLStreamReaderUtil.skipElement(reader);
ohair@286 92 return true;
ohair@286 93 }
ohair@286 94
mkos@408 95 public boolean portTypeOperationInput(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 96 for (WSDLParserExtension e : extensions)
ohair@286 97 e.portTypeOperationInput(op,reader);
ohair@286 98
ohair@286 99 return false;
ohair@286 100 }
ohair@286 101
mkos@408 102 public boolean portTypeOperationOutput(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 103 for (WSDLParserExtension e : extensions)
ohair@286 104 e.portTypeOperationOutput(op,reader);
ohair@286 105
ohair@286 106 return false;
ohair@286 107 }
ohair@286 108
mkos@408 109 public boolean portTypeOperationFault(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 110 for (WSDLParserExtension e : extensions)
ohair@286 111 e.portTypeOperationFault(op,reader);
ohair@286 112
ohair@286 113 return false;
ohair@286 114 }
ohair@286 115
mkos@408 116 public void portAttributes(EditableWSDLPort port, XMLStreamReader reader) {
ohair@286 117 for (WSDLParserExtension e : extensions)
ohair@286 118 e.portAttributes(port,reader);
ohair@286 119 }
ohair@286 120
ohair@286 121 public boolean definitionsElements(XMLStreamReader reader){
ohair@286 122 for (WSDLParserExtension e : extensions) {
ohair@286 123 if (e.definitionsElements(reader)) {
ohair@286 124 return true;
ohair@286 125 }
ohair@286 126 }
ohair@286 127 XMLStreamReaderUtil.skipElement(reader);
ohair@286 128 return true;
ohair@286 129 }
ohair@286 130
mkos@408 131 public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader){
ohair@286 132 for (WSDLParserExtension e : extensions) {
ohair@286 133 if (e.bindingElements(binding, reader)) {
ohair@286 134 return true;
ohair@286 135 }
ohair@286 136 }
ohair@286 137 //extension is not understood by any WSDlParserExtension
ohair@286 138 //Check if it must be understood.
ohair@286 139 if (isRequiredExtension(reader)) {
mkos@408 140 binding.addNotUnderstoodExtension(
ohair@286 141 reader.getName(), getLocator(reader));
ohair@286 142 }
ohair@286 143 XMLStreamReaderUtil.skipElement(reader);
ohair@286 144 return true;
ohair@286 145 }
ohair@286 146
mkos@408 147 public void bindingAttributes(EditableWSDLBoundPortType binding, XMLStreamReader reader){
ohair@286 148 for (WSDLParserExtension e : extensions) {
ohair@286 149 e.bindingAttributes(binding, reader);
ohair@286 150 }
ohair@286 151 }
ohair@286 152
mkos@408 153 public boolean portTypeElements(EditableWSDLPortType portType, XMLStreamReader reader) {
ohair@286 154 for (WSDLParserExtension e : extensions) {
ohair@286 155 if (e.portTypeElements(portType, reader)) {
ohair@286 156 return true;
ohair@286 157 }
ohair@286 158 }
ohair@286 159 XMLStreamReaderUtil.skipElement(reader);
ohair@286 160 return true;
ohair@286 161 }
ohair@286 162
mkos@408 163 public void portTypeAttributes(EditableWSDLPortType portType, XMLStreamReader reader) {
ohair@286 164 for (WSDLParserExtension e : extensions) {
ohair@286 165 e.portTypeAttributes(portType, reader);
ohair@286 166 }
ohair@286 167 }
ohair@286 168
mkos@408 169 public boolean portTypeOperationElements(EditableWSDLOperation operation, XMLStreamReader reader) {
ohair@286 170 for (WSDLParserExtension e : extensions) {
ohair@286 171 if (e.portTypeOperationElements(operation, reader)) {
ohair@286 172 return true;
ohair@286 173 }
ohair@286 174 }
ohair@286 175 XMLStreamReaderUtil.skipElement(reader);
ohair@286 176 return true;
ohair@286 177 }
ohair@286 178
mkos@408 179 public void portTypeOperationAttributes(EditableWSDLOperation operation, XMLStreamReader reader) {
ohair@286 180 for (WSDLParserExtension e : extensions) {
ohair@286 181 e.portTypeOperationAttributes(operation, reader);
ohair@286 182 }
ohair@286 183 }
ohair@286 184
mkos@408 185 public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 186 for (WSDLParserExtension e : extensions) {
ohair@286 187 if (e.bindingOperationElements(operation, reader)) {
ohair@286 188 return true;
ohair@286 189 }
ohair@286 190 }
ohair@286 191 XMLStreamReaderUtil.skipElement(reader);
ohair@286 192 return true;
ohair@286 193 }
ohair@286 194
mkos@408 195 public void bindingOperationAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 196 for (WSDLParserExtension e : extensions) {
ohair@286 197 e.bindingOperationAttributes(operation, reader);
ohair@286 198 }
ohair@286 199 }
ohair@286 200
mkos@408 201 public boolean messageElements(EditableWSDLMessage msg, XMLStreamReader reader) {
ohair@286 202 for (WSDLParserExtension e : extensions) {
ohair@286 203 if (e.messageElements(msg, reader)) {
ohair@286 204 return true;
ohair@286 205 }
ohair@286 206 }
ohair@286 207 XMLStreamReaderUtil.skipElement(reader);
ohair@286 208 return true;
ohair@286 209 }
ohair@286 210
mkos@408 211 public void messageAttributes(EditableWSDLMessage msg, XMLStreamReader reader) {
ohair@286 212 for (WSDLParserExtension e : extensions) {
ohair@286 213 e.messageAttributes(msg, reader);
ohair@286 214 }
ohair@286 215 }
ohair@286 216
mkos@408 217 public boolean portTypeOperationInputElements(EditableWSDLInput input, XMLStreamReader reader) {
ohair@286 218 for (WSDLParserExtension e : extensions) {
ohair@286 219 if (e.portTypeOperationInputElements(input, reader)) {
ohair@286 220 return true;
ohair@286 221 }
ohair@286 222 }
ohair@286 223 XMLStreamReaderUtil.skipElement(reader);
ohair@286 224 return true;
ohair@286 225 }
ohair@286 226
mkos@408 227 public void portTypeOperationInputAttributes(EditableWSDLInput input, XMLStreamReader reader) {
ohair@286 228 for (WSDLParserExtension e : extensions) {
ohair@286 229 e.portTypeOperationInputAttributes(input, reader);
ohair@286 230 }
ohair@286 231 }
ohair@286 232
mkos@408 233 public boolean portTypeOperationOutputElements(EditableWSDLOutput output, XMLStreamReader reader) {
ohair@286 234 for (WSDLParserExtension e : extensions) {
ohair@286 235 if (e.portTypeOperationOutputElements(output, reader)) {
ohair@286 236 return true;
ohair@286 237 }
ohair@286 238 }
ohair@286 239 XMLStreamReaderUtil.skipElement(reader);
ohair@286 240 return true;
ohair@286 241 }
ohair@286 242
mkos@408 243 public void portTypeOperationOutputAttributes(EditableWSDLOutput output, XMLStreamReader reader) {
ohair@286 244 for (WSDLParserExtension e : extensions) {
ohair@286 245 e.portTypeOperationOutputAttributes(output, reader);
ohair@286 246 }
ohair@286 247 }
ohair@286 248
mkos@408 249 public boolean portTypeOperationFaultElements(EditableWSDLFault fault, XMLStreamReader reader) {
ohair@286 250 for (WSDLParserExtension e : extensions) {
ohair@286 251 if (e.portTypeOperationFaultElements(fault, reader)) {
ohair@286 252 return true;
ohair@286 253 }
ohair@286 254 }
ohair@286 255 XMLStreamReaderUtil.skipElement(reader);
ohair@286 256 return true;
ohair@286 257 }
ohair@286 258
mkos@408 259 public void portTypeOperationFaultAttributes(EditableWSDLFault fault, XMLStreamReader reader) {
ohair@286 260 for (WSDLParserExtension e : extensions) {
ohair@286 261 e.portTypeOperationFaultAttributes(fault, reader);
ohair@286 262 }
ohair@286 263 }
ohair@286 264
mkos@408 265 public boolean bindingOperationInputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 266 for (WSDLParserExtension e : extensions) {
ohair@286 267 if (e.bindingOperationInputElements(operation, reader)) {
ohair@286 268 return true;
ohair@286 269 }
ohair@286 270 }
ohair@286 271 XMLStreamReaderUtil.skipElement(reader);
ohair@286 272 return true;
ohair@286 273 }
ohair@286 274
mkos@408 275 public void bindingOperationInputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 276 for (WSDLParserExtension e : extensions) {
ohair@286 277 e.bindingOperationInputAttributes(operation, reader);
ohair@286 278 }
ohair@286 279 }
ohair@286 280
mkos@408 281 public boolean bindingOperationOutputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 282 for (WSDLParserExtension e : extensions) {
ohair@286 283 if (e.bindingOperationOutputElements(operation, reader)) {
ohair@286 284 return true;
ohair@286 285 }
ohair@286 286 }
ohair@286 287 XMLStreamReaderUtil.skipElement(reader);
ohair@286 288 return true;
ohair@286 289 }
ohair@286 290
mkos@408 291 public void bindingOperationOutputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 292 for (WSDLParserExtension e : extensions) {
ohair@286 293 e.bindingOperationOutputAttributes(operation, reader);
ohair@286 294 }
ohair@286 295 }
ohair@286 296
mkos@408 297 public boolean bindingOperationFaultElements(EditableWSDLBoundFault fault, XMLStreamReader reader) {
ohair@286 298 for (WSDLParserExtension e : extensions) {
ohair@286 299 if (e.bindingOperationFaultElements(fault, reader)) {
ohair@286 300 return true;
ohair@286 301 }
ohair@286 302 }
ohair@286 303 XMLStreamReaderUtil.skipElement(reader);
ohair@286 304 return true;
ohair@286 305 }
ohair@286 306
mkos@408 307 public void bindingOperationFaultAttributes(EditableWSDLBoundFault fault, XMLStreamReader reader) {
ohair@286 308 for (WSDLParserExtension e : extensions) {
ohair@286 309 e.bindingOperationFaultAttributes(fault, reader);
ohair@286 310 }
ohair@286 311 }
ohair@286 312
ohair@286 313 public void finished(WSDLParserExtensionContext context) {
ohair@286 314 for (WSDLParserExtension e : extensions) {
ohair@286 315 e.finished(context);
ohair@286 316 }
ohair@286 317 }
ohair@286 318
ohair@286 319 public void postFinished(WSDLParserExtensionContext context) {
ohair@286 320 for (WSDLParserExtension e : extensions) {
ohair@286 321 e.postFinished(context);
ohair@286 322 }
ohair@286 323 }
ohair@286 324 /**
ohair@286 325 *
ohair@286 326 * @param reader
ohair@286 327 * @return If the element has wsdl:required attribute set to true
ohair@286 328 */
ohair@286 329
ohair@286 330 private boolean isRequiredExtension(XMLStreamReader reader) {
ohair@286 331 String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
ohair@286 332 if(required != null)
ohair@286 333 return Boolean.parseBoolean(required);
ohair@286 334 return false;
ohair@286 335 }
ohair@286 336
ohair@286 337 private Locator getLocator(XMLStreamReader reader) {
ohair@286 338 Location location = reader.getLocation();
ohair@286 339 LocatorImpl loc = new LocatorImpl();
ohair@286 340 loc.setSystemId(location.getSystemId());
ohair@286 341 loc.setLineNumber(location.getLineNumber());
ohair@286 342 return loc;
ohair@286 343 }
ohair@286 344
ohair@286 345 }

mercurial