Source Code Cross Referenced for WrapperUtil.java in  » ESB » open-esb » com » sun » jbi » wsdl11wrapper » util » 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 » ESB » open esb » com.sun.jbi.wsdl11wrapper.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)WrapperUtil.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.wsdl11wrapper.util;
030:
031:        import javax.xml.namespace.QName;
032:        import javax.xml.parsers.DocumentBuilder;
033:        import javax.xml.parsers.DocumentBuilderFactory;
034:        import javax.xml.parsers.ParserConfigurationException;
035:        import org.w3c.dom.Document;
036:        import org.w3c.dom.Element;
037:        import org.w3c.dom.Node;
038:        import org.w3c.dom.NodeList;
039:        import com.sun.jbi.wsdl11wrapper.*;
040:
041:        /*
042:         * WrapperUtil.java
043:         *
044:         * Created on August 12, 2005, 2:00 PM
045:         *
046:         * @author blu
047:         */
048:        public class WrapperUtil {
049:
050:            /**
051:             * Constants to build wsdl 1.1 wrapper, e.g. along the lines of
052:             *   <jbi:message version="1.0" type="wsdl:input wsdl:output or wsdl:fault message attribute value QNAME" name="optional name attribute from wsdl:input etc." xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper">
053:             *       <jbi:part>
054:             *       </jbi:part>
055:             *       <jbi:part>
056:             *       </jbi:part>
057:             *   </jbi:message>
058:             */
059:            public static final String WRAPPER_DEFAULT_NAMESPACE_PREFIX = "jbi";
060:            public static final String WRAPPER_DEFAULT_NAMESPACE = "http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper";
061:            public static final String WRAPPER_MESSAGE = "jbi:message";
062:            public static final String WRAPPER_ATTRIBUTE_VERSION = "version";
063:            public static final String WRAPPER_ATTRIBUTE_VERSION_VALUE = "1.0";
064:            public static final String WRAPPER_ATTRIBUTE_TYPE = "type";
065:            public static final String WRAPPER_ATTRIBUTE_NAME = "name";
066:            public static final String WRAPPER_PART = "jbi:part";
067:
068:            /**
069:             * Creates and returns a JBI message wrapper element. Does NOT add the created element to the normalDoc
070:             * - nor does it popluate the wrapper element with a payload
071:             * @param normalDoc The target document of the normalization
072:             * @param type qualified message name defined in the portmap definition for a given message
073:             * @param name optional name attribute defined in the portmap definition for a given message
074:             * @return the jbi message wrapper element
075:             */
076:            public static Element createJBIMessageWrapper(Document normalDoc,
077:                    QName type, String name) {
078:                Element msgWrapper = normalDoc.createElementNS(
079:                        WRAPPER_DEFAULT_NAMESPACE, WRAPPER_MESSAGE);
080:                msgWrapper.setAttribute(WRAPPER_ATTRIBUTE_VERSION,
081:                        WRAPPER_ATTRIBUTE_VERSION_VALUE);
082:                String prefix = type.getPrefix();
083:                if (prefix == null || prefix.length() == 0) {
084:                    prefix = "msgns";
085:                }
086:                msgWrapper.setAttribute(WRAPPER_ATTRIBUTE_TYPE, prefix + ":"
087:                        + type.getLocalPart());
088:                msgWrapper.setAttribute("xmlns:" + prefix, type
089:                        .getNamespaceURI());
090:
091:                if (name != null) {
092:                    msgWrapper.setAttribute(WRAPPER_ATTRIBUTE_NAME, name);
093:                }
094:
095:                return msgWrapper;
096:            }
097:
098:            /**
099:             * Creates and returns a JBI part wrapper element. Does NOT add the created element to the normalDoc.
100:             * @param normalDoc The target document of the normalization
101:             * @param partName the name of the part
102:             * @param part the part payload which must be created by normalDoc
103:             */
104:            public static Element createJBIWrappedPart(Document normalDoc,
105:                    NodeList part) {
106:                Element wrapperElem = normalDoc.createElement(WRAPPER_PART);
107:                if (part != null) {
108:                    int noOfNodes = part.getLength();
109:                    for (int nodeCount = 0; nodeCount < noOfNodes; nodeCount++) {
110:                        wrapperElem.appendChild(part.item(nodeCount));
111:                    }
112:                }
113:                return wrapperElem;
114:            }
115:
116:            /**
117:             * Creates and returns a JBI part wrapper element. Does NOT add the created element to the normalDoc.
118:             * @param normalDoc The target document of the normalization
119:             * @param partName the name of the part
120:             * @param part the part payload which must be created by normalDoc
121:             */
122:            public static Element createJBIWrappedPart(Document normalDoc,
123:                    Node part) {
124:                Element wrapperElem = normalDoc.createElement(WRAPPER_PART);
125:                if (part != null) {
126:                    wrapperElem.appendChild(part);
127:                }
128:                return wrapperElem;
129:            }
130:
131:            /**
132:             * Creates and returns a JBI part wrapper element. Does NOT add the created element to the normalDoc.
133:             * @param normalDoc The target document of the normalization
134:             * @param partName the name of the part
135:             * @param part the part payload which need not be created by normalDoc
136:             */
137:            public static Element importJBIWrappedPart(Document normalDoc,
138:                    NodeList part) {
139:                Element wrapperElem = normalDoc.createElement(WRAPPER_PART);
140:                if (part != null) {
141:                    int noOfNodes = part.getLength();
142:                    for (int nodeCount = 0; nodeCount < noOfNodes; nodeCount++) {
143:                        Node aNode = part.item(nodeCount);
144:                        if (aNode != null) {
145:                            Node importedPartNode = normalDoc.importNode(aNode,
146:                                    true);
147:                            wrapperElem.appendChild(importedPartNode);
148:                        }
149:                    }
150:                }
151:                return wrapperElem;
152:            }
153:
154:            /**
155:             * Creates and returns a JBI part wrapper element. Does NOT add the created element to the normalDoc.
156:             * @param normalDoc The target document of the normalization
157:             * @param partName the name of the part
158:             * @param part the part payload which need not be created by normalDoc
159:             */
160:            public static Element importJBIWrappedPart(Document normalDoc,
161:                    Node part) {
162:                Element wrapperElem = normalDoc.createElement(WRAPPER_PART);
163:                if (part != null) {
164:                    Node importedPartNode = normalDoc.importNode(part, true);
165:                    wrapperElem.appendChild(importedPartNode);
166:                }
167:                return wrapperElem;
168:            }
169:
170:            /**
171:             * Returns only the first Element inside the part wrapper
172:             * Legally, the jbi:part may contain multiple Elements, or text - but
173:             * in many cases the WSDL will limit this to one element.
174:             *
175:             * (a jbi:part element may legally contain multiple Elements, or text)
176:             * @param wrappedDoc the wrapped document
177:             * @return the first Element in the normalized message part, null if no element is present
178:             * @throws WrapperProcessingException if the part could not be returned
179:             */
180:            public static Element getPartElement(Document wrappedDoc)
181:                    throws WrapperProcessingException {
182:                // Get the jbi message wrapper element
183:                Element jbiMessageWrapper = wrappedDoc.getDocumentElement();
184:                if (jbiMessageWrapper.getTagName().equalsIgnoreCase(
185:                        WRAPPER_MESSAGE)) {
186:                    // The JBI wsdl 1.1 wrapper does not contain part names, but all parts
187:                    // have to appear in the exact order defined in the WSDL
188:                    NodeList childNodesI = jbiMessageWrapper.getChildNodes();
189:                    for (int i = 0, I = childNodesI.getLength(); i < I; i++) {
190:                        Node nodeI = childNodesI.item(i);
191:                        if (nodeI.getNodeType() != Node.ELEMENT_NODE) {
192:                            continue;
193:                        }
194:                        Element jbiPartWrapper = (Element) nodeI;
195:                        if (!jbiPartWrapper.getTagName().equalsIgnoreCase(
196:                                WRAPPER_PART)) {
197:                            continue;
198:                        }
199:                        NodeList childNodesJ = jbiPartWrapper.getChildNodes();
200:                        for (int j = 0, J = childNodesJ.getLength(); j < J; j++) {
201:                            Node nodeJ = childNodesJ.item(j);
202:                            if (nodeJ.getNodeType() == Node.ELEMENT_NODE) {
203:                                return (Element) nodeJ;
204:                            }
205:                        }
206:                    }
207:                }
208:                return null;
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.