001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.tools.ws.api.wsdl;
038:
039: import com.sun.tools.ws.wsdl.document.WSDLConstants;
040: import org.w3c.dom.Element;
041:
042: /**
043: * JAXWS WSDL parser {@link com.sun.tools.ws.wsdl.parser.WSDLParser} will call an {@link TWSDLExtensionHandler} registered
044: * with it for the WSDL extensibility elements thats not already defined in the WSDL 1.1 spec, such as SOAP or MIME.
045: *
046: * @author Vivek Pandey
047: */
048: public abstract class TWSDLExtensionHandler {
049: /**
050: * Gives the namespace of an extensibility element.
051: * <p/>
052: * For example a soap 1.1 XXExtensionHandler would return <code>""http://schemas.xmlsoap.org/wsdl/soap/"</code>
053: */
054: public String getNamespaceURI() {
055: return null;
056: }
057:
058: /**
059: * This interface is called during WSDL parsing on detecting any wsdl extension.
060: *
061: * @param context Parser context that will be passed on by the wsdl parser
062: * @param parent The Parent element within which the extensibility element is defined
063: * @param e The extensibility elemenet
064: * @return false if there was some error during the extension handling otherwise returns true. If returned false
065: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
066: */
067: public boolean doHandleExtension(TWSDLParserContext context,
068: TWSDLExtensible parent, Element e) {
069: if (parent.getWSDLElementName().equals(
070: WSDLConstants.QNAME_DEFINITIONS)) {
071: return handleDefinitionsExtension(context, parent, e);
072: } else if (parent.getWSDLElementName().equals(
073: WSDLConstants.QNAME_TYPES)) {
074: return handleTypesExtension(context, parent, e);
075: } else if (parent.getWSDLElementName().equals(
076: WSDLConstants.QNAME_PORT_TYPE)) {
077: return handlePortTypeExtension(context, parent, e);
078: } else if (parent.getWSDLElementName().equals(
079: WSDLConstants.QNAME_BINDING)) {
080: return handleBindingExtension(context, parent, e);
081: } else if (parent.getWSDLElementName().equals(
082: WSDLConstants.QNAME_OPERATION)) {
083: return handleOperationExtension(context, parent, e);
084: } else if (parent.getWSDLElementName().equals(
085: WSDLConstants.QNAME_INPUT)) {
086: return handleInputExtension(context, parent, e);
087: } else if (parent.getWSDLElementName().equals(
088: WSDLConstants.QNAME_OUTPUT)) {
089: return handleOutputExtension(context, parent, e);
090: } else if (parent.getWSDLElementName().equals(
091: WSDLConstants.QNAME_FAULT)) {
092: return handleFaultExtension(context, parent, e);
093: } else if (parent.getWSDLElementName().equals(
094: WSDLConstants.QNAME_SERVICE)) {
095: return handleServiceExtension(context, parent, e);
096: } else if (parent.getWSDLElementName().equals(
097: WSDLConstants.QNAME_PORT)) {
098: return handlePortExtension(context, parent, e);
099: } else {
100: return false;
101: }
102: }
103:
104: /**
105: * Callback for <code>wsdl:portType</code>
106: *
107: * @param context Parser context that will be passed on by the wsdl parser
108: * @param parent The Parent element within which the extensibility element is defined
109: * @param e The extensibility elemenet
110: * @return false if there was some error during the extension handling otherwise returns true. If returned false
111: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
112: */
113: public boolean handlePortTypeExtension(TWSDLParserContext context,
114: TWSDLExtensible parent, Element e) {
115: return false;
116: }
117:
118: /**
119: * Callback for <code>wsdl:definitions</code>
120: *
121: * @param context Parser context that will be passed on by the wsdl parser
122: * @param parent The Parent element within which the extensibility element is defined
123: * @param e The extensibility elemenet
124: * @return false if there was some error during the extension handling otherwise returns true. If returned false
125: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
126: */
127: public boolean handleDefinitionsExtension(
128: TWSDLParserContext context, TWSDLExtensible parent,
129: Element e) {
130: return false;
131: }
132:
133: /**
134: * Callback for <code>wsdl:type</code>
135: *
136: * @param context Parser context that will be passed on by the wsdl parser
137: * @param parent The Parent element within which the extensibility element is defined
138: * @param e The extensibility elemenet
139: * @return false if there was some error during the extension handling otherwise returns true. If returned false
140: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
141: */
142: public boolean handleTypesExtension(TWSDLParserContext context,
143: TWSDLExtensible parent, Element e) {
144: return false;
145: }
146:
147: /**
148: * Callback for <code>wsdl:binding</code>
149: *
150: * @param context Parser context that will be passed on by the wsdl parser
151: * @param parent The Parent element within which the extensibility element is defined
152: * @param e The extensibility elemenet
153: * @return false if there was some error during the extension handling otherwise returns true. If returned false
154: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
155: */
156: public boolean handleBindingExtension(TWSDLParserContext context,
157: TWSDLExtensible parent, Element e) {
158: return false;
159: }
160:
161: /**
162: * Callback for <code>wsdl:portType/wsdl:operation</code>.
163: *
164: * @param context Parser context that will be passed on by the wsdl parser
165: * @param parent The Parent element within which the extensibility element is defined
166: * @param e The extensibility elemenet
167: * @return false if there was some error during the extension handling otherwise returns true. If returned false
168: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
169: */
170: public boolean handleOperationExtension(TWSDLParserContext context,
171: TWSDLExtensible parent, Element e) {
172: return false;
173: }
174:
175: /**
176: * Callback for <code>wsdl:input</code>
177: *
178: * @param context Parser context that will be passed on by the wsdl parser
179: * @param parent The Parent element within which the extensibility element is defined
180: * @param e The extensibility elemenet
181: * @return false if there was some error during the extension handling otherwise returns true. If returned false
182: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
183: */
184: public boolean handleInputExtension(TWSDLParserContext context,
185: TWSDLExtensible parent, Element e) {
186: return false;
187: }
188:
189: /**
190: * Callback for <code>wsdl:output</code>
191: *
192: * @param context Parser context that will be passed on by the wsdl parser
193: * @param parent The Parent element within which the extensibility element is defined
194: * @param e The extensibility elemenet
195: * @return false if there was some error during the extension handling otherwise returns true. If returned false
196: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
197: */
198: public boolean handleOutputExtension(TWSDLParserContext context,
199: TWSDLExtensible parent, Element e) {
200: return false;
201: }
202:
203: /**
204: * Callback for <code>wsdl:fault</code>
205: *
206: * @param context Parser context that will be passed on by the wsdl parser
207: * @param parent The Parent element within which the extensibility element is defined
208: * @param e The extensibility elemenet
209: * @return false if there was some error during the extension handling otherwise returns true. If returned false
210: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
211: */
212: public boolean handleFaultExtension(TWSDLParserContext context,
213: TWSDLExtensible parent, Element e) {
214: return false;
215: }
216:
217: /**
218: * Callback for <code>wsdl:service</code>
219: *
220: * @param context Parser context that will be passed on by the wsdl parser
221: * @param parent The Parent element within which the extensibility element is defined
222: * @param e The extensibility elemenet
223: * @return false if there was some error during the extension handling otherwise returns true. If returned false
224: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
225: */
226: public boolean handleServiceExtension(TWSDLParserContext context,
227: TWSDLExtensible parent, Element e) {
228: return false;
229: }
230:
231: /**
232: * Callback for <code>wsdl:port</code>
233: *
234: * @param context Parser context that will be passed on by the wsdl parser
235: * @param parent The Parent element within which the extensibility element is defined
236: * @param e The extensibility elemenet
237: * @return false if there was some error during the extension handling otherwise returns true. If returned false
238: * then the WSDL parser can abort if the wsdl extensibility element had <code>required</code> attribute set to true
239: */
240: public boolean handlePortExtension(TWSDLParserContext context,
241: TWSDLExtensible parent, Element e) {
242: return false;
243: }
244: }
|