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