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. package com.sun.corba.se.impl.orbutil;
  16. import javax.rmi.CORBA.Util;
  17. import javax.rmi.PortableRemoteObject;
  18. import java.util.Hashtable;
  19. import java.util.Stack;
  20. import java.io.IOException;
  21. import java.util.EmptyStackException;
  22. import com.sun.corba.se.impl.util.Utility;
  23. import com.sun.corba.se.impl.io.IIOPInputStream;
  24. import com.sun.corba.se.impl.io.IIOPOutputStream;
  25. import com.sun.corba.se.impl.util.RepositoryId;
  26. import com.sun.corba.se.impl.util.Utility;
  27. import org.omg.CORBA.TCKind;
  28. import org.omg.CORBA.MARSHAL;
  29. import org.omg.CORBA.CompletionStatus;
  30. import org.omg.CORBA.portable.IndirectionException;
  31. import com.sun.org.omg.SendingContext.CodeBase;
  32. import java.security.AccessController;
  33. import java.security.PrivilegedAction;
  34. /**
  35. * This class overrides behavior of our current ValueHandlerImpl to
  36. * provide backwards compatibility with JDK 1.3.0.
  37. */
  38. public class ValueHandlerImpl_1_3 extends com.sun.corba.se.impl.io.ValueHandlerImpl {
  39. public ValueHandlerImpl_1_3(){
  40. super();
  41. }
  42. public ValueHandlerImpl_1_3(boolean isInputStream) {
  43. super(isInputStream);
  44. }
  45. /**
  46. * Writes the value to the stream using java semantics.
  47. * @param out The stream to write the value to
  48. * @param value The value to be written to the stream
  49. **/
  50. public void writeValue(org.omg.CORBA.portable.OutputStream _out, java.io.Serializable value) {
  51. super.writeValue(_out, value);
  52. }
  53. /**
  54. * Reads a value from the stream using java semantics.
  55. * @param in The stream to read the value from
  56. * @param clazz The type of the value to be read in
  57. * @param sender The sending context runtime
  58. **/
  59. public java.io.Serializable readValue(org.omg.CORBA.portable.InputStream _in,
  60. int offset,
  61. java.lang.Class clazz,
  62. String repositoryID,
  63. org.omg.SendingContext.RunTime _sender)
  64. {
  65. return super.readValue(_in, offset, clazz, repositoryID, _sender);
  66. }
  67. /**
  68. * Returns the repository ID for the given RMI value Class.
  69. * @param clz The class to return a repository ID for.
  70. * @return the repository ID of the Class.
  71. **/
  72. public java.lang.String getRMIRepositoryID(java.lang.Class clz) {
  73. return RepositoryId_1_3.createForJavaType(clz);
  74. }
  75. /**
  76. * Indicates whether the given Class performs custom or
  77. * default marshaling.
  78. * @param clz The class to test for custom marshaling.
  79. * @return True if the class performs custom marshaling, false
  80. * if it does not.
  81. **/
  82. public boolean isCustomMarshaled(java.lang.Class clz) {
  83. return super.isCustomMarshaled(clz);
  84. }
  85. /**
  86. * Returns the CodeBase for this ValueHandler. This is used by
  87. * the ORB runtime. The server sends the service context containing
  88. * the IOR for this CodeBase on the first GIOP reply. The clients
  89. * do the same on the first GIOP request.
  90. * @return the SendingContext.CodeBase of this ValueHandler.
  91. **/
  92. public org.omg.SendingContext.RunTime getRunTimeCodeBase() {
  93. return super.getRunTimeCodeBase();
  94. }
  95. /**
  96. * If the value contains a writeReplace method then the result
  97. * is returned. Otherwise, the value itself is returned.
  98. * @return the true value to marshal on the wire.
  99. **/
  100. public java.io.Serializable writeReplace(java.io.Serializable value) {
  101. return super.writeReplace(value);
  102. }
  103. // methods supported for backward compatability so that the appropriate
  104. // Rep-id calculations take place based on the ORB version
  105. /**
  106. * Returns a boolean of whether or not RepositoryId indicates
  107. * FullValueDescriptor.
  108. * used for backward compatability
  109. */
  110. public boolean useFullValueDescription(Class clazz, String repositoryID)
  111. throws IOException
  112. {
  113. return RepositoryId_1_3.useFullValueDescription(clazz, repositoryID);
  114. }
  115. public String getClassName(String id)
  116. {
  117. RepositoryId_1_3 repID = RepositoryId_1_3.cache.getId(id);
  118. return repID.getClassName();
  119. }
  120. public Class getClassFromType(String id)
  121. throws ClassNotFoundException
  122. {
  123. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  124. return repId.getClassFromType();
  125. }
  126. public Class getAnyClassFromType(String id)
  127. throws ClassNotFoundException
  128. {
  129. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  130. return repId.getAnyClassFromType();
  131. }
  132. public String createForAnyType(Class cl)
  133. {
  134. return RepositoryId_1_3.createForAnyType(cl);
  135. }
  136. public String getDefinedInId(String id)
  137. {
  138. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  139. return repId.getDefinedInId();
  140. }
  141. public String getUnqualifiedName(String id)
  142. {
  143. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  144. return repId.getUnqualifiedName();
  145. }
  146. public String getSerialVersionUID(String id)
  147. {
  148. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  149. return repId.getSerialVersionUID();
  150. }
  151. public boolean isAbstractBase(Class clazz)
  152. {
  153. return RepositoryId_1_3.isAbstractBase(clazz);
  154. }
  155. public boolean isSequence(String id)
  156. {
  157. RepositoryId_1_3 repId = RepositoryId_1_3.cache.getId(id);
  158. return repId.isSequence();
  159. }
  160. /**
  161. * Preserves the incorrect 1.3 behavior which truncates Java chars in
  162. * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
  163. * continue interoperating with our legacy ORBs. If this goes into
  164. * Ladybird, then Ladybird and Kestrel will interoperate as long as
  165. * people don't use chars greater than 8-bits.
  166. */
  167. protected void writeCharArray(org.omg.CORBA_2_3.portable.OutputStream out,
  168. char[] array,
  169. int offset,
  170. int length)
  171. {
  172. out.write_char_array(array, offset, length);
  173. }
  174. /**
  175. * Preserves the incorrect 1.3 behavior which truncates Java chars in
  176. * arrays to 8-bit CORBA chars. Bug 4367783. This enables us to
  177. * continue interoperating with our legacy ORBs. If this goes into
  178. * Ladybird, then Ladybird and Kestrel will interoperate as long as
  179. * people don't use chars greater than 8-bits.
  180. */
  181. protected void readCharArray(org.omg.CORBA_2_3.portable.InputStream in,
  182. char[] array,
  183. int offset,
  184. int length)
  185. {
  186. in.read_char_array(array, offset, length);
  187. }
  188. protected final String getOutputStreamClassName() {
  189. return "com.sun.corba.se.impl.orbutil.IIOPOutputStream_1_3";
  190. }
  191. protected final String getInputStreamClassName() {
  192. return "com.sun.corba.se.impl.orbutil.IIOPInputStream_1_3";
  193. }
  194. /**
  195. * Our JDK 1.3 and JDK 1.3.1 behavior subclasses override this.
  196. * The correct behavior is for a Java char to map to a CORBA wchar,
  197. * but our older code mapped it to a CORBA char.
  198. */
  199. protected TCKind getJavaCharTCKind() {
  200. return TCKind.tk_char;
  201. }
  202. }