Source Code Cross Referenced for JAXWSBindingExtensionHandler.java in  » 6.0-JDK-Modules-com.sun » tools » com » sun » tools » internal » 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 com.sun » tools » com.sun.tools.internal.ws.wsdl.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Portions Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        package com.sun.tools.internal.ws.wsdl.parser;
026:
027:        import java.util.Iterator;
028:        import java.io.IOException;
029:
030:        import javax.xml.namespace.QName;
031:        import javax.xml.namespace.NamespaceContext;
032:        import javax.xml.xpath.XPathFactory;
033:        import javax.xml.xpath.XPath;
034:        import javax.xml.xpath.XPathConstants;
035:        import javax.xml.xpath.XPathExpressionException;
036:
037:        import org.w3c.dom.Element;
038:        import org.w3c.dom.Node;
039:        import org.w3c.dom.NodeList;
040:
041:        import com.sun.tools.internal.ws.wsdl.document.*;
042:        import com.sun.tools.internal.ws.wsdl.document.jaxws.CustomName;
043:        import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBinding;
044:        import com.sun.tools.internal.ws.wsdl.document.jaxws.JAXWSBindingsConstants;
045:        import com.sun.tools.internal.ws.wsdl.document.jaxws.Parameter;
046:        import com.sun.tools.internal.ws.wsdl.document.schema.SchemaKinds;
047:        import com.sun.tools.internal.ws.wsdl.framework.Extensible;
048:        import com.sun.tools.internal.ws.wsdl.framework.Extension;
049:        import com.sun.tools.internal.ws.wsdl.framework.ParserContext;
050:        import com.sun.tools.internal.ws.wsdl.framework.WriterContext;
051:        import com.sun.tools.internal.ws.util.xml.XmlUtil;
052:
053:        /**
054:         * @author Vivek Pandey
055:         *
056:         * jaxws:bindings exension handler.
057:         *
058:         */
059:        public class JAXWSBindingExtensionHandler extends ExtensionHandlerBase {
060:
061:            private static final XPathFactory xpf = XPathFactory.newInstance();
062:            private final XPath xpath = xpf.newXPath();
063:
064:            /**
065:             *
066:             */
067:            public JAXWSBindingExtensionHandler() {
068:            }
069:
070:            /* (non-Javadoc)
071:             * @see ExtensionHandler#getNamespaceURI()
072:             */
073:            public String getNamespaceURI() {
074:                return JAXWSBindingsConstants.NS_JAXWS_BINDINGS;
075:            }
076:
077:            /**
078:             * @param context
079:             * @param parent
080:             * @param e
081:             */
082:            private boolean parseGlobalJAXWSBindings(ParserContext context,
083:                    Extensible parent, Element e) {
084:                context.push();
085:                context.registerNamespaces(e);
086:
087:                JAXWSBinding jaxwsBinding = getJAXWSExtension(parent);
088:                if (jaxwsBinding == null)
089:                    jaxwsBinding = new JAXWSBinding();
090:                String attr = XmlUtil.getAttributeOrNull(e,
091:                        JAXWSBindingsConstants.WSDL_LOCATION_ATTR);
092:                if (attr != null) {
093:                    jaxwsBinding.setWsdlLocation(attr);
094:                }
095:
096:                attr = XmlUtil.getAttributeOrNull(e,
097:                        JAXWSBindingsConstants.NODE_ATTR);
098:                if (attr != null) {
099:                    jaxwsBinding.setNode(attr);
100:                }
101:
102:                attr = XmlUtil.getAttributeOrNull(e,
103:                        JAXWSBindingsConstants.VERSION_ATTR);
104:                if (attr != null) {
105:                    jaxwsBinding.setVersion(attr);
106:                }
107:
108:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
109:                    Element e2 = Util.nextElement(iter);
110:                    if (e2 == null)
111:                        break;
112:
113:                    if (XmlUtil
114:                            .matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) {
115:                        parsePackage(context, jaxwsBinding, e2);
116:                        if ((jaxwsBinding.getJaxwsPackage() != null)
117:                                && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) {
118:                            ((Definitions) parent)
119:                                    .setDocumentation(new Documentation(
120:                                            jaxwsBinding.getJaxwsPackage()
121:                                                    .getJavaDoc()));
122:                        }
123:                    } else if (XmlUtil.matchesTagNS(e2,
124:                            JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
125:                        parseWrapperStyle(context, jaxwsBinding, e2);
126:                    } else if (XmlUtil.matchesTagNS(e2,
127:                            JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
128:                        parseAsynMapping(context, jaxwsBinding, e2);
129:                    }
130:                    //            else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
131:                    //                parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
132:                    //            }
133:                    else if (XmlUtil.matchesTagNS(e2,
134:                            JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
135:                        parseMimeContent(context, jaxwsBinding, e2);
136:                    } else {
137:                        Util.fail("parsing.invalidExtensionElement", e2
138:                                .getTagName(), e2.getNamespaceURI());
139:                        return false;
140:                    }
141:                }
142:                parent.addExtension(jaxwsBinding);
143:                context.pop();
144:                context.fireDoneParsingEntity(
145:                        JAXWSBindingsConstants.JAXWS_BINDINGS, jaxwsBinding);
146:                return true;
147:            }
148:
149:            private static JAXWSBinding getJAXWSExtension(Extensible extensible) {
150:                for (Iterator iter = extensible.extensions(); iter.hasNext();) {
151:                    Extension extension = (Extension) iter.next();
152:                    if (extension.getClass().equals(JAXWSBinding.class)) {
153:                        return (JAXWSBinding) extension;
154:                    }
155:                }
156:
157:                return null;
158:            }
159:
160:            /**
161:             * @param context
162:             * @param parent
163:             * @param e
164:             */
165:            private void parseProvider(ParserContext context,
166:                    Extensible parent, Element e) {
167:                String val = e.getTextContent();
168:                if (val == null)
169:                    return;
170:                if (val.equals("false") || val.equals("0")) {
171:                    ((JAXWSBinding) parent).setProvider(Boolean.FALSE);
172:                } else if (val.equals("true") || val.equals("1")) {
173:                    ((JAXWSBinding) parent).setProvider(Boolean.TRUE);
174:                }
175:
176:            }
177:
178:            /**
179:             *
180:             * @param context
181:             * @param parent
182:             * @param e
183:             */
184:            private void parseJAXBBindings(ParserContext context,
185:                    Extensible parent, Element e) {
186:                JAXWSBinding binding = (JAXWSBinding) parent;
187:                binding.addJaxbBindings(e);
188:            }
189:
190:            /**
191:             * @param context
192:             * @param parent
193:             * @param e
194:             */
195:            private void parsePackage(ParserContext context, Extensible parent,
196:                    Element e) {
197:                //System.out.println("In handlePackageExtension: " + e.getNodeName());
198:                String packageName = XmlUtil.getAttributeOrNull(e,
199:                        JAXWSBindingsConstants.NAME_ATTR);
200:                JAXWSBinding binding = (JAXWSBinding) parent;
201:                binding.setJaxwsPackage(new CustomName(packageName,
202:                        getJavaDoc(e)));
203:            }
204:
205:            /**
206:             * @param context
207:             * @param parent
208:             * @param e
209:             */
210:            private void parseWrapperStyle(ParserContext context,
211:                    Extensible parent, Element e) {
212:                //System.out.println("In handleWrapperStyleExtension: " + e.getNodeName());
213:                String val = e.getTextContent();
214:                if (val == null)
215:                    return;
216:                if (val.equals("false") || val.equals("0")) {
217:                    ((JAXWSBinding) parent)
218:                            .setEnableWrapperStyle(Boolean.FALSE);
219:                } else if (val.equals("true") || val.equals("1")) {
220:                    ((JAXWSBinding) parent).setEnableWrapperStyle(Boolean.TRUE);
221:                }
222:            }
223:
224:            /**
225:             * @param context
226:             * @param parent
227:             * @param e
228:             */
229:            //    private void parseAdditionalSOAPHeaderMapping(ParserContext context, Extensible parent, Element e) {
230:            //        //System.out.println("In handleAdditionalSOAPHeaderExtension: " + e.getNodeName());
231:            //        String val = e.getTextContent();
232:            //        if(val == null)
233:            //            return;
234:            //        if(val.equals("false") || val.equals("0")){
235:            //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.FALSE);
236:            //        }else if(val.equals("true") || val.equals("1")){
237:            //            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.TRUE);
238:            //        }
239:            //    }
240:            /**
241:             * @param context
242:             * @param parent
243:             * @param e
244:             */
245:            private void parseAsynMapping(ParserContext context,
246:                    Extensible parent, Element e) {
247:                //System.out.println("In handleAsynMappingExtension: " + e.getNodeName());
248:                String val = e.getTextContent();
249:                if (val == null)
250:                    return;
251:                if (val.equals("false") || val.equals("0")) {
252:                    ((JAXWSBinding) parent)
253:                            .setEnableAsyncMapping(Boolean.FALSE);
254:                } else if (val.equals("true") || val.equals("1")) {
255:                    ((JAXWSBinding) parent).setEnableAsyncMapping(Boolean.TRUE);
256:                }
257:            }
258:
259:            /**
260:             * @param context
261:             * @param parent
262:             * @param e
263:             */
264:            private void parseMimeContent(ParserContext context,
265:                    Extensible parent, Element e) {
266:                //System.out.println("In handleMimeContentExtension: " + e.getNodeName());
267:                String val = e.getTextContent();
268:                if (val == null)
269:                    return;
270:                if (val.equals("false") || val.equals("0")) {
271:                    ((JAXWSBinding) parent)
272:                            .setEnableMimeContentMapping(Boolean.FALSE);
273:                } else if (val.equals("true") || val.equals("1")) {
274:                    ((JAXWSBinding) parent)
275:                            .setEnableMimeContentMapping(Boolean.TRUE);
276:                }
277:            }
278:
279:            /**
280:             * @param context
281:             * @param jaxwsBinding
282:             * @param e
283:             */
284:            private void parseMethod(ParserContext context,
285:                    JAXWSBinding jaxwsBinding, Element e) {
286:                String methodName = XmlUtil.getAttributeOrNull(e,
287:                        JAXWSBindingsConstants.NAME_ATTR);
288:                String javaDoc = getJavaDoc(e);
289:                CustomName name = new CustomName(methodName, javaDoc);
290:                jaxwsBinding.setMethodName(name);
291:            }
292:
293:            /**
294:             * @param context
295:             * @param jaxwsBinding
296:             * @param e
297:             */
298:            private void parseParameter(ParserContext context,
299:                    JAXWSBinding jaxwsBinding, Element e) {
300:                String part = XmlUtil.getAttributeOrNull(e,
301:                        JAXWSBindingsConstants.PART_ATTR);
302:                Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(),
303:                        part, new NamespaceContextImpl(e));
304:                Node msgElm = msgPartElm.getParentNode();
305:                //MessagePart msgPart = new MessagePart();
306:
307:                String partName = XmlUtil
308:                        .getAttributeOrNull(msgPartElm, "name");
309:                String msgName = XmlUtil.getAttributeOrNull((Element) msgElm,
310:                        "name");
311:                if ((partName == null) || (msgName == null))
312:                    return;
313:
314:                String val = XmlUtil.getAttributeOrNull(msgPartElm, "element");
315:
316:                String element = XmlUtil.getAttributeOrNull(e,
317:                        JAXWSBindingsConstants.ELEMENT_ATTR);
318:                String name = XmlUtil.getAttributeOrNull(e,
319:                        JAXWSBindingsConstants.NAME_ATTR);
320:
321:                QName elementName = null;
322:                if (element != null) {
323:                    String uri = e.lookupNamespaceURI(XmlUtil
324:                            .getPrefix(element));
325:                    elementName = (uri == null) ? null : new QName(uri, XmlUtil
326:                            .getLocalPart(element));
327:                }
328:
329:                jaxwsBinding.addParameter(new Parameter(msgName, partName,
330:                        elementName, name));
331:            }
332:
333:            private Element evaluateXPathNode(Node target, String expression,
334:                    NamespaceContext namespaceContext) {
335:                NodeList nlst;
336:                try {
337:                    xpath.setNamespaceContext(namespaceContext);
338:                    nlst = (NodeList) xpath.evaluate(expression, target,
339:                            XPathConstants.NODESET);
340:                } catch (XPathExpressionException e) {
341:                    Util.fail("internalizer.XPathEvaluationError", e
342:                            .getMessage());
343:                    return null; // abort processing this <jaxb:bindings>
344:                }
345:
346:                if (nlst.getLength() == 0) {
347:                    Util.fail("internalizer.XPathEvaluatesToNoTarget",
348:                            new Object[] { expression });
349:                    return null; // abort
350:                }
351:
352:                if (nlst.getLength() != 1) {
353:                    Util.fail("internalizer.XPathEvaulatesToTooManyTargets",
354:                            new Object[] { expression, nlst.getLength() });
355:                    return null; // abort
356:                }
357:
358:                Node rnode = nlst.item(0);
359:                if (!(rnode instanceof  Element)) {
360:                    Util.fail("internalizer.XPathEvaluatesToNonElement",
361:                            new Object[] { expression });
362:                    return null; // abort
363:                }
364:                return (Element) rnode;
365:            }
366:
367:            /**
368:             * @param context
369:             * @param jaxwsBinding
370:             * @param e
371:             */
372:            private void parseClass(ParserContext context,
373:                    JAXWSBinding jaxwsBinding, Element e) {
374:                String className = XmlUtil.getAttributeOrNull(e,
375:                        JAXWSBindingsConstants.NAME_ATTR);
376:                String javaDoc = getJavaDoc(e);
377:                jaxwsBinding.setClassName(new CustomName(className, javaDoc));
378:            }
379:
380:            /**
381:             * @param context
382:             * @param jaxwsBinding
383:             * @param e
384:             */
385:            private void parseException(ParserContext context,
386:                    JAXWSBinding jaxwsBinding, Element e) {
387:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
388:                    Element e2 = Util.nextElement(iter);
389:                    if (e2 == null)
390:                        break;
391:                    if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.CLASS)) {
392:                        String className = XmlUtil.getAttributeOrNull(e2,
393:                                JAXWSBindingsConstants.NAME_ATTR);
394:                        String javaDoc = getJavaDoc(e2);
395:                        jaxwsBinding
396:                                .setException(new com.sun.tools.internal.ws.wsdl.document.jaxws.Exception(
397:                                        new CustomName(className, javaDoc)));
398:                    }
399:                }
400:            }
401:
402:            /* (non-Javadoc)
403:             * @see ExtensionHandlerBase#handleDefinitionsExtension(ParserContext, Extensible, org.w3c.dom.Element)
404:             */
405:            protected boolean handleDefinitionsExtension(ParserContext context,
406:                    Extensible parent, Element e) {
407:                return parseGlobalJAXWSBindings(context, parent, e);
408:            }
409:
410:            /* (non-Javadoc)
411:             * @see ExtensionHandlerBase#handleTypesExtension(ParserContext, Extensible, org.w3c.dom.Element)
412:             */
413:            protected boolean handleTypesExtension(ParserContext context,
414:                    Extensible parent, Element e) {
415:                // TODO Auto-generated method stub
416:                return false;
417:            }
418:
419:            /* (non-Javadoc)
420:             * @see ExtensionHandlerBase#handlePortTypeExtension(ParserContext, Extensible, org.w3c.dom.Element)
421:             */
422:            protected boolean handlePortTypeExtension(ParserContext context,
423:                    Extensible parent, Element e) {
424:                if (XmlUtil.matchesTagNS(e,
425:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
426:                    context.push();
427:                    context.registerNamespaces(e);
428:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
429:
430:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
431:                            .hasNext();) {
432:                        Element e2 = Util.nextElement(iter);
433:                        if (e2 == null)
434:                            break;
435:
436:                        if (XmlUtil.matchesTagNS(e2,
437:                                JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
438:                            parseWrapperStyle(context, jaxwsBinding, e2);
439:                        } else if (XmlUtil.matchesTagNS(e2,
440:                                JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
441:                            parseAsynMapping(context, jaxwsBinding, e2);
442:                        } else if (XmlUtil.matchesTagNS(e2,
443:                                JAXWSBindingsConstants.CLASS)) {
444:                            parseClass(context, jaxwsBinding, e2);
445:                            if ((jaxwsBinding.getClassName() != null)
446:                                    && (jaxwsBinding.getClassName()
447:                                            .getJavaDoc() != null)) {
448:                                ((PortType) parent)
449:                                        .setDocumentation(new Documentation(
450:                                                jaxwsBinding.getClassName()
451:                                                        .getJavaDoc()));
452:                            }
453:                        } else {
454:                            Util.fail("parsing.invalidExtensionElement", e2
455:                                    .getTagName(), e2.getNamespaceURI());
456:                            return false;
457:                        }
458:                    }
459:                    parent.addExtension(jaxwsBinding);
460:                    context.pop();
461:                    context
462:                            .fireDoneParsingEntity(
463:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
464:                                    jaxwsBinding);
465:                    return true;
466:                } else {
467:                    Util.fail("parsing.invalidExtensionElement",
468:                            e.getTagName(), e.getNamespaceURI());
469:                    return false;
470:                }
471:            }
472:
473:            /* (non-Javadoc)
474:             * @see ExtensionHandlerBase#handleOperationExtension(ParserContext, Extensible, org.w3c.dom.Element)
475:             */
476:            protected boolean handleOperationExtension(ParserContext context,
477:                    Extensible parent, Element e) {
478:                if (XmlUtil.matchesTagNS(e,
479:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
480:                    if (parent instanceof  Operation) {
481:                        return handlePortTypeOperation(context,
482:                                (Operation) parent, e);
483:                    } else if (parent instanceof  BindingOperation) {
484:                        return handleBindingOperation(context,
485:                                (BindingOperation) parent, e);
486:                    }
487:                } else {
488:                    Util.fail("parsing.invalidExtensionElement",
489:                            e.getTagName(), e.getNamespaceURI());
490:                    return false;
491:                }
492:                return false;
493:            }
494:
495:            /**
496:             * @param context
497:             * @param operation
498:             * @param e
499:             * @return
500:             */
501:            private boolean handleBindingOperation(ParserContext context,
502:                    BindingOperation operation, Element e) {
503:                if (XmlUtil.matchesTagNS(e,
504:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
505:                    context.push();
506:                    context.registerNamespaces(e);
507:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
508:
509:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
510:                            .hasNext();) {
511:                        Element e2 = Util.nextElement(iter);
512:                        if (e2 == null)
513:                            break;
514:
515:                        //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
516:                        //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
517:                        //                }else
518:                        if (XmlUtil.matchesTagNS(e2,
519:                                JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
520:                            parseMimeContent(context, jaxwsBinding, e2);
521:                        } else if (XmlUtil.matchesTagNS(e2,
522:                                JAXWSBindingsConstants.PARAMETER)) {
523:                            parseParameter(context, jaxwsBinding, e2);
524:                        } else {
525:                            Util.fail("parsing.invalidExtensionElement", e2
526:                                    .getTagName(), e2.getNamespaceURI());
527:                            return false;
528:                        }
529:                    }
530:                    operation.addExtension(jaxwsBinding);
531:                    context.pop();
532:                    context
533:                            .fireDoneParsingEntity(
534:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
535:                                    jaxwsBinding);
536:                    return true;
537:                } else {
538:                    Util.fail("parsing.invalidExtensionElement",
539:                            e.getTagName(), e.getNamespaceURI());
540:                    return false;
541:                }
542:            }
543:
544:            /**
545:             * @param context
546:             * @param parent
547:             * @param e
548:             * @return
549:             */
550:            private boolean handlePortTypeOperation(ParserContext context,
551:                    Operation parent, Element e) {
552:                context.push();
553:                context.registerNamespaces(e);
554:                JAXWSBinding jaxwsBinding = new JAXWSBinding();
555:
556:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
557:                    Element e2 = Util.nextElement(iter);
558:                    if (e2 == null)
559:                        break;
560:
561:                    if (XmlUtil.matchesTagNS(e2,
562:                            JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) {
563:                        parseWrapperStyle(context, jaxwsBinding, e2);
564:                    } else if (XmlUtil.matchesTagNS(e2,
565:                            JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) {
566:                        parseAsynMapping(context, jaxwsBinding, e2);
567:                    } else if (XmlUtil.matchesTagNS(e2,
568:                            JAXWSBindingsConstants.METHOD)) {
569:                        parseMethod(context, jaxwsBinding, e2);
570:                        if ((jaxwsBinding.getMethodName() != null)
571:                                && (jaxwsBinding.getMethodName().getJavaDoc() != null)) {
572:                            parent.setDocumentation(new Documentation(
573:                                    jaxwsBinding.getMethodName().getJavaDoc()));
574:                        }
575:                    } else if (XmlUtil.matchesTagNS(e2,
576:                            JAXWSBindingsConstants.PARAMETER)) {
577:                        parseParameter(context, jaxwsBinding, e2);
578:                    } else {
579:                        Util.fail("parsing.invalidExtensionElement", e2
580:                                .getTagName(), e2.getNamespaceURI());
581:                        return false;
582:                    }
583:                }
584:                parent.addExtension(jaxwsBinding);
585:                context.pop();
586:                context.fireDoneParsingEntity(
587:                        JAXWSBindingsConstants.JAXWS_BINDINGS, jaxwsBinding);
588:                return true;
589:            }
590:
591:            /* (non-Javadoc)
592:             * @see ExtensionHandlerBase#handleBindingExtension(ParserContext, Extensible, org.w3c.dom.Element)
593:             */
594:            protected boolean handleBindingExtension(ParserContext context,
595:                    Extensible parent, Element e) {
596:                if (XmlUtil.matchesTagNS(e,
597:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
598:                    context.push();
599:                    context.registerNamespaces(e);
600:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
601:
602:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
603:                            .hasNext();) {
604:                        Element e2 = Util.nextElement(iter);
605:                        if (e2 == null)
606:                            break;
607:
608:                        //                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
609:                        //                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
610:                        //                }else
611:                        if (XmlUtil.matchesTagNS(e2,
612:                                JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) {
613:                            parseMimeContent(context, jaxwsBinding, e2);
614:                        } else {
615:                            Util.fail("parsing.invalidExtensionElement", e2
616:                                    .getTagName(), e2.getNamespaceURI());
617:                            return false;
618:                        }
619:                    }
620:                    parent.addExtension(jaxwsBinding);
621:                    context.pop();
622:                    context
623:                            .fireDoneParsingEntity(
624:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
625:                                    jaxwsBinding);
626:                    return true;
627:                } else {
628:                    Util.fail("parsing.invalidExtensionElement",
629:                            e.getTagName(), e.getNamespaceURI());
630:                    return false;
631:                }
632:            }
633:
634:            /* (non-Javadoc)
635:             * @see ExtensionHandlerBase#handleInputExtension(ParserContext, Extensible, org.w3c.dom.Element)
636:             */
637:            protected boolean handleInputExtension(ParserContext context,
638:                    Extensible parent, Element e) {
639:                // TODO Auto-generated method stub
640:                return false;
641:            }
642:
643:            /* (non-Javadoc)
644:             * @see ExtensionHandlerBase#handleOutputExtension(ParserContext, Extensible, org.w3c.dom.Element)
645:             */
646:            protected boolean handleOutputExtension(ParserContext context,
647:                    Extensible parent, Element e) {
648:                // TODO Auto-generated method stub
649:                return false;
650:            }
651:
652:            /* (non-Javadoc)
653:             * @see ExtensionHandlerBase#handleFaultExtension(ParserContext, Extensible, org.w3c.dom.Element)
654:             */
655:            protected boolean handleFaultExtension(ParserContext context,
656:                    Extensible parent, Element e) {
657:                if (XmlUtil.matchesTagNS(e,
658:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
659:                    context.push();
660:                    context.registerNamespaces(e);
661:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
662:
663:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
664:                            .hasNext();) {
665:                        Element e2 = Util.nextElement(iter);
666:                        if (e2 == null)
667:                            break;
668:                        if (XmlUtil.matchesTagNS(e2,
669:                                JAXWSBindingsConstants.CLASS)) {
670:                            parseClass(context, jaxwsBinding, e2);
671:                            if ((jaxwsBinding.getClassName() != null)
672:                                    && (jaxwsBinding.getClassName()
673:                                            .getJavaDoc() != null)) {
674:                                ((Fault) parent)
675:                                        .setDocumentation(new Documentation(
676:                                                jaxwsBinding.getClassName()
677:                                                        .getJavaDoc()));
678:                            }
679:                        } else {
680:                            Util.fail("parsing.invalidExtensionElement", e2
681:                                    .getTagName(), e2.getNamespaceURI());
682:                            return false;
683:                        }
684:                    }
685:                    parent.addExtension(jaxwsBinding);
686:                    context.pop();
687:                    context
688:                            .fireDoneParsingEntity(
689:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
690:                                    jaxwsBinding);
691:                    return true;
692:                } else {
693:                    Util.fail("parsing.invalidExtensionElement",
694:                            e.getTagName(), e.getNamespaceURI());
695:                    return false;
696:                }
697:            }
698:
699:            /* (non-Javadoc)
700:             * @see ExtensionHandlerBase#handleServiceExtension(ParserContext, Extensible, org.w3c.dom.Element)
701:             */
702:            protected boolean handleServiceExtension(ParserContext context,
703:                    Extensible parent, Element e) {
704:                if (XmlUtil.matchesTagNS(e,
705:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
706:                    context.push();
707:                    context.registerNamespaces(e);
708:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
709:
710:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
711:                            .hasNext();) {
712:                        Element e2 = Util.nextElement(iter);
713:                        if (e2 == null)
714:                            break;
715:                        if (XmlUtil.matchesTagNS(e2,
716:                                JAXWSBindingsConstants.CLASS)) {
717:                            parseClass(context, jaxwsBinding, e2);
718:                            if ((jaxwsBinding.getClassName() != null)
719:                                    && (jaxwsBinding.getClassName()
720:                                            .getJavaDoc() != null)) {
721:                                ((Service) parent)
722:                                        .setDocumentation(new Documentation(
723:                                                jaxwsBinding.getClassName()
724:                                                        .getJavaDoc()));
725:                            }
726:                        } else {
727:                            Util.fail("parsing.invalidExtensionElement", e2
728:                                    .getTagName(), e2.getNamespaceURI());
729:                            return false;
730:                        }
731:                    }
732:                    parent.addExtension(jaxwsBinding);
733:                    context.pop();
734:                    context
735:                            .fireDoneParsingEntity(
736:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
737:                                    jaxwsBinding);
738:                    return true;
739:                } else {
740:                    Util.fail("parsing.invalidExtensionElement",
741:                            e.getTagName(), e.getNamespaceURI());
742:                    return false;
743:                }
744:            }
745:
746:            /* (non-Javadoc)
747:             * @see ExtensionHandlerBase#handlePortExtension(ParserContext, Extensible, org.w3c.dom.Element)
748:             */
749:            protected boolean handlePortExtension(ParserContext context,
750:                    Extensible parent, Element e) {
751:                if (XmlUtil.matchesTagNS(e,
752:                        JAXWSBindingsConstants.JAXWS_BINDINGS)) {
753:                    context.push();
754:                    context.registerNamespaces(e);
755:                    JAXWSBinding jaxwsBinding = new JAXWSBinding();
756:
757:                    for (Iterator iter = XmlUtil.getAllChildren(e); iter
758:                            .hasNext();) {
759:                        Element e2 = Util.nextElement(iter);
760:                        if (e2 == null)
761:                            break;
762:
763:                        if (XmlUtil.matchesTagNS(e2,
764:                                JAXWSBindingsConstants.PROVIDER)) {
765:                            parseProvider(context, jaxwsBinding, e2);
766:                        } else if (XmlUtil.matchesTagNS(e2,
767:                                JAXWSBindingsConstants.METHOD)) {
768:                            parseMethod(context, jaxwsBinding, e2);
769:                            if ((jaxwsBinding.getMethodName() != null)
770:                                    && (jaxwsBinding.getMethodName()
771:                                            .getJavaDoc() != null)) {
772:                                ((Port) parent)
773:                                        .setDocumentation(new Documentation(
774:                                                jaxwsBinding.getMethodName()
775:                                                        .getJavaDoc()));
776:                            }
777:                        } else {
778:                            Util.fail("parsing.invalidExtensionElement", e2
779:                                    .getTagName(), e2.getNamespaceURI());
780:                            return false;
781:                        }
782:                    }
783:                    parent.addExtension(jaxwsBinding);
784:                    context.pop();
785:                    context
786:                            .fireDoneParsingEntity(
787:                                    JAXWSBindingsConstants.JAXWS_BINDINGS,
788:                                    jaxwsBinding);
789:                    return true;
790:                } else {
791:                    Util.fail("parsing.invalidExtensionElement",
792:                            e.getTagName(), e.getNamespaceURI());
793:                    return false;
794:                }
795:            }
796:
797:            /* (non-Javadoc)
798:             * @see ExtensionHandlerBase#handleMIMEPartExtension(ParserContext, Extensible, org.w3c.dom.Element)
799:             */
800:            protected boolean handleMIMEPartExtension(ParserContext context,
801:                    Extensible parent, Element e) {
802:                // TODO Auto-generated method stub
803:                return false;
804:            }
805:
806:            private String getJavaDoc(Element e) {
807:                for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
808:                    Element e2 = Util.nextElement(iter);
809:                    if (e2 == null)
810:                        break;
811:                    if (XmlUtil
812:                            .matchesTagNS(e2, JAXWSBindingsConstants.JAVADOC)) {
813:                        return XmlUtil.getTextForNode(e2);
814:                    }
815:                }
816:                return null;
817:            }
818:
819:            public void doHandleExtension(WriterContext context,
820:                    Extension extension) throws IOException {
821:                //System.out.println("JAXWSBindingExtensionHandler doHandleExtension: "+extension);
822:                // NOTE - this ugliness can be avoided by moving all the XML parsing/writing code
823:                // into the document classes themselves
824:                if (extension instanceof  JAXWSBinding) {
825:                    JAXWSBinding binding = (JAXWSBinding) extension;
826:                    System.out.println("binding.getElementName: "
827:                            + binding.getElementName());
828:                    context.writeStartTag(binding.getElementName());
829:                    context
830:                            .writeStartTag(JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE);
831:                    context.writeChars(binding.isEnableWrapperStyle()
832:                            .toString());
833:                    context
834:                            .writeEndTag(JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE);
835:                    context.writeEndTag(binding.getElementName());
836:                } else {
837:                    throw new IllegalArgumentException();
838:                }
839:            }
840:
841:        }
w__w__w_.__j__a_va_2___s.___c__o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.