src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/WSDLParserExtensionFacade.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 408
b0610cd08440
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

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

mercurial