1. /*
  2. * @(#)RequestMessage_1_0.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.0 Request header.
  15. *
  16. * @author Ram Jeyaraman 05/14/2000
  17. * @version 1.0
  18. */
  19. public final class RequestMessage_1_0 extends Message_1_0
  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[] object_key = null;
  27. private String operation = null;
  28. private Principal requesting_principal = null;
  29. private ObjectKey objectKey = null;
  30. // Constructor
  31. RequestMessage_1_0(ORB orb) {
  32. this.orb = orb;
  33. }
  34. RequestMessage_1_0(ORB orb, ServiceContexts _service_contexts,
  35. int _request_id, boolean _response_expected, byte[] _object_key,
  36. String _operation, Principal _requesting_principal) {
  37. super(Message.GIOPBigMagic, false, Message.GIOPRequest, 0);
  38. this.orb = orb;
  39. service_contexts = _service_contexts;
  40. request_id = _request_id;
  41. response_expected = _response_expected;
  42. object_key = _object_key;
  43. operation = _operation;
  44. requesting_principal = _requesting_principal;
  45. }
  46. // Accessor methods (RequestMessage interface)
  47. public ServiceContexts getServiceContexts() {
  48. return this.service_contexts;
  49. }
  50. public int getRequestId() {
  51. return this.request_id;
  52. }
  53. public boolean isResponseExpected() {
  54. return this.response_expected;
  55. }
  56. public byte[] getReserved() {
  57. // REVISIT Should we throw an exception or return null ?
  58. return null;
  59. }
  60. public ObjectKey getObjectKey() {
  61. if (this.objectKey == null) {
  62. // this will raise a MARSHAL exception upon errors.
  63. this.objectKey = MessageBase.extractObjectKey(object_key, orb);
  64. }
  65. return this.objectKey;
  66. }
  67. public String getOperation() {
  68. return this.operation;
  69. }
  70. public Principal getPrincipal() {
  71. return this.requesting_principal;
  72. }
  73. // IO methods
  74. public void read(org.omg.CORBA.portable.InputStream istream) {
  75. super.read(istream);
  76. this.service_contexts
  77. = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream) istream);
  78. this.request_id = istream.read_ulong();
  79. this.response_expected = istream.read_boolean();
  80. int _len0 = istream.read_long();
  81. this.object_key = new byte[_len0];
  82. istream.read_octet_array(this.object_key, 0, _len0);
  83. this.operation = istream.read_string();
  84. this.requesting_principal = istream.read_Principal();
  85. }
  86. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  87. super.write(ostream);
  88. if (this.service_contexts != null) {
  89. service_contexts.write(
  90. (org.omg.CORBA_2_3.portable.OutputStream) ostream,
  91. GIOPVersion.V1_0);
  92. } else {
  93. ServiceContexts.writeNullServiceContext(
  94. (org.omg.CORBA_2_3.portable.OutputStream) ostream);
  95. }
  96. ostream.write_ulong(this.request_id);
  97. ostream.write_boolean(this.response_expected);
  98. nullCheck(this.object_key);
  99. ostream.write_long(this.object_key.length);
  100. ostream.write_octet_array(this.object_key, 0, this.object_key.length);
  101. ostream.write_string(this.operation);
  102. if (this.requesting_principal != null) {
  103. ostream.write_Principal(this.requesting_principal);
  104. } else {
  105. ostream.write_long(0);
  106. }
  107. }
  108. public final void callback(com.sun.corba.se.internal.iiop.MessageMediator m)
  109. throws java.io.IOException
  110. {
  111. m.handleInput(this);
  112. }
  113. } // class RequestMessage_1_0