src/share/jaxws_classes/com/sun/xml/internal/ws/api/wsdl/parser/WSDLParserExtension.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.api.wsdl.parser;
ohair@286 27
ohair@286 28 import com.sun.xml.internal.ws.api.WSService;
mkos@408 29 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundFault;
mkos@408 30 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundOperation;
mkos@408 31 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLBoundPortType;
mkos@408 32 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLFault;
mkos@408 33 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLInput;
mkos@408 34 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLMessage;
mkos@408 35 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOperation;
mkos@408 36 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLOutput;
mkos@408 37 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort;
mkos@408 38 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPortType;
mkos@408 39 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService;
ohair@286 40 import com.sun.xml.internal.ws.api.pipe.Tube;
ohair@286 41 import com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser;
ohair@286 42
ohair@286 43 import javax.xml.stream.XMLStreamConstants;
ohair@286 44 import javax.xml.stream.XMLStreamReader;
ohair@286 45 import javax.xml.ws.WebServiceException;
ohair@286 46
ohair@286 47 /**
ohair@286 48 * Extends the WSDL parsing process.
ohair@286 49 *
ohair@286 50 * <p>
ohair@286 51 * This interface is implemented by components that build on top of the JAX-WS RI,
ohair@286 52 * to participate in the WSDL parsing process that happens in the runtime.
ohair@286 53 * This allows such components to retrieve information from WSDL extension elements,
ohair@286 54 * and use that later to, for example, configure {@link Tube}s.
ohair@286 55 *
ohair@286 56 *
ohair@286 57 *
ohair@286 58 * <h2>How it works?</h2>
ohair@286 59 * <p>
ohair@286 60 * Each method on this interface denotes one extension point in WSDL
ohair@286 61 * (the place where foreign elements/attributes can be added.) A {@link RuntimeWSDLParser}
ohair@286 62 * starts parsing WSDL with a fixed set of {@link WSDLParserExtension}s, and
ohair@286 63 * as it finds extension elements/attributes, it calls appropriate callback methods
ohair@286 64 * to provide a chance for {@link WSDLParserExtension} to parse such
ohair@286 65 * an extension element.
ohair@286 66 *
ohair@286 67 * <p>
ohair@286 68 * There are two kinds of callbacks.
ohair@286 69 *
ohair@286 70 * <h3>Attribute callbacks</h3>
ohair@286 71 * <p>
ohair@286 72 * One is for attributes, which ends with the name {@code Attributes}.
ohair@286 73 * This callback is invoked with {@link XMLStreamReader} that points
ohair@286 74 * to the start tag of the WSDL element.
ohair@286 75 *
ohair@286 76 * <p>
ohair@286 77 * The callback method can read interesting attributes on it.
ohair@286 78 * The method must return without advancing the parser to the next token.
ohair@286 79 *
ohair@286 80 * <h3>Element callbacks</h3>
ohair@286 81 * <p>
ohair@286 82 * The other callback is for extension elements, which ends with the name
ohair@286 83 * {@code Elements}.
ohair@286 84 * When a callback is invoked, {@link XMLStreamReader} points to the
ohair@286 85 * start tag of the extension element. The callback method can do
ohair@286 86 * one of the following:
ohair@286 87 *
ohair@286 88 * <ol>
ohair@286 89 * <li>Return {@code false} without moving {@link XMLStreamReader},
ohair@286 90 * to indicate that the extension element isn't recognized.
ohair@286 91 * This allows the next {@link WSDLParserExtension} to see this
ohair@286 92 * extension element.
ohair@286 93 * <li>Parse the whole subtree rooted at the element,
ohair@286 94 * move the cursor to the {@link XMLStreamConstants#END_ELEMENT} state,
ohair@286 95 * and return {@code true}, indicating that the extension
ohair@286 96 * element is consumed.
ohair@286 97 * No other {@link WSDLParserExtension}s are notified of this extension.
ohair@286 98 * </ol>
ohair@286 99 *
ohair@286 100 * <h3>Parsing in callback</h3>
ohair@286 101 * <p>
ohair@286 102 * For each callback, the corresponding WSDL model object is passed in,
ohair@286 103 * so that {@link WSDLParserExtension} can relate what it's parsing
ohair@286 104 * to the {@link WSDLModel}. Most likely, extensions can parse
ohair@286 105 * their data into an {@link WSDLExtension}-derived classes, then
ohair@286 106 * use {@link WSDLExtensible} interface to hook them into {@link WSDLModel}.
ohair@286 107 *
ohair@286 108 * <p>
ohair@286 109 * Note that since the {@link WSDLModel} itself
ohair@286 110 * is being built, {@link WSDLParserExtension} may not invoke any of
ohair@286 111 * the query methods on the WSDL model. Those references are passed just so that
ohair@286 112 * {@link WSDLParserExtension} can hold on to those references, or put
ohair@286 113 * {@link WSDLExtensible} objects into the model, not to query it.
ohair@286 114 *
ohair@286 115 * <p>
ohair@286 116 * If {@link WSDLParserExtension} needs to query {@link WSDLModel},
ohair@286 117 * defer that processing until {@link #finished(WSDLParserExtensionContext)}, when it's
ohair@286 118 * safe to use {@link WSDLModel} can be used safely.
ohair@286 119 *
ohair@286 120 * <p>
ohair@286 121 * Also note that {@link WSDLParserExtension}s are called in no particular order.
ohair@286 122 * This interface is not designed for having multiple {@link WSDLParserExtension}s
ohair@286 123 * parse the same extension element.
ohair@286 124 *
ohair@286 125 *
ohair@286 126 * <h2>Error Handling</h2>
ohair@286 127 * <p>
ohair@286 128 * For usability, {@link WSDLParserExtension}s are expected to check possible
ohair@286 129 * errors in the extension elements that it parses. When an error is found,
ohair@286 130 * it may throw a {@link WebServiceException} to abort the parsing of the WSDL.
ohair@286 131 * This exception will be propagated to the user, so it should have
ohair@286 132 * detailed error messages pointing at the problem.
ohair@286 133 *
ohair@286 134 * <h2>Discovery</h2>
ohair@286 135 * <p>
ohair@286 136 * The JAX-WS RI locates the implementation of {@link WSDLParserExtension}s
ohair@286 137 * by using the standard service look up mechanism, in particular looking for
ohair@286 138 * <tt>META-INF/services/com.sun.xml.internal.ws.api.wsdl.parser.WSDLParserExtension</tt>
ohair@286 139 *
ohair@286 140 *
ohair@286 141 * <h2>TODO</h2>
ohair@286 142 * <p>
ohair@286 143 * As it's designed today, extensions cannot access to any of the environmental
ohair@286 144 * information before the parsing begins (such as what {@link WSService} this
ohair@286 145 * WSDL is being parsed for, etc.) We might need to reconsider this aspect.
ohair@286 146 * The JAX-WS team waits for feedback on this topic.
ohair@286 147 *
ohair@286 148 * @author Kohsuke Kawaguchi
ohair@286 149 */
ohair@286 150 public abstract class WSDLParserExtension {
mkos@408 151
ohair@286 152 public void start(WSDLParserExtensionContext context){
ohair@286 153 // noop
ohair@286 154 }
mkos@408 155
mkos@408 156 public void serviceAttributes(EditableWSDLService service, XMLStreamReader reader) {
ohair@286 157 // noop
ohair@286 158 }
ohair@286 159
mkos@408 160 public boolean serviceElements(EditableWSDLService service, XMLStreamReader reader) {
ohair@286 161 return false;
ohair@286 162 }
ohair@286 163
mkos@408 164 public void portAttributes(EditableWSDLPort port, XMLStreamReader reader) {
ohair@286 165 // noop
ohair@286 166 }
ohair@286 167
mkos@408 168 public boolean portElements(EditableWSDLPort port, XMLStreamReader reader) {
ohair@286 169 return false;
ohair@286 170 }
ohair@286 171
mkos@408 172 public boolean portTypeOperationInput(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 173 return false;
ohair@286 174 }
ohair@286 175
mkos@408 176 public boolean portTypeOperationOutput(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 177 return false;
ohair@286 178 }
ohair@286 179
mkos@408 180 public boolean portTypeOperationFault(EditableWSDLOperation op, XMLStreamReader reader) {
ohair@286 181 return false;
ohair@286 182 }
ohair@286 183
ohair@286 184 public boolean definitionsElements(XMLStreamReader reader) {
ohair@286 185 return false;
ohair@286 186 }
ohair@286 187
mkos@408 188 public boolean bindingElements(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
ohair@286 189 return false;
ohair@286 190 }
ohair@286 191
mkos@408 192 public void bindingAttributes(EditableWSDLBoundPortType binding, XMLStreamReader reader) {
ohair@286 193 }
ohair@286 194
mkos@408 195 public boolean portTypeElements(EditableWSDLPortType portType, XMLStreamReader reader) {
ohair@286 196 return false;
ohair@286 197 }
ohair@286 198
mkos@408 199 public void portTypeAttributes(EditableWSDLPortType portType, XMLStreamReader reader) {
ohair@286 200 }
ohair@286 201
mkos@408 202 public boolean portTypeOperationElements(EditableWSDLOperation operation, XMLStreamReader reader) {
ohair@286 203 return false;
ohair@286 204 }
ohair@286 205
mkos@408 206 public void portTypeOperationAttributes(EditableWSDLOperation operation, XMLStreamReader reader) {
ohair@286 207 }
ohair@286 208
mkos@408 209 public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 210 return false;
ohair@286 211 }
ohair@286 212
mkos@408 213 public void bindingOperationAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 214 }
ohair@286 215
mkos@408 216 public boolean messageElements(EditableWSDLMessage msg, XMLStreamReader reader) {
ohair@286 217 return false;
ohair@286 218 }
ohair@286 219
mkos@408 220 public void messageAttributes(EditableWSDLMessage msg, XMLStreamReader reader) {
ohair@286 221 }
ohair@286 222
mkos@408 223 public boolean portTypeOperationInputElements(EditableWSDLInput input, XMLStreamReader reader) {
ohair@286 224 return false;
ohair@286 225 }
ohair@286 226
mkos@408 227 public void portTypeOperationInputAttributes(EditableWSDLInput input, XMLStreamReader reader) {
ohair@286 228 }
ohair@286 229
mkos@408 230 public boolean portTypeOperationOutputElements(EditableWSDLOutput output, XMLStreamReader reader) {
ohair@286 231 return false;
ohair@286 232 }
ohair@286 233
mkos@408 234 public void portTypeOperationOutputAttributes(EditableWSDLOutput output, XMLStreamReader reader) {
ohair@286 235 }
ohair@286 236
mkos@408 237 public boolean portTypeOperationFaultElements(EditableWSDLFault fault, XMLStreamReader reader) {
ohair@286 238 return false;
ohair@286 239 }
ohair@286 240
mkos@408 241 public void portTypeOperationFaultAttributes(EditableWSDLFault fault, XMLStreamReader reader) {
ohair@286 242 }
ohair@286 243
mkos@408 244 public boolean bindingOperationInputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 245 return false;
ohair@286 246 }
ohair@286 247
mkos@408 248 public void bindingOperationInputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 249 }
ohair@286 250
mkos@408 251 public boolean bindingOperationOutputElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 252 return false;
ohair@286 253 }
ohair@286 254
mkos@408 255 public void bindingOperationOutputAttributes(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
ohair@286 256 }
ohair@286 257
mkos@408 258 public boolean bindingOperationFaultElements(EditableWSDLBoundFault fault, XMLStreamReader reader) {
ohair@286 259 return false;
ohair@286 260 }
ohair@286 261
mkos@408 262 public void bindingOperationFaultAttributes(EditableWSDLBoundFault fault, XMLStreamReader reader) {
ohair@286 263 }
ohair@286 264
ohair@286 265 // TODO: complete the rest of the callback
ohair@286 266
ohair@286 267 /**
ohair@286 268 * Called when the parsing of a set of WSDL documents are all done.
ohair@286 269 * <p>
ohair@286 270 * This is the opportunity to do any post-processing of the parsing
ohair@286 271 * you've done.
ohair@286 272 *
ohair@286 273 * @param context {@link WSDLParserExtensionContext} gives fully parsed {@link WSDLModel}.
ohair@286 274 */
ohair@286 275 public void finished(WSDLParserExtensionContext context) {
ohair@286 276 // noop
ohair@286 277 }
ohair@286 278
ohair@286 279 public void postFinished(WSDLParserExtensionContext context) {
ohair@286 280 // noop
ohair@286 281 }
ohair@286 282 }

mercurial