1. /*
  2. * @(#)ClientResponseImpl.java 1.35 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. public class ClientResponseImpl extends IIOPInputStream implements ClientResponse
  20. {
  21. protected ClientResponseImpl(Connection conn, byte[] buf, ReplyMessage header)
  22. throws IOException
  23. {
  24. super(conn, buf, header);
  25. this.reply = header;
  26. }
  27. protected ClientResponseImpl(SystemException ex)
  28. {
  29. this.systemException = ex;
  30. }
  31. public boolean isSystemException() {
  32. if ( reply != null )
  33. return reply.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION;
  34. else
  35. return (systemException != null);
  36. }
  37. public boolean isUserException() {
  38. if ( reply != null )
  39. return reply.getReplyStatus() == ReplyMessage.USER_EXCEPTION;
  40. else
  41. return false;
  42. }
  43. public boolean isLocationForward() {
  44. if ( reply != null ) {
  45. return ( (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD) ||
  46. (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD_PERM) );
  47. //return reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD;
  48. } else {
  49. return false;
  50. }
  51. }
  52. public boolean isDifferentAddrDispositionRequested() {
  53. if (reply != null) {
  54. return reply.getReplyStatus() == ReplyMessage.NEEDS_ADDRESSING_MODE;
  55. }
  56. return false;
  57. }
  58. public short getAddrDisposition() {
  59. if (reply != null) {
  60. return reply.getAddrDisposition();
  61. }
  62. throw new org.omg.CORBA.INTERNAL(
  63. "Null reply in getAddrDisposition",
  64. MinorCodes.NULL_REPLY_IN_GET_ADDR_DISPOSITION,
  65. CompletionStatus.COMPLETED_MAYBE);
  66. }
  67. public IOR getForwardedIOR() {
  68. if ( reply != null )
  69. return reply.getIOR();
  70. else
  71. return null;
  72. }
  73. public int getRequestId() {
  74. if ( reply != null )
  75. return reply.getRequestId();
  76. else
  77. throw new org.omg.CORBA.INTERNAL("Error in getRequestId");
  78. }
  79. public ServiceContexts getServiceContexts() {
  80. if ( reply != null )
  81. return reply.getServiceContexts();
  82. else
  83. return null;
  84. }
  85. public SystemException getSystemException() {
  86. if ( reply != null )
  87. return reply.getSystemException();
  88. else
  89. return systemException;
  90. }
  91. public java.lang.String peekUserExceptionId() {
  92. mark(Integer.MAX_VALUE);
  93. String result = read_string();
  94. reset();
  95. return result;
  96. }
  97. /**
  98. * Check to see if response is local.
  99. */
  100. public boolean isLocal(){
  101. return false;
  102. }
  103. protected ReplyMessage reply;
  104. private SystemException systemException;
  105. }