Source Code Cross Referenced for WSDLDocument.java in  » 6.0-JDK-Modules-com.sun » xml » com » sun » xml » 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 » xml » com.sun.xml.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:
026:        package com.sun.xml.internal.ws.wsdl.parser;
027:
028:        import com.sun.xml.internal.ws.model.ParameterBinding;
029:        import com.sun.xml.internal.ws.model.Mode;
030:
031:        import javax.xml.namespace.QName;
032:        import javax.xml.ws.soap.SOAPBinding;
033:
034:        import java.util.ArrayList;
035:        import java.util.Collection;
036:        import java.util.HashMap;
037:        import java.util.Iterator;
038:        import java.util.LinkedHashMap;
039:        import java.util.List;
040:        import java.util.Map;
041:
042:        public class WSDLDocument {
043:            protected Map<QName, Message> messages;
044:            protected Map<QName, PortType> portTypes;
045:            protected Map<QName, Binding> bindings;
046:            protected Map<QName, Service> services;
047:
048:            public WSDLDocument() {
049:                messages = new HashMap<QName, Message>();
050:                portTypes = new HashMap<QName, PortType>();
051:                bindings = new HashMap<QName, Binding>();
052:                services = new LinkedHashMap<QName, Service>();
053:            }
054:
055:            public void addMessage(Message msg) {
056:                messages.put(msg.getName(), msg);
057:            }
058:
059:            public Message getMessage(QName name) {
060:                return messages.get(name);
061:            }
062:
063:            public void addPortType(PortType pt) {
064:                portTypes.put(pt.getName(), pt);
065:            }
066:
067:            public PortType getPortType(QName name) {
068:                return portTypes.get(name);
069:            }
070:
071:            public void addBinding(Binding binding) {
072:                bindings.put(binding.getName(), binding);
073:            }
074:
075:            public Binding getBinding(QName name) {
076:                return bindings.get(name);
077:            }
078:
079:            public void addService(Service svc) {
080:                services.put(svc.getName(), svc);
081:            }
082:
083:            public Service getService(QName name) {
084:                return services.get(name);
085:            }
086:
087:            public Map<QName, Service> getServices() {
088:                return services;
089:            }
090:
091:            /**
092:             * Returns the first service QName from insertion order
093:             * @return
094:             */
095:            public QName getFirstServiceName() {
096:                if (services.isEmpty())
097:                    return null;
098:                return services.values().iterator().next().getName();
099:            }
100:
101:            /**
102:             * Returns first port QName from first service as per the insertion order
103:             * @return
104:             */
105:            public QName getFirstPortName() {
106:                if (services.isEmpty())
107:                    return null;
108:                Service service = services.values().iterator().next();
109:                Iterator<QName> iter = service.keySet().iterator();
110:                QName port = (iter.hasNext()) ? iter.next() : null;
111:                return port;
112:            }
113:
114:            private Port getFirstPort() {
115:                if (services.isEmpty())
116:                    return null;
117:                Service service = services.values().iterator().next();
118:                Collection<Port> coll = service.values();
119:                Port port = (coll != null) ? ((coll.iterator().hasNext()) ? coll
120:                        .iterator().next()
121:                        : null)
122:                        : null;
123:                return port;
124:            }
125:
126:            /**
127:             * Returns biningId of the first port
128:             * @return
129:             */
130:            public String getBindingId() {
131:                Port port = getFirstPort();
132:                if (port == null)
133:                    return null;
134:                Binding binding = bindings.get(port.getBindingName());
135:                if (binding == null)
136:                    return null;
137:                return binding.getBindingId();
138:            }
139:
140:            /**
141:             * Gives the binding Id of the given service and port
142:             * @param service
143:             * @param port
144:             * @return
145:             */
146:            public String getBindingId(QName service, QName port) {
147:                Service s = services.get(service);
148:                if (s != null) {
149:                    Port p = s.get(port);
150:                    if (p != null) {
151:                        Binding b = bindings.get(p.getBindingName());
152:                        if (b != null)
153:                            return b.getBindingId();
154:                    }
155:
156:                }
157:                return null;
158:            }
159:
160:            /**
161:             *
162:             * @param serviceName non-null service QName
163:             * @param portName    non-null port QName
164:             * @return
165:             *          BindingOperation on success otherwise null. throws NPE if any of the parameters null
166:             */
167:            public Binding getBinding(QName serviceName, QName portName) {
168:                Service service = services.get(serviceName);
169:                if (service != null) {
170:                    Port port = service.get(portName);
171:                    if (port != null) {
172:                        QName bindingName = port.getBindingName();
173:                        return bindings.get(bindingName);
174:                    }
175:                }
176:                return null;
177:            }
178:
179:            /**
180:             * Returns the bindings for the given bindingId
181:             * @param service  non-null service
182:             * @param bindingId  non-null binding id
183:             * @return
184:             */
185:            public List<Binding> getBindings(Service service, String bindingId) {
186:                List<Binding> bs = new ArrayList<Binding>();
187:                Collection<Port> ports = service.values();
188:                if (ports.isEmpty())
189:                    return bs;
190:                for (Port port : ports) {
191:                    Binding b = bindings.get(port.getName());
192:                    if (b == null)
193:                        return bs;
194:                    if (b.equals(bindingId))
195:                        bs.add(b);
196:                }
197:                return bs;
198:            }
199:
200:            public QName getPortName(QName serviceName, QName portType) {
201:                Service service = services.get(serviceName);
202:                for (Port port : service.values()) {
203:                    QName bindingName = port.getBindingName();
204:                    assert (bindingName != null);
205:                    Binding binding = bindings.get(bindingName);
206:                    QName ptName = binding.getPortTypeName();
207:                    assert (ptName != null);
208:                    if (ptName.equals(portType))
209:                        return port.getName();
210:                }
211:                return null;
212:            }
213:
214:            public void finalizeBinding(Binding binding) {
215:                assert (binding != null);
216:                QName portTypeName = binding.getPortTypeName();
217:                if (portTypeName == null)
218:                    return;
219:                PortType pt = portTypes.get(portTypeName);
220:                if (pt == null)
221:                    return;
222:                for (String op : binding.keySet()) {
223:                    PortTypeOperation pto = pt.get(op);
224:                    if (pto == null)
225:                        return;
226:                    QName inMsgName = pto.getInputMessage();
227:                    if (inMsgName == null)
228:                        continue;
229:                    Message inMsg = messages.get(inMsgName);
230:                    BindingOperation bo = binding.get(op);
231:                    int bodyindex = 0;
232:                    if (inMsg != null) {
233:                        for (String name : inMsg) {
234:                            ParameterBinding pb = bo.getInputBinding(name);
235:                            if (pb.isBody()) {
236:                                bo.addPart(new Part(name, pb, bodyindex++),
237:                                        Mode.IN);
238:                            }
239:                        }
240:                    }
241:                    bodyindex = 0;
242:                    QName outMsgName = pto.getOutputMessage();
243:                    if (outMsgName == null)
244:                        continue;
245:                    Message outMsg = messages.get(outMsgName);
246:                    if (outMsg != null) {
247:                        for (String name : outMsg) {
248:                            ParameterBinding pb = bo.getOutputBinding(name);
249:                            if (pb.isBody()) {
250:                                bo.addPart(new Part(name, pb, bodyindex++),
251:                                        Mode.OUT);
252:                            }
253:                        }
254:                    }
255:                }
256:            }
257:        }
ww__w.ja__v__a__2_s__._c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.