1 /* |
|
2 * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.corba.se.impl.iiop; |
|
27 |
|
28 import java.io.IOException; |
|
29 |
|
30 import org.omg.CORBA.SystemException; |
|
31 import org.omg.CORBA.CompletionStatus; |
|
32 |
|
33 import com.sun.corba.se.impl.core.Response; |
|
34 import com.sun.corba.se.impl.core.ClientResponse; |
|
35 import com.sun.corba.se.impl.corba.IOR; |
|
36 import com.sun.corba.se.impl.core.ORB; |
|
37 import com.sun.corba.se.impl.core.ServiceContext; |
|
38 import com.sun.corba.se.impl.core.ServiceContexts; |
|
39 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; |
|
40 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage; |
|
41 import com.sun.corba.se.impl.orbutil.MinorCodes; |
|
42 |
|
43 class LocalClientResponseImpl extends IIOPInputStream implements ClientResponse |
|
44 { |
|
45 LocalClientResponseImpl(ORB orb, byte[] buf, ReplyMessage header) |
|
46 { |
|
47 super(orb, buf, header.getSize(), header.isLittleEndian(), header, null); |
|
48 |
|
49 this.reply = header; |
|
50 |
|
51 // NOTE (Ram J) (06/02/2000) if we set result.setIndex(bodyBegin) |
|
52 // in LocalServerResponse.getClientResponse(), then we do not need |
|
53 // to read the headers (done below) anymore. |
|
54 // This will be an optimisation which is can be done to speed up the |
|
55 // local invocation by avoiding reading the headers in the local cases. |
|
56 |
|
57 // BUGFIX(Ram Jeyaraman) This has been moved from |
|
58 // LocalServerResponse.getClientResponse() |
|
59 // Skip over all of the GIOP header information. This positions |
|
60 // the offset in the buffer so that the skeleton can correctly read |
|
61 // the marshalled arguments. |
|
62 this.setIndex(Message.GIOPMessageHeaderLength); |
|
63 |
|
64 // BUGFIX(Ram Jeyaraman) For local invocations, the reply mesg fields |
|
65 // needs to be set, by reading the response buffer contents |
|
66 // to correctly set the exception type and other info. |
|
67 this.reply.read(this); |
|
68 } |
|
69 |
|
70 LocalClientResponseImpl(SystemException ex) |
|
71 { |
|
72 this.systemException = ex; |
|
73 } |
|
74 |
|
75 public boolean isSystemException() { |
|
76 if ( reply != null ) |
|
77 return reply.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION; |
|
78 else |
|
79 return (systemException != null); |
|
80 } |
|
81 |
|
82 public boolean isUserException() { |
|
83 if ( reply != null ) |
|
84 return reply.getReplyStatus() == ReplyMessage.USER_EXCEPTION; |
|
85 else |
|
86 return false; |
|
87 } |
|
88 |
|
89 public boolean isLocationForward() { |
|
90 if ( reply != null ) { |
|
91 return ( (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD) || |
|
92 (reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD_PERM) ); |
|
93 //return reply.getReplyStatus() == ReplyMessage.LOCATION_FORWARD; |
|
94 } else { |
|
95 return false; |
|
96 } |
|
97 } |
|
98 |
|
99 public boolean isDifferentAddrDispositionRequested() { |
|
100 if (reply != null) { |
|
101 return reply.getReplyStatus() == ReplyMessage.NEEDS_ADDRESSING_MODE; |
|
102 } |
|
103 |
|
104 return false; |
|
105 } |
|
106 |
|
107 public short getAddrDisposition() { |
|
108 if (reply != null) { |
|
109 return reply.getAddrDisposition(); |
|
110 } |
|
111 |
|
112 throw new org.omg.CORBA.INTERNAL( |
|
113 "Null reply in getAddrDisposition", |
|
114 MinorCodes.NULL_REPLY_IN_GET_ADDR_DISPOSITION, |
|
115 CompletionStatus.COMPLETED_MAYBE); |
|
116 } |
|
117 |
|
118 public IOR getForwardedIOR() { |
|
119 if ( reply != null ) |
|
120 return reply.getIOR(); |
|
121 else |
|
122 return null; |
|
123 } |
|
124 |
|
125 public int getRequestId() { |
|
126 if ( reply != null ) |
|
127 return reply.getRequestId(); |
|
128 else |
|
129 throw new org.omg.CORBA.INTERNAL("Error in getRequestId"); |
|
130 } |
|
131 |
|
132 public ServiceContexts getServiceContexts() { |
|
133 if ( reply != null ) |
|
134 return reply.getServiceContexts(); |
|
135 else |
|
136 return null; |
|
137 } |
|
138 |
|
139 public SystemException getSystemException() { |
|
140 if ( reply != null ) |
|
141 return reply.getSystemException(); |
|
142 else |
|
143 return systemException; |
|
144 } |
|
145 |
|
146 public java.lang.String peekUserExceptionId() { |
|
147 mark(Integer.MAX_VALUE); |
|
148 String result = read_string(); |
|
149 reset(); |
|
150 return result; |
|
151 } |
|
152 |
|
153 /** |
|
154 * Check to see if the response is local. |
|
155 */ |
|
156 public boolean isLocal(){ |
|
157 return true; |
|
158 } |
|
159 |
|
160 private ReplyMessage reply; |
|
161 private SystemException systemException; |
|
162 } |
|