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


001:        /**
002:         * $Id: SerializationContext.java,v 1.2 2003/12/01 10:47:40 vv138407 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.rpc;
014:
015:        import javax.xml.namespace.QName;
016:
017:        import com.sun.xml.rpc.encoding.CombinedSerializer;
018:        import com.sun.xml.rpc.encoding.simpletype.SimpleTypeEncoder;
019:        import com.sun.xml.rpc.encoding.simpletype.XSDByteEncoder;
020:        import com.sun.xml.rpc.encoding.simpletype.XSDBooleanEncoder;
021:        import com.sun.xml.rpc.encoding.simpletype.XSDDoubleEncoder;
022:        import com.sun.xml.rpc.encoding.simpletype.XSDFloatEncoder;
023:        import com.sun.xml.rpc.encoding.simpletype.XSDIntegerEncoder;
024:        import com.sun.xml.rpc.encoding.simpletype.XSDIntEncoder;
025:        import com.sun.xml.rpc.encoding.simpletype.XSDLongEncoder;
026:        import com.sun.xml.rpc.encoding.simpletype.XSDShortEncoder;
027:        import com.sun.xml.rpc.encoding.simpletype.XSDStringEncoder;
028:        import com.sun.xml.rpc.wsdl.document.schema.SchemaConstants;
029:        import com.sun.portal.providers.simplewebservice.ParameterDescriptor;
030:        import com.sun.portal.providers.simplewebservice.util.XList;
031:        import com.sun.portal.providers.simplewebservice.util.SimpleWebServiceTypeConstants;
032:
033:        /*
034:         * Utility class to create the serialization context
035:         * information for the given parameter
036:         */
037:
038:        class SerializationContext {
039:
040:            // SimpleTypeHandler specific properties
041:            SimpleTypeEncoder primitiveTypeEncoder;
042:            CombinedSerializer serializer;
043:
044:            // SimpleType and ComplexType Handler properties
045:            Class typeHolderClass;
046:            QName typeQName;
047:            QName typeArrayQName;
048:            String registryKeyName;
049:
050:            SerializationContext(SimpleTypeEncoder encoder,
051:                    Class proxyClassName, QName typeQName, QName arrayTypeQName) {
052:                this .primitiveTypeEncoder = encoder;
053:                this .typeHolderClass = proxyClassName;
054:                this .typeQName = typeQName;
055:                this .typeArrayQName = arrayTypeQName;
056:            }
057:
058:            SerializationContext(Class proxyClassName, QName typeQName,
059:                    QName arrayTypeQName) {
060:                this .typeHolderClass = proxyClassName;
061:                this .typeQName = typeQName;
062:                this .typeArrayQName = arrayTypeQName;
063:            }
064:
065:            public static SerializationContext createSimpleSerializationContext(
066:                    ParameterDescriptor descriptor) {
067:
068:                SerializationContext context = null;
069:                String nmSpace = null;
070:                String arrayTypeName = null;
071:                String arrayElementTypeName = null;
072:
073:                if (descriptor.isArrayType()) {
074:                    XList value = (XList) descriptor.getValue();
075:                    // Namespace of Array type
076:                    nmSpace = value.getTargetNameSpace();
077:                    // Array type name
078:                    arrayTypeName = value.getComplexTypeName();
079:                    // Array element's type name
080:                    arrayElementTypeName = descriptor.getArrayTypeName();
081:
082:                } else {
083:                    nmSpace = "";
084:                    arrayTypeName = "";
085:                    arrayElementTypeName = descriptor.getType().getName();
086:                    arrayElementTypeName = arrayElementTypeName.substring(
087:                            arrayElementTypeName.lastIndexOf('.') + 1)
088:                            .toLowerCase();
089:                }
090:
091:                if (arrayElementTypeName
092:                        .equals(SimpleWebServiceTypeConstants.STRING)) {
093:                    context = new SerializationContext(XSDStringEncoder
094:                            .getInstance(), // Encoder to use for array element
095:                            java.lang.String.class, // Java class of array element type
096:                            new QName(nmSpace, arrayTypeName), // XML type of array
097:                            SchemaConstants.QNAME_TYPE_STRING); // XML type of array element
098:                } else if (arrayElementTypeName
099:                        .equals(SimpleWebServiceTypeConstants.FLOAT)) {
100:                    context = new SerializationContext(XSDFloatEncoder
101:                            .getInstance(), float.class, new QName(nmSpace,
102:                            arrayTypeName), SchemaConstants.QNAME_TYPE_FLOAT);
103:                } else if (arrayElementTypeName
104:                        .equals(SimpleWebServiceTypeConstants.INT)
105:                        || arrayElementTypeName
106:                                .equals(SimpleWebServiceTypeConstants.INTEGER)) {
107:                    context = new SerializationContext(XSDIntEncoder
108:                            .getInstance(), int.class, new QName(nmSpace,
109:                            arrayTypeName), SchemaConstants.QNAME_TYPE_INT);
110:                } else if (arrayElementTypeName
111:                        .equals(SimpleWebServiceTypeConstants.DOUBLE)) {
112:                    context = new SerializationContext(XSDDoubleEncoder
113:                            .getInstance(), double.class, new QName(nmSpace,
114:                            arrayTypeName), SchemaConstants.QNAME_TYPE_DOUBLE);
115:                } else if (arrayElementTypeName
116:                        .equals(SimpleWebServiceTypeConstants.BOOLEAN)) {
117:                    context = new SerializationContext(XSDBooleanEncoder
118:                            .getInstance(), boolean.class, new QName(nmSpace,
119:                            arrayTypeName), SchemaConstants.QNAME_TYPE_BOOLEAN);
120:                } else if (arrayElementTypeName
121:                        .equals(SimpleWebServiceTypeConstants.LONG)) {
122:                    context = new SerializationContext(XSDLongEncoder
123:                            .getInstance(), long.class, new QName(nmSpace,
124:                            arrayTypeName), SchemaConstants.QNAME_TYPE_LONG);
125:                } else if (arrayElementTypeName
126:                        .equals(SimpleWebServiceTypeConstants.BYTE)) {
127:                    context = new SerializationContext(XSDByteEncoder
128:                            .getInstance(), byte.class, new QName(nmSpace,
129:                            arrayTypeName), SchemaConstants.QNAME_TYPE_BYTE);
130:                } else if (arrayElementTypeName
131:                        .equals(SimpleWebServiceTypeConstants.SHORT)) {
132:                    context = new SerializationContext(XSDShortEncoder
133:                            .getInstance(), short.class, new QName(nmSpace,
134:                            arrayTypeName), SchemaConstants.QNAME_TYPE_SHORT);
135:                }
136:                //System.out.println(context.simpleToString());
137:                return context;
138:            }
139:
140:            public static SerializationContext createComplexSerializationContext(
141:                    ParameterDescriptor descriptor) {
142:
143:                SerializationContext context = null;
144:
145:                XList value = (XList) descriptor.getValue();
146:                // Note that the value of type attribute in <part name ="xyz" type = "complexType">
147:                // is what we need to register. This is the name of the descriptor in complexType
148:                // descriptor's case. Also, in our case the namespace is in the XList.
149:                String typeName = value.getComplexTypeName();
150:                String typeNameSpace = value.getTargetNameSpace();
151:
152:                QName complexParamArrayQName = null;
153:                QName complexParamQName = null;
154:
155:                if (descriptor.isArrayType()) {
156:                    complexParamQName = new QName(typeNameSpace, typeName);
157:                    complexParamArrayQName = new QName(typeNameSpace,
158:                            descriptor.getArrayTypeName());
159:                } else {
160:                    complexParamQName = new QName(typeNameSpace, typeName);
161:                }
162:
163:                context = new SerializationContext(value.getClass(), // holder/proxy class
164:                        complexParamQName, // complextype QName
165:                        complexParamArrayQName); // complextype array's QName
166:
167:                //System.out.println(context.complexToString());
168:                return context;
169:            }
170:
171:            String simpleToString() {
172:                return "Encoder is " + primitiveTypeEncoder
173:                        + ", \nElement class name is "
174:                        + typeHolderClass.toString()
175:                        + ", \nQName of array class is " + typeQName.toString()
176:                        + ", \nQName of element class is "
177:                        + typeArrayQName.toString();
178:            }
179:
180:            String complexToString() {
181:                return "\nQName of element class is " + typeQName.toString();
182:
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.