Source Code Cross Referenced for SimpleWebServiceUtilImpl.java in  » Portal » Open-Portal » com » sun » portal » providers » simplewebservice » 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 » Portal » Open Portal » com.sun.portal.providers.simplewebservice.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: SimpleWebServiceUtilImpl.java,v 1.1 2003/06/03 10:45:15 sy131129 Exp $
003:         * Copyright 2003 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.providers.simplewebservice.util;
014:
015:        import java.util.ArrayList;
016:        import javax.xml.namespace.QName;
017:
018:        import com.sun.xml.rpc.wsdl.document.schema.SchemaConstants;
019:        import com.sun.xml.rpc.wsdl.document.soap.SOAPConstants;
020:        import com.sun.xml.rpc.util.StructMap;
021:        import com.sun.portal.providers.simplewebservice.ParameterDescriptor;
022:        import com.sun.portal.providers.simplewebservice.SimpleWebServiceParameter;
023:
024:        /*
025:         * Implements the various utility functions exposed via interface SimpleWebServiceUtil.
026:         */
027:
028:        public class SimpleWebServiceUtilImpl implements  SimpleWebServiceUtil {
029:
030:            public QName getSimpleSchemaType(Class type, String encodingToUse) {
031:
032:                if (encodingToUse.equals("")
033:                        || encodingToUse.equals(SchemaConstants.NS_XSD)) {
034:                    if (type.equals(java.lang.String.class)) {
035:                        return SchemaConstants.QNAME_TYPE_STRING;
036:                    } else if (type == Float.class) {
037:                        return SchemaConstants.QNAME_TYPE_FLOAT;
038:                    } else if (type == Integer.class) {
039:                        return SchemaConstants.QNAME_TYPE_INT;
040:                    } else if (type == Double.class) {
041:                        return SchemaConstants.QNAME_TYPE_DOUBLE;
042:                    } else if (type == Boolean.class) {
043:                        return SchemaConstants.QNAME_TYPE_BOOLEAN;
044:                    } else if (type == Long.class) {
045:                        return SchemaConstants.QNAME_TYPE_LONG;
046:                    } else if (type == Byte.class) {
047:                        return SchemaConstants.QNAME_TYPE_BYTE;
048:                    } else if (type == Short.class) {
049:                        return SchemaConstants.QNAME_TYPE_SHORT;
050:                    }
051:                } else if (encodingToUse.equals(SOAPConstants.NS_SOAP_ENCODING)) {
052:                    if (type.equals(java.lang.String.class)) {
053:                        return SOAPConstants.QNAME_TYPE_STRING;
054:                    } else if (type == Float.class) {
055:                        return SOAPConstants.QNAME_TYPE_FLOAT;
056:                    } else if (type == Integer.class) {
057:                        return SOAPConstants.QNAME_TYPE_INT;
058:                    } else if (type == Double.class) {
059:                        return SOAPConstants.QNAME_TYPE_DOUBLE;
060:                    } else if (type == Boolean.class) {
061:                        return SOAPConstants.QNAME_TYPE_BOOLEAN;
062:                    } else if (type == Long.class) {
063:                        return SOAPConstants.QNAME_TYPE_LONG;
064:                    } else if (type == Byte.class) {
065:                        return SOAPConstants.QNAME_TYPE_BYTE;
066:                    } else if (type == Short.class) {
067:                        return SOAPConstants.QNAME_TYPE_SHORT;
068:                    }
069:                }
070:                return null;
071:            }
072:
073:            public Class getSimpleClassType(String type) {
074:
075:                if (type.equals(SimpleWebServiceTypeConstants.STRING)) {
076:                    return String.class;
077:                } else if (type.equals(SimpleWebServiceTypeConstants.FLOAT)) {
078:                    return Float.class;
079:                } else if (type.equals(SimpleWebServiceTypeConstants.INT)) {
080:                    return Integer.class;
081:                } else if (type.equals(SimpleWebServiceTypeConstants.DOUBLE)) {
082:                    return Double.class;
083:                } else if (type.equals(SimpleWebServiceTypeConstants.BOOLEAN)) {
084:                    return Boolean.class;
085:                } else if (type.equals(SimpleWebServiceTypeConstants.LONG)) {
086:                    return Long.class;
087:                } else if (type.equals(SimpleWebServiceTypeConstants.BYTE)) {
088:                    return Byte.class;
089:                } else if (type.equals(SimpleWebServiceTypeConstants.SHORT)) {
090:                    return Short.class;
091:                }
092:                return null;
093:            }
094:
095:            public XList createXListFromSimpleArray(Object returnValues,
096:                    String arrayElementTypeName, String arrayName,
097:                    String arrayNamespace) {
098:
099:                XList xlist = new XList(arrayName, arrayNamespace);
100:
101:                if (arrayElementTypeName
102:                        .equals(SimpleWebServiceTypeConstants.FLOAT)) {
103:                    float[] values = (float[]) returnValues;
104:                    for (int count = 0; count < values.length; count++)
105:                        xlist.add(new Float(values[count]));
106:                } else if (arrayElementTypeName
107:                        .equals(SimpleWebServiceTypeConstants.INT)) {
108:                    int[] values = (int[]) returnValues;
109:                    for (int count = 0; count < values.length; count++)
110:                        xlist.add(new Integer(values[count]));
111:                } else if (arrayElementTypeName
112:                        .equals(SimpleWebServiceTypeConstants.LONG)) {
113:                    long[] values = (long[]) returnValues;
114:                    for (int count = 0; count < values.length; count++)
115:                        xlist.add(new Long(values[count]));
116:                } else if (arrayElementTypeName
117:                        .equals(SimpleWebServiceTypeConstants.DOUBLE)) {
118:                    double[] values = (double[]) returnValues;
119:                    for (int count = 0; count < values.length; count++)
120:                        xlist.add(new Double(values[count]));
121:                } else if (arrayElementTypeName
122:                        .equals(SimpleWebServiceTypeConstants.SHORT)) {
123:                    short[] values = (short[]) returnValues;
124:                    for (int count = 0; count < values.length; count++)
125:                        xlist.add(new Short(values[count]));
126:                } else if (arrayElementTypeName
127:                        .equals(SimpleWebServiceTypeConstants.BYTE)) {
128:                    byte[] values = (byte[]) returnValues;
129:                    for (int count = 0; count < values.length; count++)
130:                        xlist.add(new Byte(values[count]));
131:                } else if (arrayElementTypeName
132:                        .equals(SimpleWebServiceTypeConstants.BOOLEAN)) {
133:                    boolean[] values = (boolean[]) returnValues;
134:                    for (int count = 0; count < values.length; count++)
135:                        xlist.add(new Boolean(values[count]));
136:                } else if (arrayElementTypeName
137:                        .equals(SimpleWebServiceTypeConstants.STRING)) {
138:                    String[] values = (String[]) returnValues;
139:                    for (int count = 0; count < values.length; count++)
140:                        xlist.add(values[count]);
141:                }
142:                return xlist;
143:            }
144:
145:            /*
146:             * Returns an XList of SimpleWebServiceParameter. The returned XList is constructed using
147:             * the meta data ParameterDescriptor, outputParamDesc. The outputParamDesc is expected
148:             * to be the ParameterDescriptor of the array. Any nested objects are also constructed as
149:             * SimpleWebServiceParameters, using meta data in outputParamDesc and its nested objects.
150:             */
151:            public XList createXListFromComplexArray(Object returnValues,
152:                    ParameterDescriptor outputParamDesc) {
153:
154:                XList paramDescsList = (XList) outputParamDesc.getValue();
155:                XList swsXList = new XList(paramDescsList.getComplexTypeName(),
156:                        paramDescsList.getTargetNameSpace());
157:
158:                // Complex arrays returned by CollectionSerializer are expected in an ArrayList.
159:                // However, an array is returned sometimes.
160:                if (returnValues instanceof  ArrayList) {
161:                    ArrayList returnValuesList = (ArrayList) returnValues;
162:
163:                    for (int count = 0; count < returnValuesList.size(); count++) {
164:                        swsXList.add(createSWSParameterFromComplexType(
165:                                returnValuesList.get(count),
166:                                (ParameterDescriptor) paramDescsList.get(0)));
167:                    }
168:                } else if (returnValues instanceof  StructMap[]) {
169:                    StructMap[] returnValuesList = (StructMap[]) returnValues;
170:
171:                    for (int count = 0; count < returnValuesList.length; count++) {
172:                        swsXList.add(createSWSParameterFromComplexType(
173:                                returnValuesList[count],
174:                                (ParameterDescriptor) paramDescsList.get(0)));
175:                    }
176:                }
177:
178:                return swsXList;
179:            }
180:
181:            /*
182:             * Returns a SimpleWebServiceParameter. The returned SimpleWebServiceParameter is
183:             * constructed using the meta data ParameterDescriptor, outputParamDesc. Any nested objects
184:             * are also constructed as SimpleWebServiceParameters, using meta data in outputParamDesc
185:             * and its nested objects.
186:             */
187:            public SimpleWebServiceParameter createSWSParameterFromComplexType(
188:                    Object returnValue, ParameterDescriptor outputParamDesc) {
189:
190:                XList paramDescsList = (XList) outputParamDesc.getValue();
191:
192:                // Complex object returned by XMapSerializer is expected to be a StructMap
193:                StructMap outValue = (StructMap) returnValue;
194:
195:                SimpleWebServiceParameter swsOuterParam = null;
196:
197:                // Create SimpleWebServiceParameter for complex type
198:                XList swsXList = new XList(paramDescsList.getComplexTypeName(),
199:                        paramDescsList.getTargetNameSpace());
200:                swsOuterParam = new SimpleWebServiceParameter(outputParamDesc,
201:                        swsXList);
202:
203:                // Create SimpleWebServiceParameters for complex type's elements
204:                for (int count = 0; count < paramDescsList.size(); count++) {
205:                    SimpleWebServiceParameter innerSWSParam = null;
206:                    ParameterDescriptor innerParamDesc = (ParameterDescriptor) paramDescsList
207:                            .get(count);
208:
209:                    QName currentParamName = new QName("", innerParamDesc
210:                            .getName());
211:
212:                    Object value = outValue.get(currentParamName);
213:
214:                    if (innerParamDesc.getType() == XList.class) {
215:                        // Element is Array type or Complex type.
216:                        // TODO - Handle simple arrays
217:                        if (innerParamDesc.isArrayType()) {
218:                            innerSWSParam = new SimpleWebServiceParameter(
219:                                    innerParamDesc,
220:                                    createXListFromComplexArray(value,
221:                                            innerParamDesc));
222:                        } else {
223:                            innerSWSParam = createSWSParameterFromComplexType(
224:                                    value, innerParamDesc);
225:                        }
226:                    } else {
227:                        // Simple type element. So create the SWSParameter.
228:                        innerSWSParam = new SimpleWebServiceParameter(
229:                                innerParamDesc, value.toString());
230:                    }
231:                    swsXList.add(innerSWSParam);
232:                }
233:                return swsOuterParam;
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.