Source Code Cross Referenced for WSDLHelper.java in  » ESB » celtix-1.0 » org » objectweb » celtix » helpers » 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 » celtix 1.0 » org.objectweb.celtix.helpers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.helpers;
002:
003:        import java.io.File;
004:        import java.lang.annotation.Annotation;
005:        import java.lang.reflect.Method;
006:        import java.util.*;
007:        import javax.jws.WebParam;
008:        import javax.wsdl.Binding;
009:        import javax.wsdl.BindingInput;
010:        import javax.wsdl.BindingOperation;
011:        import javax.wsdl.BindingOutput;
012:        import javax.wsdl.Definition;
013:        import javax.wsdl.Input;
014:        import javax.wsdl.Message;
015:        import javax.wsdl.Operation;
016:        import javax.wsdl.Output;
017:        import javax.wsdl.Part;
018:        import javax.wsdl.PortType;
019:        import javax.wsdl.extensions.soap.SOAPBinding;
020:        import javax.wsdl.extensions.soap.SOAPBody;
021:        import javax.wsdl.extensions.soap.SOAPHeader;
022:        import javax.wsdl.extensions.soap.SOAPOperation;
023:        import javax.wsdl.factory.WSDLFactory;
024:        import javax.wsdl.xml.WSDLReader;
025:        import javax.xml.ws.RequestWrapper;
026:
027:        public class WSDLHelper {
028:
029:            public BindingOperation getBindingOperation(Definition def,
030:                    String operationName) {
031:                if (operationName == null) {
032:                    return null;
033:                }
034:                Iterator ite = def.getBindings().values().iterator();
035:                while (ite.hasNext()) {
036:                    Binding binding = (Binding) ite.next();
037:                    Iterator ite1 = binding.getBindingOperations().iterator();
038:                    while (ite1.hasNext()) {
039:                        BindingOperation bop = (BindingOperation) ite1.next();
040:                        if (bop.getName().equals(operationName)) {
041:                            return bop;
042:                        }
043:                    }
044:                }
045:                return null;
046:            }
047:
048:            public BindingOperation getBindingOperation(Binding binding,
049:                    String operationName) {
050:                if (operationName == null) {
051:                    return null;
052:                }
053:                List bindingOperations = binding.getBindingOperations();
054:                for (Iterator iter = bindingOperations.iterator(); iter
055:                        .hasNext();) {
056:                    BindingOperation bindingOperation = (BindingOperation) iter
057:                            .next();
058:                    if (operationName.equals(bindingOperation.getName())) {
059:                        return bindingOperation;
060:                    }
061:                }
062:                return null;
063:            }
064:
065:            public Map getParts(Operation operation, boolean out) {
066:                Message message = null;
067:                if (out) {
068:                    Output output = operation.getOutput();
069:                    message = output.getMessage();
070:                } else {
071:                    Input input = operation.getInput();
072:                    message = input.getMessage();
073:                }
074:                return message.getParts() == null ? new HashMap() : message
075:                        .getParts();
076:            }
077:
078:            public javax.jws.soap.SOAPBinding getBindingAnnotationFromClass(
079:                    List<Class<?>> classList) {
080:                javax.jws.soap.SOAPBinding sb = null;
081:                for (Class<?> c : classList) {
082:                    sb = c.getAnnotation(javax.jws.soap.SOAPBinding.class);
083:                    if (null != sb) {
084:                        break;
085:                    }
086:                }
087:                return sb;
088:            }
089:
090:            public javax.jws.soap.SOAPBinding getBindingAnnotationFromMethod(
091:                    Method m) {
092:                javax.jws.soap.SOAPBinding sb = null;
093:                if (null != m) {
094:                    sb = m.getAnnotation(javax.jws.soap.SOAPBinding.class);
095:                }
096:                return sb;
097:            }
098:
099:            public WebParam getWebParamAnnotation(Annotation[] pa) {
100:                WebParam wp = null;
101:
102:                if (null != pa) {
103:                    for (Annotation annotation : pa) {
104:                        if (WebParam.class.equals(annotation.annotationType())) {
105:                            wp = (WebParam) annotation;
106:                            break;
107:                        }
108:                    }
109:                }
110:                return wp;
111:            }
112:
113:            public RequestWrapper getRequestWrapperAnnotation(Method m) {
114:                RequestWrapper rw = null;
115:
116:                if (null != m) {
117:                    rw = m.getAnnotation(RequestWrapper.class);
118:                }
119:                return rw;
120:            }
121:
122:            public List<PortType> getPortTypes(Definition def) {
123:                List<PortType> portTypes = new ArrayList<PortType>();
124:                Iterator ite = def.getPortTypes().values().iterator();
125:                while (ite.hasNext()) {
126:                    PortType portType = (PortType) ite.next();
127:                    portTypes.add(portType);
128:                }
129:                return portTypes;
130:            }
131:
132:            public List<Part> getInMessageParts(Operation operation) {
133:                Input input = operation.getInput();
134:                List<Part> partsList = new ArrayList<Part>();
135:                if (input != null) {
136:                    Iterator ite = input.getMessage().getParts().values()
137:                            .iterator();
138:                    while (ite.hasNext()) {
139:                        partsList.add((Part) ite.next());
140:                    }
141:                }
142:                return partsList;
143:            }
144:
145:            public List<Part> getOutMessageParts(Operation operation) {
146:                Output output = operation.getOutput();
147:                List<Part> partsList = new ArrayList<Part>();
148:                if (output != null) {
149:                    Iterator ite = output.getMessage().getParts().values()
150:                            .iterator();
151:                    while (ite.hasNext()) {
152:                        partsList.add((Part) ite.next());
153:                    }
154:                }
155:                return partsList;
156:            }
157:
158:            public String getBindingStyle(Binding binding) {
159:                Iterator ite = binding.getExtensibilityElements().iterator();
160:                while (ite.hasNext()) {
161:                    Object obj = ite.next();
162:                    if (obj instanceof  SOAPBinding) {
163:                        return ((SOAPBinding) obj).getStyle();
164:                    }
165:                }
166:                return "";
167:            }
168:
169:            public Binding getBinding(BindingOperation bop, Definition def) {
170:                Iterator ite = def.getBindings().values().iterator();
171:                while (ite.hasNext()) {
172:                    Binding binding = (Binding) ite.next();
173:                    for (Iterator ite2 = binding.getBindingOperations()
174:                            .iterator(); ite2.hasNext();) {
175:                        BindingOperation bindingOperation = (BindingOperation) ite2
176:                                .next();
177:                        if (bindingOperation.getName().equals(bop)) {
178:                            return binding;
179:                        }
180:                    }
181:                }
182:                return null;
183:            }
184:
185:            public String getSOAPOperationStyle(BindingOperation bop) {
186:                String style = "";
187:                Iterator ite = bop.getExtensibilityElements().iterator();
188:                while (ite.hasNext()) {
189:                    Object obj = ite.next();
190:                    if (obj instanceof  SOAPOperation) {
191:                        SOAPOperation soapOperation = (SOAPOperation) obj;
192:                        style = soapOperation.getStyle();
193:                        break;
194:                    }
195:                }
196:                return style;
197:
198:            }
199:
200:            public SOAPBody getBindingInputSOAPBody(BindingOperation bop) {
201:                BindingInput bindingInput = bop.getBindingInput();
202:                if (bindingInput != null) {
203:                    Iterator ite = bindingInput.getExtensibilityElements()
204:                            .iterator();
205:                    while (ite.hasNext()) {
206:                        Object obj = ite.next();
207:                        if (obj instanceof  SOAPBody) {
208:                            return (SOAPBody) obj;
209:                        }
210:                    }
211:                }
212:
213:                return null;
214:            }
215:
216:            public SOAPHeader getBindingInputSOAPHeader(BindingOperation bop) {
217:                BindingInput bindingInput = bop.getBindingInput();
218:                if (bindingInput != null) {
219:                    Iterator ite = bindingInput.getExtensibilityElements()
220:                            .iterator();
221:                    while (ite.hasNext()) {
222:                        Object obj = ite.next();
223:                        if (obj instanceof  SOAPHeader) {
224:                            return (SOAPHeader) obj;
225:                        }
226:                    }
227:                }
228:
229:                return null;
230:            }
231:
232:            public SOAPHeader getBindingOutputSOAPHeader(BindingOperation bop) {
233:                BindingOutput bindingOutput = bop.getBindingOutput();
234:                if (bindingOutput != null) {
235:                    Iterator ite = bindingOutput.getExtensibilityElements()
236:                            .iterator();
237:                    while (ite.hasNext()) {
238:                        Object obj = ite.next();
239:                        if (obj instanceof  SOAPHeader) {
240:                            return (SOAPHeader) obj;
241:                        }
242:                    }
243:                }
244:
245:                return null;
246:            }
247:
248:            public SOAPBody getBindingOutputSOAPBody(BindingOperation bop) {
249:                BindingOutput bindingOutput = bop.getBindingOutput();
250:                if (bindingOutput != null) {
251:                    Iterator ite = bindingOutput.getExtensibilityElements()
252:                            .iterator();
253:                    while (ite.hasNext()) {
254:                        Object obj = ite.next();
255:                        if (obj instanceof  SOAPBody) {
256:                            return (SOAPBody) obj;
257:                        }
258:                    }
259:                }
260:
261:                return null;
262:            }
263:
264:            public Definition getDefinition(File wsdlFile) throws Exception {
265:                WSDLFactory wsdlFactory = WSDLFactory.newInstance();
266:                WSDLReader reader = wsdlFactory.newWSDLReader();
267:                reader.setFeature("javax.wsdl.verbose", false);
268:                return reader.readWSDL(wsdlFile.toURL().toString());
269:            }
270:
271:            public boolean isMixedStyle(Binding binding) {
272:                Iterator ite = binding.getExtensibilityElements().iterator();
273:                String bindingStyle = "";
274:                String previousOpStyle = "";
275:                String style = "";
276:                while (ite.hasNext()) {
277:                    Object obj = ite.next();
278:                    if (obj instanceof  SOAPBinding) {
279:                        SOAPBinding soapBinding = (SOAPBinding) obj;
280:                        bindingStyle = soapBinding.getStyle();
281:                        if (bindingStyle == null) {
282:                            bindingStyle = "";
283:                        }
284:                    }
285:                }
286:                Iterator ite2 = binding.getBindingOperations().iterator();
287:                while (ite2.hasNext()) {
288:                    BindingOperation bop = (BindingOperation) ite2.next();
289:                    Iterator ite3 = bop.getExtensibilityElements().iterator();
290:                    while (ite3.hasNext()) {
291:                        Object obj = ite3.next();
292:
293:                        if (obj instanceof  SOAPOperation) {
294:                            SOAPOperation soapOperation = (SOAPOperation) obj;
295:                            style = soapOperation.getStyle();
296:                            if (style == null) {
297:                                style = "";
298:                            }
299:
300:                            if ("".equals(bindingStyle)
301:                                    && "".equals(previousOpStyle)
302:                                    || "".equals(bindingStyle)
303:                                    && previousOpStyle.equalsIgnoreCase(style)) {
304:                                previousOpStyle = style;
305:
306:                            } else if (!"".equals(bindingStyle)
307:                                    && "".equals(previousOpStyle)
308:                                    && bindingStyle.equalsIgnoreCase(style)
309:                                    || bindingStyle
310:                                            .equalsIgnoreCase(previousOpStyle)
311:                                    && bindingStyle.equalsIgnoreCase(style)) {
312:                                previousOpStyle = style;
313:                            } else if (!"".equals(bindingStyle)
314:                                    && "".equals(style)
315:                                    && "".equals(previousOpStyle)) {
316:                                continue;
317:                            } else {
318:                                return true;
319:                            }
320:
321:                        }
322:
323:                    }
324:                }
325:
326:                return false;
327:
328:            }
329:
330:            public String getCanonicalBindingStyle(Binding binding) {
331:                String bindingStyle = getBindingStyle(binding);
332:                if (bindingStyle != null && !("".equals(bindingStyle))) {
333:                    return bindingStyle;
334:                }
335:                for (Iterator ite2 = binding.getBindingOperations().iterator(); ite2
336:                        .hasNext();) {
337:                    BindingOperation bindingOp = (BindingOperation) ite2.next();
338:                    String bopStyle = getSOAPOperationStyle(bindingOp);
339:                    if (!"".equals(bopStyle)) {
340:                        return bopStyle;
341:                    }
342:                }
343:                return "";
344:
345:            }
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.