1. /*
  2. * @(#)RequestMessage_1_0.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. /**
  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. // Mutators
  74. public void setThreadPoolToUse(int poolToUse) {
  75. // No-op, must be GIOP Version 1.1 or greater
  76. // to support this SUN PROPRIETARY EXTENSION.
  77. }
  78. // IO methods
  79. public void read(org.omg.CORBA.portable.InputStream istream) {
  80. super.read(istream);
  81. this.service_contexts
  82. = new ServiceContexts((org.omg.CORBA_2_3.portable.InputStream) istream);
  83. this.request_id = istream.read_ulong();
  84. this.response_expected = istream.read_boolean();
  85. int _len0 = istream.read_long();
  86. this.object_key = new byte[_len0];
  87. istream.read_octet_array(this.object_key, 0, _len0);
  88. this.operation = istream.read_string();
  89. this.requesting_principal = istream.read_Principal();
  90. }
  91. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  92. super.write(ostream);
  93. if (this.service_contexts != null) {
  94. service_contexts.write(
  95. (org.omg.CORBA_2_3.portable.OutputStream) ostream,
  96. GIOPVersion.V1_0);
  97. } else {
  98. ServiceContexts.writeNullServiceContext(
  99. (org.omg.CORBA_2_3.portable.OutputStream) ostream);
  100. }
  101. ostream.write_ulong(this.request_id);
  102. ostream.write_boolean(this.response_expected);
  103. nullCheck(this.object_key);
  104. ostream.write_long(this.object_key.length);
  105. ostream.write_octet_array(this.object_key, 0, this.object_key.length);
  106. ostream.write_string(this.operation);
  107. if (this.requesting_principal != null) {
  108. ostream.write_Principal(this.requesting_principal);
  109. } else {
  110. ostream.write_long(0);
  111. }
  112. }
  113. public void callback(MessageHandler handler)
  114. throws java.io.IOException
  115. {
  116. handler.handleInput(this);
  117. }
  118. } // class RequestMessage_1_0