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