Source Code Cross Referenced for JAXWSBindingParser.java in  » Web-Services-apache-cxf-2.0.1 » tools-wsdlto » org » apache » cxf » tools » wsdlto » frontend » jaxws » customization » 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 » Web Services apache cxf 2.0.1 » tools wsdlto » org.apache.cxf.tools.wsdlto.frontend.jaxws.customization 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.tools.wsdlto.frontend.jaxws.customization;
019:
020:        import java.util.Iterator;
021:        import java.util.logging.Logger;
022:
023:        import javax.wsdl.WSDLException;
024:        import javax.wsdl.extensions.ExtensionRegistry;
025:        import javax.xml.namespace.NamespaceContext;
026:        import javax.xml.xpath.XPath;
027:        import javax.xml.xpath.XPathConstants;
028:        import javax.xml.xpath.XPathExpressionException;
029:        import javax.xml.xpath.XPathFactory;
030:
031:        import org.w3c.dom.Element;
032:        import org.w3c.dom.Node;
033:        import org.w3c.dom.NodeList;
034:
035:        import org.apache.cxf.common.i18n.Message;
036:        import org.apache.cxf.common.logging.LogUtils;
037:        import org.apache.cxf.helpers.DOMUtils;
038:        import org.apache.cxf.tools.common.ToolConstants;
039:        import org.apache.cxf.tools.common.ToolException;
040:
041:        public class JAXWSBindingParser {
042:            private static final Logger LOG = LogUtils
043:                    .getL7dLogger(CustomizationParser.class);
044:            private ExtensionRegistry extReg;
045:
046:            public JAXWSBindingParser(ExtensionRegistry ext) {
047:                extReg = ext;
048:            }
049:
050:            public JAXWSBinding parse(Class parentType, Element element,
051:                    String namespace) throws WSDLException {
052:                JAXWSBinding jaxwsBinding = (JAXWSBinding) extReg
053:                        .createExtension(parentType,
054:                                ToolConstants.JAXWS_BINDINGS);
055:
056:                jaxwsBinding.setElementType(ToolConstants.JAXWS_BINDINGS);
057:                jaxwsBinding.setElement(element);
058:                jaxwsBinding.setDocumentBaseURI(namespace);
059:
060:                parseElement(jaxwsBinding, element);
061:
062:                return jaxwsBinding;
063:            }
064:
065:            void parseElement(JAXWSBinding jaxwsBinding, Element element) {
066:                NodeList children = element.getChildNodes();
067:                if (children != null && children.getLength() == 0) {
068:                    // global binding
069:                    if (isAsyncElement(element)) {
070:                        jaxwsBinding
071:                                .setEnableAsyncMapping(getNodeValue(element));
072:                    }
073:                    if (isMIMEElement(element)) {
074:                        jaxwsBinding.setEnableMime(getNodeValue(element));
075:                    }
076:                    if (isPackageElement(element)) {
077:                        jaxwsBinding.setPackage(getPackageName(element));
078:                    }
079:
080:                    if (isWrapperStyle(element)) {
081:                        jaxwsBinding
082:                                .setEnableWrapperStyle(getNodeValue(element));
083:                    }
084:                }
085:
086:                if (children != null && children.getLength() > 0) {
087:                    // other binding
088:                    for (int i = 0; i < children.getLength(); i++) {
089:                        Node child = children.item(i);
090:
091:                        if (isAsyncElement(child)) {
092:                            jaxwsBinding
093:                                    .setEnableAsyncMapping(getNodeValue(child));
094:                        }
095:                        if (isMIMEElement(child)) {
096:                            jaxwsBinding.setEnableMime(getNodeValue(child));
097:                        }
098:
099:                        if (isWrapperStyle(child)) {
100:                            jaxwsBinding
101:                                    .setEnableWrapperStyle(getNodeValue(child));
102:                        }
103:
104:                        if (isPackageElement(child)) {
105:                            jaxwsBinding.setPackage(getPackageName(child));
106:                        }
107:
108:                        if (isJAXWSMethodElement(child)) {
109:                            jaxwsBinding.setMethodName(getMethodName(child));
110:                        }
111:
112:                        if (isJAXWSParameterElement(child)) {
113:                            Element childElement = (Element) child;
114:                            String partPath = "//"
115:                                    + childElement.getAttribute("part");
116:                            Node node = queryXPathNode(element
117:                                    .getOwnerDocument().getDocumentElement(),
118:                                    partPath);
119:                            String messageName = "";
120:                            if (node != null) {
121:                                Node messageNode = node.getParentNode();
122:                                if (messageNode != null) {
123:                                    Element messageEle = (Element) messageNode;
124:                                    messageName = messageEle
125:                                            .getAttribute("name");
126:                                }
127:                            }
128:
129:                            String name = childElement.getAttribute("name");
130:                            String elementName = childElement
131:                                    .getAttribute("childElementName");
132:                            JAXWSParameter jpara = new JAXWSParameter(
133:                                    messageName, elementName, name);
134:                            jaxwsBinding.setJaxwsPara(jpara);
135:                        }
136:
137:                        if (isJAXWSClass(child)) {
138:                            Element childElement = (Element) child;
139:                            String clzName = childElement.getAttribute("name");
140:                            String javadoc = "";
141:                            Node docChild = DOMUtils.getChild(child,
142:                                    Element.ELEMENT_NODE);
143:
144:                            if (docChild != null
145:                                    && this .isJAXWSClassDoc(docChild)) {
146:                                javadoc = DOMUtils.getContent(docChild);
147:                            }
148:
149:                            JAXWSClass jaxwsClass = new JAXWSClass(clzName,
150:                                    javadoc);
151:                            jaxwsBinding.setJaxwsClass(jaxwsClass);
152:                        }
153:                    }
154:                }
155:
156:            }
157:
158:            private boolean isJAXWSMethodElement(Node node) {
159:                return ToolConstants.NS_JAXWS_BINDINGS.equals(node
160:                        .getNamespaceURI())
161:                        && "method".equals(node.getLocalName());
162:            }
163:
164:            private String getMethodName(Node node) {
165:                Element ele = (Element) node;
166:                return ele.getAttribute("name");
167:            }
168:
169:            private boolean isPackageElement(Node node) {
170:                if (ToolConstants.NS_JAXWS_BINDINGS.equals(node
171:                        .getNamespaceURI())
172:                        && "package".equals(node.getLocalName())) {
173:                    return true;
174:                }
175:                return false;
176:
177:            }
178:
179:            private boolean isJAXWSParameterElement(Node node) {
180:                return (ToolConstants.NS_JAXWS_BINDINGS.equals(node
181:                        .getNamespaceURI()))
182:                        && "parameter".equals(node.getLocalName());
183:
184:            }
185:
186:            private boolean isJAXWSClass(Node node) {
187:                return (ToolConstants.NS_JAXWS_BINDINGS.equals(node
188:                        .getNamespaceURI()))
189:                        && "class".equals(node.getLocalName());
190:            }
191:
192:            private boolean isJAXWSClassDoc(Node node) {
193:                return (ToolConstants.NS_JAXWS_BINDINGS.equals(node
194:                        .getNamespaceURI()))
195:                        && "javadoc".equals(node.getLocalName());
196:            }
197:
198:            private String getPackageName(Node node) {
199:                Element ele = (Element) node;
200:                return ele.getAttribute("name");
201:            }
202:
203:            private Boolean isAsyncElement(Node node) {
204:                return "enableAsyncMapping".equals(node.getLocalName())
205:                        && ToolConstants.NS_JAXWS_BINDINGS.equals(node
206:                                .getNamespaceURI());
207:            }
208:
209:            private Boolean isWrapperStyle(Node node) {
210:                return "enableWrapperStyle".equals(node.getLocalName())
211:                        && ToolConstants.NS_JAXWS_BINDINGS.equals(node
212:                                .getNamespaceURI());
213:            }
214:
215:            private Boolean getNodeValue(Node node) {
216:                return Boolean.valueOf(node.getTextContent());
217:            }
218:
219:            private Boolean isMIMEElement(Node node) {
220:                return "enableMIMEContent".equals(node.getLocalName())
221:                        && ToolConstants.NS_JAXWS_BINDINGS.equals(node
222:                                .getNamespaceURI());
223:            }
224:
225:            private Node queryXPathNode(Node target, String expression) {
226:                NodeList nlst;
227:                try {
228:                    ContextImpl contextImpl = new ContextImpl(target);
229:                    XPath xpath = XPathFactory.newInstance().newXPath();
230:                    xpath.setNamespaceContext(contextImpl);
231:                    nlst = (NodeList) xpath.evaluate(expression, target,
232:                            XPathConstants.NODESET);
233:                } catch (XPathExpressionException e) {
234:                    Message msg = new Message("XPATH_ERROR", LOG,
235:                            new Object[] { expression });
236:                    throw new ToolException(msg, e);
237:                }
238:
239:                if (nlst.getLength() != 1) {
240:                    Message msg = new Message("ERROR_TARGETNODE_WITH_XPATH",
241:                            LOG, new Object[] { expression });
242:                    throw new ToolException(msg);
243:                }
244:
245:                Node rnode = nlst.item(0);
246:                if (!(rnode instanceof  Element)) {
247:                    return null;
248:                }
249:                return (Element) rnode;
250:            }
251:
252:            class ContextImpl implements  NamespaceContext {
253:                private Node targetNode;
254:
255:                public ContextImpl(Node node) {
256:                    targetNode = node;
257:                }
258:
259:                public String getNamespaceURI(String prefix) {
260:                    return targetNode.getOwnerDocument().lookupNamespaceURI(
261:                            prefix);
262:                }
263:
264:                public String getPrefix(String nsURI) {
265:                    throw new UnsupportedOperationException();
266:                }
267:
268:                public Iterator getPrefixes(String namespaceURI) {
269:                    throw new UnsupportedOperationException();
270:                }
271:            }
272:        }
w_w_w_.ja_v_a__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.