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  */
  25 
  26 package com.sun.tools.internal.ws.api.wsdl;
  27 
  28 import com.sun.tools.internal.ws.wsdl.document.WSDLConstants;
  29 import org.w3c.dom.Element;
  30 
  31 /**
  32  * JAXWS WSDL parser {@link com.sun.tools.internal.ws.wsdl.parser.WSDLParser} will call an {@link TWSDLExtensionHandler} registered
  33  * with it for the WSDL extensibility elements thats not already defined in the WSDL 1.1 spec, such as SOAP or MIME.
  34  *
  35  * @author Vivek Pandey
  36  * @deprecated This class is deprecated, will be removed in JAX-WS 2.2 RI.
  37  */
  38 public abstract class TWSDLExtensionHandler {
  39     /**
  40      * Gives the namespace of an extensibility element.
  41      * <p/>
  42      * For example a soap 1.1 XXExtensionHandler would return <code>""http://schemas.xmlsoap.org/wsdl/soap/"</code>
  43      */
  44     public String getNamespaceURI() {
  45         return null;
  46     }
  47 
  48     /**
  49      * This interface is called during WSDL parsing on detecting any wsdl extension.
  50      *
  51      * @param context Parser context that will be passed on by the wsdl parser
  52      * @param parent  The Parent element within which the extensibility element is defined
  53      * @param e       The extensibility elemenet
  54      * @return false if there was some error during the extension handling otherwise returns true. If returned false
  55      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
  56      */
  57     public boolean doHandleExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
  58         if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_DEFINITIONS)) {
  59             return handleDefinitionsExtension(context, parent, e);
  60         } else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_TYPES)) {
  61             return handleTypesExtension(context, parent, e);
  62         } else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_PORT_TYPE)) {
  63             return handlePortTypeExtension(context, parent, e);
  64         } else if (
  65             parent.getWSDLElementName().equals(WSDLConstants.QNAME_BINDING)) {
  66             return handleBindingExtension(context, parent, e);
  67         } else if (
  68             parent.getWSDLElementName().equals(WSDLConstants.QNAME_OPERATION)) {
  69             return handleOperationExtension(context, parent, e);
  70         } else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_INPUT)) {
  71             return handleInputExtension(context, parent, e);
  72         } else if (
  73             parent.getWSDLElementName().equals(WSDLConstants.QNAME_OUTPUT)) {
  74             return handleOutputExtension(context, parent, e);
  75         } else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_FAULT)) {
  76             return handleFaultExtension(context, parent, e);
  77         } else if (
  78             parent.getWSDLElementName().equals(WSDLConstants.QNAME_SERVICE)) {
  79             return handleServiceExtension(context, parent, e);
  80         } else if (parent.getWSDLElementName().equals(WSDLConstants.QNAME_PORT)) {
  81             return handlePortExtension(context, parent, e);
  82         } else {
  83             return false;
  84         }
  85     }
  86 
  87     /**
  88      * Callback for <code>wsdl:portType</code>
  89      *
  90      * @param context Parser context that will be passed on by the wsdl parser
  91      * @param parent  The Parent element within which the extensibility element is defined
  92      * @param e       The extensibility elemenet
  93      * @return false if there was some error during the extension handling otherwise returns true. If returned false
  94      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
  95      */
  96     public boolean handlePortTypeExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
  97         return false;
  98     }
  99 
 100     /**
 101      * Callback for <code>wsdl:definitions</code>
 102      *
 103      * @param context Parser context that will be passed on by the wsdl parser
 104      * @param parent  The Parent element within which the extensibility element is defined
 105      * @param e       The extensibility elemenet
 106      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 107      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 108      */
 109     public boolean handleDefinitionsExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 110         return false;
 111     }
 112 
 113     /**
 114      * Callback for <code>wsdl:type</code>
 115      *
 116      * @param context Parser context that will be passed on by the wsdl parser
 117      * @param parent  The Parent element within which the extensibility element is defined
 118      * @param e       The extensibility elemenet
 119      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 120      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 121      */
 122     public boolean handleTypesExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 123         return false;
 124     }
 125 
 126     /**
 127      * Callback for <code>wsdl:binding</code>
 128      *
 129      * @param context Parser context that will be passed on by the wsdl parser
 130      * @param parent  The Parent element within which the extensibility element is defined
 131      * @param e       The extensibility elemenet
 132      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 133      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 134      */
 135     public boolean handleBindingExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 136         return false;
 137     }
 138 
 139     /**
 140      * Callback for <code>wsdl:portType/wsdl:operation</code>.
 141      *
 142      * @param context Parser context that will be passed on by the wsdl parser
 143      * @param parent  The Parent element within which the extensibility element is defined
 144      * @param e       The extensibility elemenet
 145      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 146      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 147      */
 148     public boolean handleOperationExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 149         return false;
 150     }
 151 
 152     /**
 153      * Callback for <code>wsdl:input</code>
 154      *
 155      * @param context Parser context that will be passed on by the wsdl parser
 156      * @param parent  The Parent element within which the extensibility element is defined
 157      * @param e       The extensibility elemenet
 158      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 159      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 160      */
 161     public boolean handleInputExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 162         return false;
 163     }
 164 
 165     /**
 166      * Callback for <code>wsdl:output</code>
 167      *
 168      * @param context Parser context that will be passed on by the wsdl parser
 169      * @param parent  The Parent element within which the extensibility element is defined
 170      * @param e       The extensibility elemenet
 171      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 172      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 173      */
 174     public boolean handleOutputExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 175         return false;
 176     }
 177 
 178     /**
 179      * Callback for <code>wsdl:fault</code>
 180      *
 181      * @param context Parser context that will be passed on by the wsdl parser
 182      * @param parent  The Parent element within which the extensibility element is defined
 183      * @param e       The extensibility elemenet
 184      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 185      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 186      */
 187     public boolean handleFaultExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 188         return false;
 189     }
 190 
 191     /**
 192      * Callback for <code>wsdl:service</code>
 193      *
 194      * @param context Parser context that will be passed on by the wsdl parser
 195      * @param parent  The Parent element within which the extensibility element is defined
 196      * @param e       The extensibility elemenet
 197      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 198      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 199      */
 200     public boolean handleServiceExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 201         return false;
 202     }
 203 
 204     /**
 205      * Callback for <code>wsdl:port</code>
 206      *
 207      * @param context Parser context that will be passed on by the wsdl parser
 208      * @param parent  The Parent element within which the extensibility element is defined
 209      * @param e       The extensibility elemenet
 210      * @return false if there was some error during the extension handling otherwise returns true. If returned false
 211      *         then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
 212      */
 213     public boolean handlePortExtension(TWSDLParserContext context, TWSDLExtensible parent, Element e) {
 214         return false;
 215     }
 216 }