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