1. /*
  2. * @(#)LocalClientResponseImpl.java 1.24 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;
  8. import java.io.IOException;
  9. import org.omg.CORBA.SystemException;
  10. import org.omg.CORBA.CompletionStatus;
  11. import com.sun.corba.se.internal.core.Response;
  12. import com.sun.corba.se.internal.core.ClientResponse;
  13. import com.sun.corba.se.internal.core.IOR;
  14. import com.sun.corba.se.internal.core.ServiceContext;
  15. import com.sun.corba.se.internal.core.ServiceContexts;
  16. import com.sun.corba.se.internal.iiop.messages.Message;
  17. import com.sun.corba.se.internal.iiop.messages.ReplyMessage;
  18. import com.sun.corba.se.internal.orbutil.MinorCodes;
  19. class LocalClientResponseImpl extends IIOPInputStream implements ClientResponse
  20. {
  21. LocalClientResponseImpl(ORB orb, byte[] buf, ReplyMessage header)
  22. {
  23. super(orb, buf, header.getSize(), header.isLittleEndian(), header, null);
  24. this.reply = header;
  25. // NOTE (Ram J) (06/02/2000) if we set result.setIndex(bodyBegin)
  26. // in LocalServerResponse.getClientResponse(), then we do not need
  27. // to read the headers (done below) anymore.
  28. // This will be an optimisation which is can be done to speed up the
  29. // local invocation by avoiding reading the headers in the local cases.
  30. // BUGFIX(Ram Jeyaraman) This has been moved from
  31. // LocalServerResponse.getClientResponse()
  32. // Skip over all of the GIOP header information. This positions
  33. // the offset in the buffer so that the skeleton can correctly read
  34. // the marshalled arguments.
  35. this.setIndex(Message.GIOPMessageHeaderLength);
  36. // BUGFIX(Ram Jeyaraman) For local invocations, the reply mesg fields
  37. // needs to be set, by reading the response buffer contents
  38. // to correctly set the exception type and other info.
  39. this.reply.read(this);
  40. }
  41. LocalClientResponseImpl(SystemException ex)
  42. {
  43. this.systemException = ex;
  44. }
  45. public boolean isSystemException() {
  46. if ( reply != null )
  47. return reply.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION;
  48. else
  49. return (systemException != null);
  50. }
  51. public boolean isUserException() {
  52. if ( reply != null )
  53. return reply.getReplyStatus() == ReplyMessage.USER_EXCEPTION;
  54. else
  55. return false;
  56. }
  57. public boolean isLocationForward() {
  58. if ( reply != null ) {
  59. return ( (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD) ||
  60. (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD_PERM) );
  61. //return reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD;
  62. } else {
  63. return false;
  64. }
  65. }
  66. public boolean isDifferentAddrDispositionRequested() {
  67. if (reply != null) {
  68. return reply.getReplyStatus() == ReplyMessage.NEEDS_ADDRESSING_MODE;
  69. }
  70. return false;
  71. }
  72. public short getAddrDisposition() {
  73. if (reply != null) {
  74. return reply.getAddrDisposition();
  75. }
  76. throw new org.omg.CORBA.INTERNAL(
  77. "Null reply in getAddrDisposition",
  78. MinorCodes.NULL_REPLY_IN_GET_ADDR_DISPOSITION,
  79. CompletionStatus.COMPLETED_MAYBE);
  80. }
  81. public IOR getForwardedIOR() {
  82. if ( reply != null )
  83. return reply.getIOR();
  84. else
  85. return null;
  86. }
  87. public int getRequestId() {
  88. if ( reply != null )
  89. return reply.getRequestId();
  90. else
  91. throw new org.omg.CORBA.INTERNAL("Error in getRequestId");
  92. }
  93. public ServiceContexts getServiceContexts() {
  94. if ( reply != null )
  95. return reply.getServiceContexts();
  96. else
  97. return null;
  98. }
  99. public SystemException getSystemException() {
  100. if ( reply != null )
  101. return reply.getSystemException();
  102. else
  103. return systemException;
  104. }
  105. public java.lang.String peekUserExceptionId() {
  106. mark(Integer.MAX_VALUE);
  107. String result = read_string();
  108. reset();
  109. return result;
  110. }
  111. /**
  112. * Check to see if the response is local.
  113. */
  114. public boolean isLocal(){
  115. return true;
  116. }
  117. private ReplyMessage reply;
  118. private SystemException systemException;
  119. }