Source Code Cross Referenced for JAXWSBindingExtensionHandler.java in  » 6.0-JDK-Modules » jax-ws-tools » com » sun » tools » ws » wsdl » parser » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » jax ws tools » com.sun.tools.ws.wsdl.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        package com.sun.tools.ws.wsdl.parser;
037:
038:        import com.sun.tools.ws.api.wsdl.TWSDLExtensible;
039:        import com.sun.tools.ws.api.wsdl.TWSDLExtension;
040:        import com.sun.tools.ws.api.wsdl.TWSDLParserContext;
041:        import com.sun.tools.ws.util.xml.XmlUtil;
042:        import com.sun.tools.ws.wsdl.document.*;
043:        import com.sun.tools.ws.wsdl.document.jaxws.CustomName;
044:        import com.sun.tools.ws.wsdl.document.jaxws.JAXWSBinding;
045:        import com.sun.tools.ws.wsdl.document.jaxws.JAXWSBindingsConstants;
046:        import com.sun.tools.ws.wsdl.document.jaxws.Parameter;
047:        import org.w3c.dom.Element;
048:        import org.w3c.dom.Node;
049:        import org.w3c.dom.NodeList;
050:
051:        import javax.xml.namespace.NamespaceContext;
052:        import javax.xml.namespace.QName;
053:        import javax.xml.xpath.XPath;
054:        import javax.xml.xpath.XPathConstants;
055:        import javax.xml.xpath.XPathExpressionException;
056:        import javax.xml.xpath.XPathFactory;
057:        import java.util.Iterator;
058:        import java.util.Map;
059:
060:        /**
061:         * @author Vivek Pandey
062:         *
063:         * jaxws:bindings exension handler.
064:         *
065:         */
066:        public class JAXWSBindingExtensionHandler extends
067:                AbstractExtensionHandler {
068:
069:            private static final XPathFactory xpf = XPathFactory.newInstance();
070:            private final XPath xpath = xpf.newXPath();
071:
072:            public JAXWSBindingExtensionHandler(
073:                    Map<String, AbstractExtensionHandler> extensionHandlerMap) {
074:                super (extensionHandlerMap);
075:            }
076:
077:            /* (non-Javadoc)
078:             * @see AbstractExtensionHandler#getNamespaceURI()
079:             */
080:            public String getNamespaceURI() {
081:                return JAXWSBindingsConstants.NS_JAXWS_BINDINGS;
082:            }
083:
084:            /**
085:             * @param context
086:             * @param parent
087:             * @param e
088:             */
089:            private boolean parseGlobalJAXWSBindings(
090:                    TWSDLParserContext context, TWSDLExtensible parent,
091:                    Element e) {
092:                context.push();
093:                context.registerNamespaces(e);
094:
095:                JAXWSBinding jaxwsBinding = getJAXWSExtension(parent);
096:                if (jaxwsBinding == null)
097:                    jaxwsBinding = new JAXWSBinding(context.getLocation(e));
098:                String attr = XmlUtil.getAttributeOrNull(e,
099:                        JAXWSBindingsConstants.WSDL_LOCATION_ATTR);
100:                if (attr != null) {
101:                    jaxwsBinding.setWsdlLocation(attr);
102:                }
103:
104:                attr = XmlUtil.getAttributeOrNull(e,
105:                        JAXWSBindingsConstants.NODE_ATTR);
106:                if (attr != null) {
107:                    jaxwsBinding.setNode(attr);
108:                }
109:
110:                attr = XmlUtil.getAttributeOrNull(e,
111:                        JAXWSBindingsConstants.VERSION_ATTR);
112:                if (attr != null) {
113:                    jaxwsBinding.setVersion(attr);
114:                }
115:
116:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
117:                    Element e2 = Util.nextElement(iter);
118:                    if (e2 == null)
119:                        break;
120:
121:                    if (XmlUtil
122:                            .matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) {
123:                        parsePackage(context, jaxwsBinding, e2);
124:                        if ((jaxwsBinding.getJaxwsPackage() != null)
125:                                && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) {
126:                            ((Definitions) parent)
127:                                    .setDocumentation(new Documentation(
128:                                            jaxwsBinding.getJaxwsPackage()
129:                                                    .getJavaDoc()));
130:                        }
131:                    } else if (XmlUtil.matchesTagNS(e2,
132:                            JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
133:                        parseWrapperStyle(context, jaxwsBinding, e2);
134:                    } else if (XmlUtil.matchesTagNS(e2,
135:                            JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
136:                        parseAsynMapping(context, jaxwsBinding, e2);
137:                    }
138:                    //            else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
139:                    //                parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
140:                    //            }
141:                    else if (XmlUtil.matchesTagNS(e2,
142:                            JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
143:                        parseMimeContent(context, jaxwsBinding, e2);
144:                    } else {
145:                        Util.fail("parsing.invalidExtensionElement", e2
146:                                .getTagName(), e2.getNamespaceURI());
147:                        return false;
148:                    }
149:                }
150:                parent.addExtension(jaxwsBinding);
151:                context.pop();
152:                //        context.fireDoneParsingEntity(
153:                //                JAXWSBindingsConstants.JAXWS_BINDINGS,
154:                //                jaxwsBinding);
155:                return true;
156:            }
157:
158:            private static JAXWSBinding getJAXWSExtension(
159:                    TWSDLExtensible extensible) {
160:                for (TWSDLExtension extension : extensible.extensions()) {
161:                    if (extension.getClass().equals(JAXWSBinding.class)) {
162:                        return (JAXWSBinding) extension;
163:                    }
164:                }
165:
166:                return null;
167:            }
168:
169:            /**
170:             * @param context
171:             * @param parent
172:             * @param e
173:             */
174:            private void parseProvider(
175:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
176:                    JAXWSBinding parent, Element e) {
177:                String val = e.getTextContent();
178:                if (val == null)
179:                    return;
180:                if (val.equals("false") || val.equals("0")) {
181:                    ((JAXWSBinding) parent).setProvider(Boolean.FALSE);
182:                } else if (val.equals("true") || val.equals("1")) {
183:                    ((JAXWSBinding) parent).setProvider(Boolean.TRUE);
184:                }
185:
186:            }
187:
188:            /**
189:             *
190:             * @param context
191:             * @param parent
192:             * @param e
193:             */
194:            private void parseJAXBBindings(
195:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
196:                    TWSDLExtensible parent, Element e) {
197:                JAXWSBinding binding = (JAXWSBinding) parent;
198:                binding.addJaxbBindings(e);
199:            }
200:
201:            /**
202:             * @param context
203:             * @param parent
204:             * @param e
205:             */
206:            private void parsePackage(
207:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
208:                    JAXWSBinding parent, Element e) {
209:                //System.out.println("In handlePackageExtension: " + e.getNodeName());
210:                String packageName = XmlUtil.getAttributeOrNull(e,
211:                        JAXWSBindingsConstants.NAME_ATTR);
212:                JAXWSBinding binding = (JAXWSBinding) parent;
213:                binding.setJaxwsPackage(new CustomName(packageName,
214:                        getJavaDoc(e)));
215:            }
216:
217:            /**
218:             * @param context
219:             * @param parent
220:             * @param e
221:             */
222:            private void parseWrapperStyle(
223:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
224:                    JAXWSBinding parent, Element e) {
225:                //System.out.println("In handleWrapperStyleExtension: " + e.getNodeName());
226:                String val = e.getTextContent();
227:                if (val == null)
228:                    return;
229:                if (val.equals("false") || val.equals("0")) {
230:                    ((JAXWSBinding) parent)
231:                            .setEnableWrapperStyle(Boolean.FALSE);
232:                } else if (val.equals("true") || val.equals("1")) {
233:                    ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.TRUE);
234:                }
235:            }
236:
237:            /**
238:             * @param context
239:             * @param parent
240:             * @param e
241:             */
242:            //    private void parseAdditionalSOAPHeaderMapping(TWSDLParserContextImpl context, TWSDLExtensible parent, Element e) {
243:            //        //System.out.println("In handleAdditionalSOAPHeaderExtension: " + e.getNodeName());
244:            //        String val = e.getTextContent();
245:            //        if(val == null)
246:            //            return;
247:            //        if(val.equals("false") || val.equals("0")){
248:            //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.FALSE);
249:            //        }else if(val.equals("true") || val.equals("1")){
250:            //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.TRUE);
251:            //        }
252:            //    }
253:            /**
254:             * @param context
255:             * @param parent
256:             * @param e
257:             */
258:            private void parseAsynMapping(
259:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
260:                    JAXWSBinding parent, Element e) {
261:                //System.out.println("In handleAsynMappingExtension: " + e.getNodeName());
262:                String val = e.getTextContent();
263:                if (val == null)
264:                    return;
265:                if (val.equals("false") || val.equals("0")) {
266:                    ((JAXWSBinding) parent)
267:                            .setEnableAsyncMapping(Boolean.FALSE);
268:                } else if (val.equals("true") || val.equals("1")) {
269:                    ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.TRUE);
270:                }
271:            }
272:
273:            /**
274:             * @param context
275:             * @param parent
276:             * @param e
277:             */
278:            private void parseMimeContent(
279:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
280:                    JAXWSBinding parent, Element e) {
281:                //System.out.println("In handleMimeContentExtension: " + e.getNodeName());
282:                String val = e.getTextContent();
283:                if (val == null)
284:                    return;
285:                if (val.equals("false") || val.equals("0")) {
286:                    ((JAXWSBinding) parent)
287:                            .setEnableMimeContentMapping(Boolean.FALSE);
288:                } else if (val.equals("true") || val.equals("1")) {
289:                    ((JAXWSBinding) parent)
290:                            .setEnableMimeContentMapping(Boolean.TRUE);
291:                }
292:            }
293:
294:            /**
295:             * @param context
296:             * @param jaxwsBinding
297:             * @param e
298:             */
299:            private void parseMethod(
300:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
301:                    JAXWSBinding jaxwsBinding, Element e) {
302:                String methodName = XmlUtil.getAttributeOrNull(e,
303:                        JAXWSBindingsConstants.NAME_ATTR);
304:                String javaDoc = getJavaDoc(e);
305:                CustomName name = new CustomName(methodName, javaDoc);
306:                jaxwsBinding.setMethodName(name);
307:            }
308:
309:            /**
310:             * @param context
311:             * @param jaxwsBinding
312:             * @param e
313:             */
314:            private void parseParameter(
315:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
316:                    JAXWSBinding jaxwsBinding, Element e) {
317:                String part = XmlUtil.getAttributeOrNull(e,
318:                        JAXWSBindingsConstants.PART_ATTR);
319:                Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(),
320:                        part, new NamespaceContextImpl(e));
321:                Node msgElm = msgPartElm.getParentNode();
322:                //MessagePart msgPart = new MessagePart();
323:
324:                String partName = XmlUtil
325:                        .getAttributeOrNull(msgPartElm, "name");
326:                String msgName = XmlUtil.getAttributeOrNull((Element) msgElm,
327:                        "name");
328:                if ((partName == null) || (msgName == null))
329:                    return;
330:
331:                String val = XmlUtil.getAttributeOrNull(msgPartElm, "element");
332:
333:                String element = XmlUtil.getAttributeOrNull(e,
334:                        JAXWSBindingsConstants.ELEMENT_ATTR);
335:                String name = XmlUtil.getAttributeOrNull(e,
336:                        JAXWSBindingsConstants.NAME_ATTR);
337:
338:                QName elementName = null;
339:                if (element != null) {
340:                    String uri = e.lookupNamespaceURI(XmlUtil
341:                            .getPrefix(element));
342:                    elementName = (uri == null) ? null : new QName(uri, XmlUtil
343:                            .getLocalPart(element));
344:                }
345:
346:                jaxwsBinding.addParameter(new Parameter(msgName, partName,
347:                        elementName, name));
348:            }
349:
350:            private Element evaluateXPathNode(Node target, String expression,
351:                    NamespaceContext namespaceContext) {
352:                NodeList nlst;
353:                try {
354:                    xpath.setNamespaceContext(namespaceContext);
355:                    nlst = (NodeList) xpath.evaluate(expression, target,
356:                            XPathConstants.NODESET);
357:                } catch (XPathExpressionException e) {
358:                    Util.fail("internalizer.XPathEvaluationError", e
359:                            .getMessage());
360:                    return null; // abort processing this <jaxb:bindings>
361:                }
362:
363:                if (nlst.getLength() == 0) {
364:                    Util.fail("internalizer.XPathEvaluatesToNoTarget",
365:                            new Object[] { expression });
366:                    return null; // abort
367:                }
368:
369:                if (nlst.getLength() != 1) {
370:                    Util.fail("internalizer.XPathEvaulatesToTooManyTargets",
371:                            new Object[] { expression, nlst.getLength() });
372:                    return null; // abort
373:                }
374:
375:                Node rnode = nlst.item(0);
376:                if (!(rnode instanceof  Element)) {
377:                    Util.fail("internalizer.XPathEvaluatesToNonElement",
378:                            new Object[] { expression });
379:                    return null; // abort
380:                }
381:                return (Element) rnode;
382:            }
383:
384:            /**
385:             * @param context
386:             * @param jaxwsBinding
387:             * @param e
388:             */
389:            private void parseClass(
390:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
391:                    JAXWSBinding jaxwsBinding, Element e) {
392:                String className = XmlUtil.getAttributeOrNull(e,
393:                        JAXWSBindingsConstants.NAME_ATTR);
394:                String javaDoc = getJavaDoc(e);
395:                jaxwsBinding.setClassName(new CustomName(className, javaDoc));
396:            }
397:
398:            /**
399:             * @param context
400:             * @param jaxwsBinding
401:             * @param e
402:             */
403:            private void parseException(
404:                    com.sun.tools.ws.api.wsdl.TWSDLParserContext context,
405:                    JAXWSBinding jaxwsBinding, Element e) {
406:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
407:                    Element e2 = Util.nextElement(iter);
408:                    if (e2 == null)
409:                        break;
410:                    if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)) {
411:                        String className = XmlUtil.getAttributeOrNull(e2,
412:                                JAXWSBindingsConstants.NAME_ATTR);
413:                        String javaDoc = getJavaDoc(e2);
414:                        jaxwsBinding
415:                                .setException(new com.sun.tools.ws.wsdl.document.jaxws.Exception(
416:                                        new CustomName(className, javaDoc)));
417:                    }
418:                }
419:            }
420:
421:            public boolean handleDefinitionsExtension(
422:                    TWSDLParserContext context, TWSDLExtensible parent,
423:                    Element e) {
424:                return parseGlobalJAXWSBindings(context, parent, e);
425:            }
426:
427:            public boolean handlePortTypeExtension(TWSDLParserContext context,
428:                    TWSDLExtensible parent, Element e) {
429:                if (XmlUtil.matchesTagNS(e,
430:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
431:                    context.push();
432:                    context.registerNamespaces(e);
433:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
434:                            .getLocation(e));
435:
436:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
437:                            .hasNext();) {
438:                        Element e2 = Util.nextElement(iter);
439:                        if (e2 == null)
440:                            break;
441:
442:                        if (XmlUtil.matchesTagNS(e2,
443:                                JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
444:                            parseWrapperStyle(context, jaxwsBinding, e2);
445:                        } else if (XmlUtil.matchesTagNS(e2,
446:                                JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
447:                            parseAsynMapping(context, jaxwsBinding, e2);
448:                        } else if (XmlUtil.matchesTagNS(e2,
449:                                JAXWSBindingsConstants.CLASS)) {
450:                            parseClass(context, jaxwsBinding, e2);
451:                            if ((jaxwsBinding.getClassName() != null)
452:                                    && (jaxwsBinding.getClassName()
453:                                            .getJavaDoc() != null)) {
454:                                ((PortType) parent)
455:                                        .setDocumentation(new Documentation(
456:                                                jaxwsBinding.getClassName()
457:                                                        .getJavaDoc()));
458:                            }
459:                        } else {
460:                            Util.fail("parsing.invalidExtensionElement", e2
461:                                    .getTagName(), e2.getNamespaceURI());
462:                            return false;
463:                        }
464:                    }
465:                    parent.addExtension(jaxwsBinding);
466:                    context.pop();
467:                    //            context.fireDoneParsingEntity(
468:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
469:                    //                    jaxwsBinding);
470:                    return true;
471:                } else {
472:                    Util.fail("parsing.invalidExtensionElement",
473:                            e.getTagName(), e.getNamespaceURI());
474:                    return false;
475:                }
476:            }
477:
478:            public boolean handleOperationExtension(TWSDLParserContext context,
479:                    TWSDLExtensible parent, Element e) {
480:                if (XmlUtil.matchesTagNS(e,
481:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
482:                    if (parent instanceof  Operation) {
483:                        return handlePortTypeOperation(context,
484:                                (Operation) parent, e);
485:                    } else if (parent instanceof  BindingOperation) {
486:                        return handleBindingOperation(context,
487:                                (BindingOperation) parent, e);
488:                    }
489:                } else {
490:                    Util.fail("parsing.invalidExtensionElement",
491:                            e.getTagName(), e.getNamespaceURI());
492:                    return false;
493:                }
494:                return false;
495:            }
496:
497:            private boolean handleBindingOperation(TWSDLParserContext context,
498:                    BindingOperation operation, Element e) {
499:                if (XmlUtil.matchesTagNS(e,
500:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
501:                    context.push();
502:                    context.registerNamespaces(e);
503:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
504:                            .getLocation(e));
505:
506:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
507:                            .hasNext();) {
508:                        Element e2 = Util.nextElement(iter);
509:                        if (e2 == null)
510:                            break;
511:
512:                        //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
513:                        //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
514:                        //                }else
515:                        if (XmlUtil.matchesTagNS(e2,
516:                                JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
517:                            parseMimeContent(context, jaxwsBinding, e2);
518:                        } else if (XmlUtil.matchesTagNS(e2,
519:                                JAXWSBindingsConstants.PARAMETER)) {
520:                            parseParameter(context, jaxwsBinding, e2);
521:                        } else {
522:                            Util.fail("parsing.invalidExtensionElement", e2
523:                                    .getTagName(), e2.getNamespaceURI());
524:                            return false;
525:                        }
526:                    }
527:                    operation.addExtension(jaxwsBinding);
528:                    context.pop();
529:                    //            context.fireDoneParsingEntity(
530:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
531:                    //                    jaxwsBinding);
532:                    return true;
533:                } else {
534:                    Util.fail("parsing.invalidExtensionElement",
535:                            e.getTagName(), e.getNamespaceURI());
536:                    return false;
537:                }
538:            }
539:
540:            private boolean handlePortTypeOperation(TWSDLParserContext context,
541:                    Operation parent, Element e) {
542:                context.push();
543:                context.registerNamespaces(e);
544:                JAXWSBinding jaxwsBinding = new JAXWSBinding(context
545:                        .getLocation(e));
546:
547:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
548:                    Element e2 = Util.nextElement(iter);
549:                    if (e2 == null)
550:                        break;
551:
552:                    if (XmlUtil.matchesTagNS(e2,
553:                            JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
554:                        parseWrapperStyle(context, jaxwsBinding, e2);
555:                    } else if (XmlUtil.matchesTagNS(e2,
556:                            JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
557:                        parseAsynMapping(context, jaxwsBinding, e2);
558:                    } else if (XmlUtil.matchesTagNS(e2,
559:                            JAXWSBindingsConstants.METHOD)) {
560:                        parseMethod(context, jaxwsBinding, e2);
561:                        if ((jaxwsBinding.getMethodName() != null)
562:                                && (jaxwsBinding.getMethodName().getJavaDoc() != null)) {
563:                            parent.setDocumentation(new Documentation(
564:                                    jaxwsBinding.getMethodName().getJavaDoc()));
565:                        }
566:                    } else if (XmlUtil.matchesTagNS(e2,
567:                            JAXWSBindingsConstants.PARAMETER)) {
568:                        parseParameter(context, jaxwsBinding, e2);
569:                    } else {
570:                        Util.fail("parsing.invalidExtensionElement", e2
571:                                .getTagName(), e2.getNamespaceURI());
572:                        return false;
573:                    }
574:                }
575:                parent.addExtension(jaxwsBinding);
576:                context.pop();
577:                //        context.fireDoneParsingEntity(
578:                //                JAXWSBindingsConstants.JAXWS_BINDINGS,
579:                //                jaxwsBinding);
580:                return true;
581:            }
582:
583:            public boolean handleBindingExtension(TWSDLParserContext context,
584:                    TWSDLExtensible parent, Element e) {
585:                if (XmlUtil.matchesTagNS(e,
586:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
587:                    context.push();
588:                    context.registerNamespaces(e);
589:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
590:                            .getLocation(e));
591:
592:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
593:                            .hasNext();) {
594:                        Element e2 = Util.nextElement(iter);
595:                        if (e2 == null)
596:                            break;
597:
598:                        //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
599:                        //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
600:                        //                }else
601:                        if (XmlUtil.matchesTagNS(e2,
602:                                JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
603:                            parseMimeContent(context, jaxwsBinding, e2);
604:                        } else {
605:                            Util.fail("parsing.invalidExtensionElement", e2
606:                                    .getTagName(), e2.getNamespaceURI());
607:                            return false;
608:                        }
609:                    }
610:                    parent.addExtension(jaxwsBinding);
611:                    context.pop();
612:                    //            context.fireDoneParsingEntity(
613:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
614:                    //                    jaxwsBinding);
615:                    return true;
616:                } else {
617:                    Util.fail("parsing.invalidExtensionElement",
618:                            e.getTagName(), e.getNamespaceURI());
619:                    return false;
620:                }
621:            }
622:
623:            /* (non-Javadoc)
624:             * @see ExtensionHandlerBase#handleFaultExtension(TWSDLParserContextImpl, TWSDLExtensible, org.w3c.dom.Element)
625:             */
626:            public boolean handleFaultExtension(TWSDLParserContext context,
627:                    TWSDLExtensible parent, Element e) {
628:                if (XmlUtil.matchesTagNS(e,
629:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
630:                    context.push();
631:                    context.registerNamespaces(e);
632:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
633:                            .getLocation(e));
634:
635:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
636:                            .hasNext();) {
637:                        Element e2 = Util.nextElement(iter);
638:                        if (e2 == null)
639:                            break;
640:                        if (XmlUtil.matchesTagNS(e2,
641:                                JAXWSBindingsConstants.CLASS)) {
642:                            parseClass(context, jaxwsBinding, e2);
643:                            if ((jaxwsBinding.getClassName() != null)
644:                                    && (jaxwsBinding.getClassName()
645:                                            .getJavaDoc() != null)) {
646:                                ((Fault) parent)
647:                                        .setDocumentation(new Documentation(
648:                                                jaxwsBinding.getClassName()
649:                                                        .getJavaDoc()));
650:                            }
651:                        } else {
652:                            Util.fail("parsing.invalidExtensionElement", e2
653:                                    .getTagName(), e2.getNamespaceURI());
654:                            return false;
655:                        }
656:                    }
657:                    parent.addExtension(jaxwsBinding);
658:                    context.pop();
659:                    //            context.fireDoneParsingEntity(
660:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
661:                    //                    jaxwsBinding);
662:                    return true;
663:                } else {
664:                    Util.fail("parsing.invalidExtensionElement",
665:                            e.getTagName(), e.getNamespaceURI());
666:                    return false;
667:                }
668:            }
669:
670:            public boolean handleServiceExtension(TWSDLParserContext context,
671:                    TWSDLExtensible parent, Element e) {
672:                if (XmlUtil.matchesTagNS(e,
673:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
674:                    context.push();
675:                    context.registerNamespaces(e);
676:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
677:                            .getLocation(e));
678:
679:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
680:                            .hasNext();) {
681:                        Element e2 = Util.nextElement(iter);
682:                        if (e2 == null)
683:                            break;
684:                        if (XmlUtil.matchesTagNS(e2,
685:                                JAXWSBindingsConstants.CLASS)) {
686:                            parseClass(context, jaxwsBinding, e2);
687:                            if ((jaxwsBinding.getClassName() != null)
688:                                    && (jaxwsBinding.getClassName()
689:                                            .getJavaDoc() != null)) {
690:                                ((Service) parent)
691:                                        .setDocumentation(new Documentation(
692:                                                jaxwsBinding.getClassName()
693:                                                        .getJavaDoc()));
694:                            }
695:                        } else {
696:                            Util.fail("parsing.invalidExtensionElement", e2
697:                                    .getTagName(), e2.getNamespaceURI());
698:                            return false;
699:                        }
700:                    }
701:                    parent.addExtension(jaxwsBinding);
702:                    context.pop();
703:                    //            context.fireDoneParsingEntity(
704:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
705:                    //                    jaxwsBinding);
706:                    return true;
707:                } else {
708:                    Util.fail("parsing.invalidExtensionElement",
709:                            e.getTagName(), e.getNamespaceURI());
710:                    return false;
711:                }
712:            }
713:
714:            public boolean handlePortExtension(TWSDLParserContext context,
715:                    TWSDLExtensible parent, Element e) {
716:                if (XmlUtil.matchesTagNS(e,
717:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
718:                    context.push();
719:                    context.registerNamespaces(e);
720:                    JAXWSBinding jaxwsBinding = new JAXWSBinding(context
721:                            .getLocation(e));
722:
723:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
724:                            .hasNext();) {
725:                        Element e2 = Util.nextElement(iter);
726:                        if (e2 == null)
727:                            break;
728:
729:                        if (XmlUtil.matchesTagNS(e2,
730:                                JAXWSBindingsConstants.PROVIDER)) {
731:                            parseProvider(context, jaxwsBinding, e2);
732:                        } else if (XmlUtil.matchesTagNS(e2,
733:                                JAXWSBindingsConstants.METHOD)) {
734:                            parseMethod(context, jaxwsBinding, e2);
735:                            if ((jaxwsBinding.getMethodName() != null)
736:                                    && (jaxwsBinding.getMethodName()
737:                                            .getJavaDoc() != null)) {
738:                                ((Port) parent)
739:                                        .setDocumentation(new Documentation(
740:                                                jaxwsBinding.getMethodName()
741:                                                        .getJavaDoc()));
742:                            }
743:                        } else {
744:                            Util.fail("parsing.invalidExtensionElement", e2
745:                                    .getTagName(), e2.getNamespaceURI());
746:                            return false;
747:                        }
748:                    }
749:                    parent.addExtension(jaxwsBinding);
750:                    context.pop();
751:                    //            context.fireDoneParsingEntity(
752:                    //                    JAXWSBindingsConstants.JAXWS_BINDINGS,
753:                    //                    jaxwsBinding);
754:                    return true;
755:                } else {
756:                    Util.fail("parsing.invalidExtensionElement",
757:                            e.getTagName(), e.getNamespaceURI());
758:                    return false;
759:                }
760:            }
761:
762:            private String getJavaDoc(Element e) {
763:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
764:                    Element e2 = Util.nextElement(iter);
765:                    if (e2 == null)
766:                        break;
767:                    if (XmlUtil
768:                            .matchesTagNS(e2, JAXWSBindingsConstants.JAVADOC)) {
769:                        return XmlUtil.getTextForNode(e2);
770:                    }
771:                }
772:                return null;
773:            }
774:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.