1. /*
  2. * @(#)RequestMessage_1_2.java 1.14 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.Principal;
  9. import com.sun.corba.se.internal.core.ServiceContexts;
  10. import com.sun.corba.se.internal.core.GIOPVersion;
  11. import com.sun.corba.se.internal.iiop.ORB;
  12. import com.sun.corba.se.internal.ior.ObjectKey;
  13. import com.sun.corba.se.internal.iiop.CDRInputStream;
  14. import com.sun.corba.se.internal.iiop.CDROutputStream;
  15. import com.sun.corba.se.internal.orbutil.ORBConstants;
  16. /**
  17. * This implements the GIOP 1.2 Request header.
  18. *
  19. * @author Ram Jeyaraman 05/14/2000
  20. * @version 1.0
  21. */
  22. public final class RequestMessage_1_2 extends Message_1_2
  23. implements RequestMessage {
  24. // Instance variables
  25. private ORB orb = null;
  26. private byte response_flags = (byte) 0;
  27. private byte reserved[] = null;
  28. private TargetAddress target = null;
  29. private String operation = null;
  30. private ServiceContexts service_contexts = null;
  31. private ObjectKey objectKey = null;
  32. // Constructors
  33. RequestMessage_1_2(ORB orb) {
  34. this.orb = orb;
  35. }
  36. RequestMessage_1_2(ORB orb, int _request_id, byte _response_flags,
  37. byte[] _reserved, TargetAddress _target,
  38. String _operation, ServiceContexts _service_contexts) {
  39. super(Message.GIOPBigMagic, GIOPVersion.V1_2, FLAG_NO_FRAG_BIG_ENDIAN,
  40. Message.GIOPRequest, 0);
  41. this.orb = orb;
  42. request_id = _request_id;
  43. response_flags = _response_flags;
  44. reserved = _reserved;
  45. target = _target;
  46. operation = _operation;
  47. service_contexts = _service_contexts;
  48. }
  49. // Accessor methods (RequestMessage interface)
  50. public int getRequestId() {
  51. return this.request_id;
  52. }
  53. public boolean isResponseExpected() {
  54. /*
  55. case 1: LSBit[1] == 1
  56. not a oneway call (DII flag INV_NO_RESPONSE is false) // Ox03
  57. LSBit[0] must be 1.
  58. case 2: LSBit[1] == 0
  59. if (LSB[0] == 0) // Ox00
  60. oneway call
  61. else if (LSB[0] == 1) // 0x01
  62. oneway call; but server may provide
  63. a location forward response or system exception response.
  64. */
  65. if ( (this.response_flags & RESPONSE_EXPECTED_BIT) == RESPONSE_EXPECTED_BIT ) {
  66. return true;
  67. }
  68. return false;
  69. }
  70. public byte[] getReserved() {
  71. return this.reserved;
  72. }
  73. public ObjectKey getObjectKey() {
  74. if (this.objectKey == null) {
  75. // this will raise a MARSHAL exception upon errors.
  76. this.objectKey = MessageBase.extractObjectKey(target, orb);
  77. }
  78. return this.objectKey;
  79. }
  80. public String getOperation() {
  81. return this.operation;
  82. }
  83. public Principal getPrincipal() {
  84. // REVISIT Should we throw an exception or return null ?
  85. return null;
  86. }
  87. public ServiceContexts getServiceContexts() {
  88. return this.service_contexts;
  89. }
  90. // IO methods
  91. public void read(org.omg.CORBA.portable.InputStream istream) {
  92. super.read(istream);
  93. this.request_id = istream.read_ulong();
  94. this.response_flags = istream.read_octet();
  95. this.reserved = new byte[3];
  96. for (int _o0 = 0;_o0 < (3); ++_o0) {
  97. this.reserved[_o0] = istream.read_octet();
  98. }
  99. this.target = TargetAddressHelper.read(istream);
  100. getObjectKey(); // this does AddressingDisposition check
  101. this.operation = istream.read_string();
  102. this.service_contexts
  103. = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream) istream);
  104. // CORBA formal 00-11-0 15.4.2.2 GIOP 1.2 body must be
  105. // aligned on an 8 octet boundary.
  106. ((CDRInputStream)istream).alignOnBoundary(ORBConstants.GIOP_12_MSG_BODY_ALIGNMENT);
  107. }
  108. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  109. super.write(ostream);
  110. ostream.write_ulong(this.request_id);
  111. ostream.write_octet(this.response_flags);
  112. nullCheck(this.reserved);
  113. if (this.reserved.length != (3)) {
  114. throw new org.omg.CORBA.MARSHAL(0,
  115. org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
  116. }
  117. for (int _i0 = 0;_i0 < (3); ++_i0) {
  118. ostream.write_octet(this.reserved[_i0]);
  119. }
  120. nullCheck(this.target);
  121. TargetAddressHelper.write(ostream, this.target);
  122. ostream.write_string(this.operation);
  123. if (this.service_contexts != null) {
  124. service_contexts.write(
  125. (org.omg.CORBA_2_3.portable.OutputStream) ostream,
  126. GIOPVersion.V1_2);
  127. } else {
  128. ServiceContexts.writeNullServiceContext(
  129. (org.omg.CORBA_2_3.portable.OutputStream) ostream);
  130. }
  131. // CORBA formal 00-11-0 15.4.2.2 GIOP 1.2 body must be
  132. // aligned on an 8 octet boundary.
  133. ((CDROutputStream)ostream).alignOnBoundary(ORBConstants.GIOP_12_MSG_BODY_ALIGNMENT);
  134. }
  135. public final void callback(com.sun.corba.se.internal.iiop.MessageMediator m)
  136. throws java.io.IOException
  137. {
  138. m.handleInput(this);
  139. }
  140. } // class RequestMessage_1_2