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