KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > encoding > DefaultSOAPEncodingTypeMappingImpl


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.axis.encoding;
18
19 import org.apache.axis.Constants;
20 import org.apache.axis.MessageContext;
21 import org.apache.axis.encoding.ser.Base64SerializerFactory;
22 import org.apache.axis.encoding.ser.Base64DeserializerFactory;
23 import org.apache.axis.encoding.ser.ArraySerializerFactory;
24 import org.apache.axis.encoding.ser.ArrayDeserializerFactory;
25
26 /**
27  *
28  * This is the implementation of the axis Default JAX-RPC SOAP Encoding TypeMapping
29  * See DefaultTypeMapping for more information.
30  *
31  * @author Rich Scheuerle (scheu@us.ibm.com)
32  */

33 public class DefaultSOAPEncodingTypeMappingImpl extends DefaultTypeMappingImpl {
34     private static DefaultSOAPEncodingTypeMappingImpl tm = null;
35     /**
36      * Construct TypeMapping
37      */

38     public static synchronized TypeMappingImpl getSingleton() {
39         if (tm == null) {
40             tm = new DefaultSOAPEncodingTypeMappingImpl();
41         }
42         return tm;
43     }
44
45     public static TypeMappingDelegate createWithDelegate() {
46         TypeMappingDelegate ret = new TypeMappingDelegate(new DefaultSOAPEncodingTypeMappingImpl());
47         MessageContext mc = MessageContext.getCurrentContext();
48         TypeMappingDelegate tm = null;
49         if (mc != null) {
50             tm = (TypeMappingDelegate)mc.getTypeMappingRegistry().getDefaultTypeMapping();
51         } else {
52             tm = DefaultTypeMappingImpl.getSingletonDelegate();
53         }
54         ret.setNext(tm);
55         return ret;
56     }
57
58     protected DefaultSOAPEncodingTypeMappingImpl() {
59         super(true);
60         registerSOAPTypes();
61     }
62
63     /**
64      * Register the SOAP encoding data types. This is split out into a
65      * method so it can happen either before or after the XSD mappings.
66      */

67     private void registerSOAPTypes() {
68         // SOAP Encoded strings are treated as primitives.
69
// Everything else is not.
70
myRegisterSimple(Constants.SOAP_STRING, java.lang.String JavaDoc.class);
71         myRegisterSimple(Constants.SOAP_BOOLEAN, java.lang.Boolean JavaDoc.class);
72         myRegisterSimple(Constants.SOAP_DOUBLE, java.lang.Double JavaDoc.class);
73         myRegisterSimple(Constants.SOAP_FLOAT, java.lang.Float JavaDoc.class);
74         myRegisterSimple(Constants.SOAP_INT, java.lang.Integer JavaDoc.class);
75         myRegisterSimple(Constants.SOAP_INTEGER, java.math.BigInteger JavaDoc.class);
76         myRegisterSimple(Constants.SOAP_DECIMAL, java.math.BigDecimal JavaDoc.class);
77         myRegisterSimple(Constants.SOAP_LONG, java.lang.Long JavaDoc.class);
78         myRegisterSimple(Constants.SOAP_SHORT, java.lang.Short JavaDoc.class);
79         myRegisterSimple(Constants.SOAP_BYTE, java.lang.Byte JavaDoc.class);
80
81         myRegister(Constants.SOAP_BASE64, byte[].class,
82                    new Base64SerializerFactory(byte[].class,
83                                                Constants.SOAP_BASE64),
84                    new Base64DeserializerFactory(byte[].class,
85                                                  Constants.SOAP_BASE64)
86         );
87         myRegister(Constants.SOAP_BASE64BINARY, byte[].class,
88                    new Base64SerializerFactory(byte[].class,
89                                                Constants.SOAP_BASE64BINARY),
90                    new Base64DeserializerFactory(byte[].class,
91                                                  Constants.SOAP_BASE64BINARY)
92         );
93
94         myRegister(Constants.SOAP_ARRAY12, java.util.Collection JavaDoc.class,
95                    new ArraySerializerFactory(),
96                    new ArrayDeserializerFactory()
97         );
98         myRegister(Constants.SOAP_ARRAY12, java.util.ArrayList JavaDoc.class,
99                    new ArraySerializerFactory(),
100                    new ArrayDeserializerFactory()
101         );
102
103         myRegister(Constants.SOAP_ARRAY12, Object JavaDoc[].class,
104                    new ArraySerializerFactory(),
105                    new ArrayDeserializerFactory()
106         );
107
108         myRegister(Constants.SOAP_ARRAY, java.util.ArrayList JavaDoc.class,
109                    new ArraySerializerFactory(),
110                    new ArrayDeserializerFactory()
111         );
112
113         // All array objects automatically get associated with the SOAP_ARRAY.
114
// There is no way to do this with a hash table,
115
// so it is done directly in getTypeQName.
116
// Internally the runtime uses ArrayList objects to hold arrays...
117
// which is the reason that ArrayList is associated with SOAP_ARRAY.
118
// In addition, handle all objects that implement the List interface
119
// as a SOAP_ARRAY
120
myRegister(Constants.SOAP_ARRAY, java.util.Collection JavaDoc.class,
121                    new ArraySerializerFactory(),
122                    new ArrayDeserializerFactory()
123         );
124
125         myRegister(Constants.SOAP_ARRAY, Object JavaDoc[].class,
126                    new ArraySerializerFactory(),
127                    new ArrayDeserializerFactory()
128         );
129
130
131     }
132 }
133
Popular Tags