1. /*
  2. * @(#)OldJIDLObjectKeyTemplate.java 1.11 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. // @(#)OldJIDLObjectKeyTemplate.java 1.5 00/10/11
  8. package com.sun.corba.se.internal.ior;
  9. import com.sun.corba.se.internal.ior.ObjectId ;
  10. import com.sun.corba.se.internal.ior.ObjectKeyFactory ;
  11. import org.omg.CORBA_2_3.portable.OutputStream ;
  12. import com.sun.corba.se.internal.iiop.CDRInputStream ;
  13. import com.sun.corba.se.internal.core.ORBVersion ;
  14. import com.sun.corba.se.internal.core.ORBVersionImpl ;
  15. import org.omg.CORBA.ORB ;
  16. import org.omg.CORBA.OctetSeqHolder ;
  17. import org.omg.CORBA.INTERNAL ;
  18. import org.omg.CORBA.CompletionStatus ;
  19. import com.sun.corba.se.internal.orbutil.MinorCodes ;
  20. /**
  21. * Handles object keys created by JDK ORBs from before JDK 1.4.0.
  22. */
  23. public final class OldJIDLObjectKeyTemplate extends OldObjectKeyTemplateBase
  24. {
  25. /**
  26. * JDK 1.3.1 FCS did not include a version byte at the end of
  27. * its object keys. JDK 1.3.1_01 included the byte with the
  28. * value 1. Anything below 1 is considered an invalid value.
  29. */
  30. public static final byte NULL_PATCH_VERSION = 0;
  31. byte patchVersion = OldJIDLObjectKeyTemplate.NULL_PATCH_VERSION;
  32. public OldJIDLObjectKeyTemplate( byte[] key, int magic, int scid, CDRInputStream is,
  33. OctetSeqHolder osh )
  34. {
  35. super( magic, scid, is.read_long() );
  36. osh.value = readObjectKey( is ) ;
  37. /**
  38. * Beginning with JDK 1.3.1_01, a byte was placed at the end of
  39. * the object key with a value indicating the patch version.
  40. * JDK 1.3.1_01 had the value 1. If other patches are necessary
  41. * which involve ORB versioning changes, they should increment
  42. * the patch version.
  43. *
  44. * Note that if we see a value greater than 1 in this code, we
  45. * will treat it as if we're talking to JDK 1.4.0 or greater.
  46. *
  47. * WARNING: This code is sensitive to changes in CDRInputStream
  48. * getPosition. It assumes that the CDRInputStream is an
  49. * encapsulation whose position can be compared to the object
  50. * key array length.
  51. */
  52. if (magic == ObjectKeyTemplate.JAVAMAGIC_NEW &&
  53. key.length > is.getPosition()) {
  54. patchVersion = is.read_octet();
  55. if (patchVersion == ObjectKeyTemplate.JDK1_3_1_01_PATCH_LEVEL)
  56. setORBVersion(ORBVersionImpl.JDK1_3_1_01);
  57. else
  58. if (patchVersion > ObjectKeyTemplate.JDK1_3_1_01_PATCH_LEVEL)
  59. setORBVersion(ORBVersionImpl.NEWER);
  60. else
  61. throw new INTERNAL("Invalid JDK 1.3.1 patch level: "
  62. + patchVersion,
  63. MinorCodes.INVALID_JDK1_3_1_PATCH_LEVEL,
  64. CompletionStatus.COMPLETED_NO);
  65. }
  66. }
  67. /**
  68. * @param scid
  69. * @param serverid
  70. * @return
  71. * @exception
  72. * @author
  73. * @roseuid 3915FF9803AA
  74. */
  75. public OldJIDLObjectKeyTemplate(int magic, int scid, int serverid)
  76. {
  77. super( magic, scid, serverid ) ;
  78. }
  79. protected void write( OutputStream os )
  80. {
  81. os.write_long( getMagic() ) ;
  82. os.write_long( getSubcontractId() ) ;
  83. os.write_long( getServerId() ) ;
  84. }
  85. public void write(ObjectId objectId, OutputStream os)
  86. {
  87. super.write(objectId, os);
  88. if (patchVersion != OldJIDLObjectKeyTemplate.NULL_PATCH_VERSION)
  89. os.write_octet( patchVersion ) ;
  90. }
  91. }