KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > orbutil > ValueHandlerImpl_1_3


1 /*
2  * @(#)ValueHandlerImpl_1_3.java 1.10 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8  * Licensed Materials - Property of IBM
9  * RMI-IIOP v1.0
10  * Copyright IBM Corp. 1998 1999 All Rights Reserved
11  *
12  * US Government Users Restricted Rights - Use, duplication or
13  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14  */

15
16 package com.sun.corba.se.impl.orbutil;
17
18 import javax.rmi.CORBA.Util JavaDoc;
19 import javax.rmi.PortableRemoteObject JavaDoc;
20
21 import java.util.Hashtable JavaDoc;
22 import java.util.Stack JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.util.EmptyStackException JavaDoc;
25
26 import com.sun.corba.se.impl.util.Utility;
27 import com.sun.corba.se.impl.io.IIOPInputStream;
28 import com.sun.corba.se.impl.io.IIOPOutputStream;
29 import com.sun.corba.se.impl.util.RepositoryId;
30 import com.sun.corba.se.impl.util.Utility;
31
32 import org.omg.CORBA.TCKind JavaDoc;
33 import org.omg.CORBA.MARSHAL JavaDoc;
34 import org.omg.CORBA.CompletionStatus JavaDoc;
35 import org.omg.CORBA.portable.IndirectionException JavaDoc;
36 import com.sun.org.omg.SendingContext.CodeBase;
37
38 import java.security.AccessController JavaDoc;
39 import java.security.PrivilegedAction JavaDoc;
40
41 /**
42  * This class overrides behavior of our current ValueHandlerImpl to
43  * provide backwards compatibility with JDK 1.3.0.
44  */

45 public class ValueHandlerImpl_1_3 extends com.sun.corba.se.impl.io.ValueHandlerImpl {
46
47     public ValueHandlerImpl_1_3(){
48     super();
49     }
50
51     public ValueHandlerImpl_1_3(boolean isInputStream) {
52     super(isInputStream);
53     }
54
55     /**
56      * Writes the value to the stream using java semantics.
57      * @param out The stream to write the value to
58      * @param value The value to be written to the stream
59      **/

60     public void writeValue(org.omg.CORBA.portable.OutputStream JavaDoc _out, java.io.Serializable JavaDoc value) {
61     super.writeValue(_out, value);
62     }
63
64     /**
65      * Reads a value from the stream using java semantics.
66      * @param in The stream to read the value from
67      * @param clazz The type of the value to be read in
68      * @param sender The sending context runtime
69      **/

70     public java.io.Serializable JavaDoc readValue(org.omg.CORBA.portable.InputStream JavaDoc _in,
71                       int offset,
72                       java.lang.Class JavaDoc clazz,
73                       String JavaDoc repositoryID,
74                       org.omg.SendingContext.RunTime JavaDoc _sender)
75     {
76     return super.readValue(_in, offset, clazz, repositoryID, _sender);
77     }
78
79     /**
80      * Returns the repository ID for the given RMI value Class.
81      * @param clz The class to return a repository ID for.
82      * @return the repository ID of the Class.
83      **/

84     public java.lang.String JavaDoc getRMIRepositoryID(java.lang.Class JavaDoc clz) {
85     return RepositoryId_1_3.createForJavaType(clz);
86     }
87
88     /**
89      * Indicates whether the given Class performs custom or
90      * default marshaling.
91      * @param clz The class to test for custom marshaling.
92      * @return True if the class performs custom marshaling, false
93      * if it does not.
94      **/

95     public boolean isCustomMarshaled(java.lang.Class JavaDoc clz) {
96     return super.isCustomMarshaled(clz);
97     }
98
99     /**
100      * Returns the CodeBase for this ValueHandler. This is used by
101      * the ORB runtime. The server sends the service context containing
102      * the IOR for this CodeBase on the first GIOP reply. The clients
103      * do the same on the first GIOP request.
104      * @return the SendingContext.CodeBase of this ValueHandler.
105      **/

106     public org.omg.SendingContext.RunTime JavaDoc getRunTimeCodeBase() {
107     return super.getRunTimeCodeBase();
108     }
109
110     /**
111      * If the value contains a writeReplace method then the result
112      * is returned. Otherwise, the value itself is returned.
113      * @return the true value to marshal on the wire.
114      **/

115     public java.io.Serializable JavaDoc writeReplace(java.io.Serializable JavaDoc value) {
116     return super.writeReplace(value);
117     }
118
119     // methods supported for backward compatability so that the appropriate
120
// Rep-id calculations take place based on the ORB version
121

122     /**
123      * Returns a boolean of whether or not RepositoryId indicates
124      * FullValueDescriptor.
125      * used for backward compatability
126      */

127
128      public boolean useFullValueDescription(Class JavaDoc clazz, String JavaDoc repositoryID)
129     throws IOException JavaDoc
130     
131      {
132         return RepositoryId_1_3.useFullValueDescription(clazz, repositoryID);
133      }
134
135      public String JavaDoc getClassName(String JavaDoc id)
136      {
137         RepositoryId_1_3 repID = RepositoryId_1_3.cache.getId(id);
138         return repID.getClassName();
139      }
140
141      public Class JavaDoc getClassFromType(String JavaDoc id)
142         throws ClassNotFoundException JavaDoc
143      {
144         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
145         return repId.getClassFromType();
146      }
147
148      public Class JavaDoc getAnyClassFromType(String JavaDoc id)
149         throws ClassNotFoundException JavaDoc
150      {
151         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
152         return repId.getAnyClassFromType();
153      }
154
155      public String JavaDoc createForAnyType(Class JavaDoc cl)
156      {
157         return RepositoryId_1_3.createForAnyType(cl);
158      }
159        
160      public String JavaDoc getDefinedInId(String JavaDoc id)
161      {
162         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
163         return repId.getDefinedInId();
164      }
165
166      public String JavaDoc getUnqualifiedName(String JavaDoc id)
167      {
168         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
169         return repId.getUnqualifiedName();
170      }
171
172      public String JavaDoc getSerialVersionUID(String JavaDoc id)
173      {
174         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
175         return repId.getSerialVersionUID();
176      }
177
178      public boolean isAbstractBase(Class JavaDoc clazz)
179      {
180         return RepositoryId_1_3.isAbstractBase(clazz);
181      }
182
183      public boolean isSequence(String JavaDoc id)
184      {
185         RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
186         return repId.isSequence();
187      }
188
189     /**
190      * Preserves the incorrect 1.3 behavior which truncates Java chars in
191      * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
192      * continue interoperating with our legacy ORBs. If this goes into
193      * Ladybird, then Ladybird and Kestrel will interoperate as long as
194      * people don't use chars greater than 8-bits.
195      */

196     protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream JavaDoc out,
197                                 char[] array,
198                                 int offset,
199                                 int length)
200     {
201         out.write_char_array(array, offset, length);
202     }
203
204     /**
205      * Preserves the incorrect 1.3 behavior which truncates Java chars in
206      * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
207      * continue interoperating with our legacy ORBs. If this goes into
208      * Ladybird, then Ladybird and Kestrel will interoperate as long as
209      * people don't use chars greater than 8-bits.
210      */

211     protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream JavaDoc in,
212                                  char[] array,
213                                  int offset,
214                                  int length)
215     {
216         in.read_char_array(array, offset, length);
217     }
218
219     protected final String JavaDoc getOutputStreamClassName() {
220         return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3";
221     }
222
223     protected final String JavaDoc getInputStreamClassName() {
224         return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3";
225     }
226
227     /**
228      * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
229      * The correct behavior is for a Java char to map to a CORBA wchar,
230      * but our older code mapped it to a CORBA char.
231      */

232     protected TCKind JavaDoc getJavaCharTCKind() {
233         return TCKind.tk_char;
234     }
235 }
236
Popular Tags