1. /*
  2. * @(#)RequestMessage_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.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. /**
  14. * This implements the GIOP 1.1 Request header.
  15. *
  16. * @author Ram Jeyaraman 05/14/2000
  17. * @version 1.0
  18. */
  19. public final class RequestMessage_1_1 extends Message_1_1
  20. implements RequestMessage {
  21. // Instance variables
  22. private ORB orb = null;
  23. private ServiceContexts service_contexts = null;
  24. private int request_id = (int) 0;
  25. private boolean response_expected = false;
  26. private byte[] reserved = null; // Added in GIOP 1.1
  27. private byte[] object_key = null;
  28. private String operation = null;
  29. private Principal requesting_principal = null;
  30. private ObjectKey objectKey = null;
  31. // Constructors
  32. RequestMessage_1_1(ORB orb) {
  33. this.orb = orb;
  34. }
  35. RequestMessage_1_1(ORB orb, ServiceContexts _service_contexts,
  36. int _request_id, boolean _response_expected, byte[] _reserved,
  37. byte[] _object_key, String _operation,
  38. Principal _requesting_principal) {
  39. super(Message.GIOPBigMagic, GIOPVersion.V1_1, FLAG_NO_FRAG_BIG_ENDIAN,
  40. Message.GIOPRequest, 0);
  41. this.orb = orb;
  42. service_contexts = _service_contexts;
  43. request_id = _request_id;
  44. response_expected = _response_expected;
  45. reserved = _reserved;
  46. object_key = _object_key;
  47. operation = _operation;
  48. requesting_principal = _requesting_principal;
  49. }
  50. // Accessor methods (RequestMessage interface)
  51. public ServiceContexts getServiceContexts() {
  52. return this.service_contexts;
  53. }
  54. public int getRequestId() {
  55. return this.request_id;
  56. }
  57. public boolean isResponseExpected() {
  58. return this.response_expected;
  59. }
  60. public byte[] getReserved() {
  61. return this.reserved;
  62. }
  63. public ObjectKey getObjectKey() {
  64. if (this.objectKey == null) {
  65. // this will raise a MARSHAL exception upon errors.
  66. this.objectKey = MessageBase.extractObjectKey(object_key, orb);
  67. }
  68. return this.objectKey;
  69. }
  70. public String getOperation() {
  71. return this.operation;
  72. }
  73. public Principal getPrincipal() {
  74. return this.requesting_principal;
  75. }
  76. // IO methods
  77. public void read(org.omg.CORBA.portable.InputStream istream) {
  78. super.read(istream);
  79. this.service_contexts
  80. = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream) istream);
  81. this.request_id = istream.read_ulong();
  82. this.response_expected = istream.read_boolean();
  83. this.reserved = new byte[3];
  84. for (int _o0 = 0;_o0 < (3); ++_o0) {
  85. this.reserved[_o0] = istream.read_octet();
  86. }
  87. int _len1 = istream.read_long();
  88. this.object_key = new byte[_len1];
  89. istream.read_octet_array(this.object_key, 0, _len1);
  90. this.operation = istream.read_string();
  91. this.requesting_principal = istream.read_Principal();
  92. }
  93. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  94. super.write(ostream);
  95. if (this.service_contexts != null) {
  96. service_contexts.write(
  97. (org.omg.CORBA_2_3.portable.OutputStream) ostream,
  98. GIOPVersion.V1_1);
  99. } else {
  100. ServiceContexts.writeNullServiceContext(
  101. (org.omg.CORBA_2_3.portable.OutputStream) ostream);
  102. }
  103. ostream.write_ulong(this.request_id);
  104. ostream.write_boolean(this.response_expected);
  105. nullCheck(this.reserved);
  106. if (this.reserved.length != (3)) {
  107. throw new org.omg.CORBA.MARSHAL(0,
  108. org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE);
  109. }
  110. for (int _i0 = 0;_i0 < (3); ++_i0) {
  111. ostream.write_octet(this.reserved[_i0]);
  112. }
  113. nullCheck(this.object_key);
  114. ostream.write_long(this.object_key.length);
  115. ostream.write_octet_array(this.object_key, 0, this.object_key.length);
  116. ostream.write_string(this.operation);
  117. if (this.requesting_principal != null) {
  118. ostream.write_Principal(this.requesting_principal);
  119. } else {
  120. ostream.write_long(0);
  121. }
  122. }
  123. public final void callback(com.sun.corba.se.internal.iiop.MessageMediator m)
  124. throws java.io.IOException
  125. {
  126. m.handleInput(this);
  127. }
  128. } // class RequestMessage_1_1