1. /*
  2. * @(#)LocateReplyMessage_1_1.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. package com.sun.corba.se.internal.iiop.messages;
  8. import org.omg.CORBA.INTERNAL;
  9. import org.omg.CORBA.CompletionStatus;
  10. import org.omg.CORBA.SystemException;
  11. import com.sun.corba.se.internal.core.GIOPVersion;
  12. import com.sun.corba.se.internal.orbutil.MinorCodes;
  13. import com.sun.corba.se.internal.core.IOR;
  14. import com.sun.corba.se.internal.iiop.CDRInputStream;
  15. import com.sun.corba.se.internal.iiop.ORB;
  16. /**
  17. * This implements the GIOP 1.1 LocateReply header.
  18. *
  19. * @author Ram Jeyaraman 05/14/2000
  20. * @version 1.0
  21. */
  22. public final class LocateReplyMessage_1_1 extends Message_1_1
  23. implements LocateReplyMessage {
  24. // Instance variables
  25. private ORB orb = null;
  26. private int request_id = (int) 0;
  27. private int reply_status = (int) 0;
  28. private IOR ior = null;
  29. // Constructors
  30. LocateReplyMessage_1_1(ORB orb) {
  31. this.orb = orb;
  32. }
  33. LocateReplyMessage_1_1(ORB orb, int _request_id,
  34. int _reply_status, IOR _ior) {
  35. super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN,
  36. Message.GIOPLocateReply, 0);
  37. this.orb = orb;
  38. request_id = _request_id;
  39. reply_status = _reply_status;
  40. ior = _ior;
  41. }
  42. // Accessor methods
  43. public int getRequestId() {
  44. return this.request_id;
  45. }
  46. public int getReplyStatus() {
  47. return this.reply_status;
  48. }
  49. public short getAddrDisposition() {
  50. return KeyAddr.value;
  51. }
  52. public SystemException getSystemException() {
  53. return null; // 1.0 LocateReply body does not contain SystemException
  54. }
  55. public IOR getIOR() {
  56. return this.ior;
  57. }
  58. // IO methods
  59. public void read(org.omg.CORBA.portable.InputStream istream) {
  60. super.read(istream);
  61. this.request_id = istream.read_ulong();
  62. this.reply_status = istream.read_long();
  63. isValidReplyStatus(this.reply_status); // raises exception on error
  64. // The code below reads the reply body if status is OBJECT_FORWARD
  65. if (this.reply_status == OBJECT_FORWARD) {
  66. CDRInputStream cdr = (CDRInputStream) istream;
  67. this.ior = new IOR( cdr ) ;
  68. }
  69. }
  70. // Note, this writes only the header information. SystemException or
  71. // IOR may be written afterwards into the reply mesg body.
  72. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  73. super.write(ostream);
  74. ostream.write_ulong(this.request_id);
  75. ostream.write_long(this.reply_status);
  76. }
  77. // Static methods
  78. public static void isValidReplyStatus(int replyStatus) {
  79. switch (replyStatus) {
  80. case UNKNOWN_OBJECT :
  81. case OBJECT_HERE :
  82. case OBJECT_FORWARD :
  83. break;
  84. default :
  85. throw new INTERNAL(MinorCodes.ILLEGAL_REPLY_STATUS,
  86. CompletionStatus.COMPLETED_MAYBE);
  87. }
  88. }
  89. public final void callback(com.sun.corba.se.internal.iiop.MessageMediator m)
  90. throws java.io.IOException
  91. {
  92. m.handleInput(this);
  93. }
  94. } // class LocateReplyMessage_1_1