Source Code Cross Referenced for WSDLServices.java in  » Testing » Unicorn » org » savarese » unicorn » 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 » Testing » Unicorn » org.savarese.unicorn.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: WSDLServices.java 6115 2006-01-30 04:50:47Z dfs $
003:         *
004:         * Copyright 2006 Daniel F. Savarese
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         *
010:         *     http://www.savarese.org/software/ApacheLicense-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        package org.savarese.unicorn.util;
020:
021:        import java.util.*;
022:        import javax.management.*;
023:        import javax.xml.namespace.QName;
024:
025:        import javax.wsdl.*;
026:
027:        import org.apache.wsif.*;
028:        import org.apache.wsif.util.*;
029:
030:        /**
031:         * A singleton class that stores convenience methods for converting
032:         * javax.wsdl information types to MBean information types.
033:         */
034:        public final class WSDLServices {
035:
036:            private WSDLServices() {
037:            }
038:
039:            /**
040:             * Converts the WSDL definition of a service to an MBeanInfo type.
041:             *
042:             * @param wsdl The WSDL definition.
043:             * @param service The Web service description.
044:             * @param operationMap A map for mapping operation names to
045:             * javax.wsdl.Operation instances.
046:             * @param portMap A map formapping port names to WSIFPort instances.
047:             * @param inputNames A map for storing the input parameter names for
048:             * each operaton.
049:             * @param outputNames A map for storing the output result names for
050:             * each operation.
051:             * @return The MBeanInfo representation of the WSDL service.
052:             */
053:            public static final MBeanInfo wsdlToMBeanInfo(Definition wsdl,
054:                    Service service, Map<String, Operation> operationMap,
055:                    Map<String, WSIFPort> portMap,
056:                    Map<String, List<String>> inputNames,
057:                    Map<String, List<String>> outputNames)
058:                    throws WSIFException, ClassNotFoundException {
059:                ArrayList<MBeanOperationInfo> operations = new ArrayList<MBeanOperationInfo>();
060:                Map ports = service.getPorts();
061:                WSIFServiceFactory sfactory = WSIFServiceFactory.newInstance();
062:
063:                for (Object portValue : ports.values()) {
064:                    Port port = (Port) portValue;
065:                    PortType portType = port.getBinding().getPortType();
066:                    WSIFService wsifService;
067:                    WSIFPort wsifPort;
068:
069:                    try {
070:                        wsifService = sfactory.getService(wsdl, service,
071:                                portType);
072:                        wsifPort = wsifService.getPort();
073:                    } catch (WSIFException wsife) {
074:                        continue;
075:                    }
076:
077:                    for (Object operation : portType.getOperations()) {
078:                        Operation op = (Operation) operation;
079:                        Input input = op.getInput();
080:                        MBeanParameterInfo[] paramInfo = null;
081:                        String inputName = null;
082:                        String outputName = null;
083:
084:                        portMap.put(op.getName(), wsifPort);
085:
086:                        if (input != null) {
087:                            inputName = input.getName();
088:
089:                            List<String> names = new LinkedList<String>();
090:                            List parts = input.getMessage().getOrderedParts(
091:                                    null);
092:                            _unwrap(wsdl, op.getName(), parts);
093:                            paramInfo = new MBeanParameterInfo[parts.size()];
094:
095:                            Iterator it = parts.iterator();
096:                            for (int i = 0; i < paramInfo.length; ++i) {
097:                                Part part = (Part) it.next();
098:                                String name = part.getName();
099:                                QName typeName = part.getTypeName();
100:
101:                                if (typeName == null)
102:                                    typeName = part.getElementName();
103:                                if (typeName == null)
104:                                    throw new WSIFException(
105:                                            "No type name defined for part "
106:                                                    + name);
107:
108:                                String type;
109:
110:                                try {
111:                                    type = Types.getClass(
112:                                            typeName.getLocalPart()).getName();
113:                                } catch (ClassNotFoundException cnfe) {
114:                                    // This is incorrect.  Have to support for complex types.
115:                                    type = "java.util.HashMap";
116:                                }
117:
118:                                paramInfo[i] = new MBeanParameterInfo(name,
119:                                        type, null);
120:                                names.add(name);
121:                            }
122:
123:                            inputNames.put(op.getName(), names);
124:                        } else
125:                            inputNames.put(op.getName(), null);
126:
127:                        Output output = op.getOutput();
128:                        String returnType;
129:
130:                        if (output != null) {
131:                            outputName = output.getName();
132:
133:                            List<String> names = new LinkedList<String>();
134:                            List parts = output.getMessage().getOrderedParts(
135:                                    null);
136:                            returnType = "java.util.Map";
137:                            _unwrap(wsdl, op.getName() + "Response", parts);
138:
139:                            for (Object p : parts)
140:                                names.add(((Part) p).getName());
141:
142:                            outputNames.put(op.getName(), names);
143:                        } else {
144:                            returnType = "void";
145:                            outputNames.put(op.getName(), null);
146:                        }
147:
148:                        operationMap.put(op.getName(), op);
149:
150:                        operations.add(new MBeanOperationInfo(op.getName(),
151:                                "Port: " + port.getName(), paramInfo,
152:                                returnType, MBeanOperationInfo.UNKNOWN));
153:                    }
154:                }
155:
156:                MBeanOperationInfo[] opinfo = new MBeanOperationInfo[operations
157:                        .size()];
158:                opinfo = operations.toArray(opinfo);
159:
160:                QName qname = service.getQName();
161:                String name = "unknown", desc = "unknown";
162:
163:                if (qname != null) {
164:                    name = qname.getLocalPart();
165:                    desc = qname.toString();
166:                }
167:
168:                return new MBeanInfo(name, desc, null, null, opinfo, null);
169:            }
170:
171:            static void _unwrap(Definition wsdl, String op, List parts)
172:                    throws WSIFException {
173:                Part part = WSIFUtils.getWrappedDocLiteralPart(parts, op);
174:
175:                if (part != null) {
176:                    List unwrapped = WSIFUtils.unWrapPart(part, wsdl);
177:                    parts.remove(part);
178:                    parts.addAll(unwrapped);
179:                }
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.