Thu, 31 Aug 2017 18:10:36 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.corba.se.impl.protocol; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.ByteArrayOutputStream; |
aoqi@0 | 29 | import java.io.IOException; |
aoqi@0 | 30 | import java.io.PrintWriter; |
aoqi@0 | 31 | import java.nio.ByteBuffer; |
aoqi@0 | 32 | import java.nio.channels.SelectionKey; |
aoqi@0 | 33 | import java.util.EmptyStackException; |
aoqi@0 | 34 | import java.util.Iterator; |
aoqi@0 | 35 | |
aoqi@0 | 36 | import org.omg.CORBA.Any; |
aoqi@0 | 37 | import org.omg.CORBA.CompletionStatus; |
aoqi@0 | 38 | import org.omg.CORBA.ExceptionList; |
aoqi@0 | 39 | import org.omg.CORBA.INTERNAL; |
aoqi@0 | 40 | import org.omg.CORBA.Principal; |
aoqi@0 | 41 | import org.omg.CORBA.SystemException; |
aoqi@0 | 42 | import org.omg.CORBA.TypeCode; |
aoqi@0 | 43 | import org.omg.CORBA.UnknownUserException; |
aoqi@0 | 44 | import org.omg.CORBA.UNKNOWN; |
aoqi@0 | 45 | import org.omg.CORBA.portable.ResponseHandler; |
aoqi@0 | 46 | import org.omg.CORBA.portable.UnknownException; |
aoqi@0 | 47 | import org.omg.CORBA_2_3.portable.InputStream; |
aoqi@0 | 48 | import org.omg.CORBA_2_3.portable.OutputStream; |
aoqi@0 | 49 | import org.omg.IOP.ExceptionDetailMessage; |
aoqi@0 | 50 | import org.omg.IOP.TAG_RMI_CUSTOM_MAX_STREAM_FORMAT; |
aoqi@0 | 51 | |
aoqi@0 | 52 | import com.sun.corba.se.pept.broker.Broker; |
aoqi@0 | 53 | import com.sun.corba.se.pept.encoding.InputObject; |
aoqi@0 | 54 | import com.sun.corba.se.pept.encoding.OutputObject; |
aoqi@0 | 55 | import com.sun.corba.se.pept.protocol.MessageMediator; |
aoqi@0 | 56 | import com.sun.corba.se.pept.protocol.ProtocolHandler; |
aoqi@0 | 57 | import com.sun.corba.se.pept.transport.ByteBufferPool; |
aoqi@0 | 58 | import com.sun.corba.se.pept.transport.Connection; |
aoqi@0 | 59 | import com.sun.corba.se.pept.transport.ContactInfo; |
aoqi@0 | 60 | import com.sun.corba.se.pept.transport.EventHandler; |
aoqi@0 | 61 | |
aoqi@0 | 62 | import com.sun.corba.se.spi.ior.IOR; |
aoqi@0 | 63 | import com.sun.corba.se.spi.ior.ObjectKey; |
aoqi@0 | 64 | import com.sun.corba.se.spi.ior.ObjectKeyTemplate; |
aoqi@0 | 65 | import com.sun.corba.se.spi.ior.iiop.GIOPVersion; |
aoqi@0 | 66 | import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate; |
aoqi@0 | 67 | import com.sun.corba.se.spi.ior.iiop.IIOPProfile; |
aoqi@0 | 68 | import com.sun.corba.se.spi.ior.iiop.MaxStreamFormatVersionComponent; |
aoqi@0 | 69 | import com.sun.corba.se.spi.oa.OAInvocationInfo; |
aoqi@0 | 70 | import com.sun.corba.se.spi.oa.ObjectAdapter; |
aoqi@0 | 71 | import com.sun.corba.se.spi.orb.ORB; |
aoqi@0 | 72 | import com.sun.corba.se.spi.orb.ORBVersionFactory; |
aoqi@0 | 73 | import com.sun.corba.se.spi.protocol.CorbaMessageMediator; |
aoqi@0 | 74 | import com.sun.corba.se.spi.protocol.CorbaProtocolHandler; |
aoqi@0 | 75 | import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher; |
aoqi@0 | 76 | import com.sun.corba.se.spi.protocol.ForwardException; |
aoqi@0 | 77 | import com.sun.corba.se.spi.transport.CorbaConnection; |
aoqi@0 | 78 | import com.sun.corba.se.spi.transport.CorbaContactInfo; |
aoqi@0 | 79 | import com.sun.corba.se.spi.transport.CorbaResponseWaitingRoom; |
aoqi@0 | 80 | import com.sun.corba.se.spi.logging.CORBALogDomains; |
aoqi@0 | 81 | |
aoqi@0 | 82 | import com.sun.corba.se.spi.servicecontext.ORBVersionServiceContext; |
aoqi@0 | 83 | import com.sun.corba.se.spi.servicecontext.ServiceContexts; |
aoqi@0 | 84 | import com.sun.corba.se.spi.servicecontext.UEInfoServiceContext; |
aoqi@0 | 85 | import com.sun.corba.se.spi.servicecontext.MaxStreamFormatVersionServiceContext; |
aoqi@0 | 86 | import com.sun.corba.se.spi.servicecontext.SendingContextServiceContext; |
aoqi@0 | 87 | import com.sun.corba.se.spi.servicecontext.UnknownServiceContext; |
aoqi@0 | 88 | |
aoqi@0 | 89 | import com.sun.corba.se.impl.corba.RequestImpl; |
aoqi@0 | 90 | import com.sun.corba.se.impl.encoding.BufferManagerFactory; |
aoqi@0 | 91 | import com.sun.corba.se.impl.encoding.BufferManagerReadStream; |
aoqi@0 | 92 | import com.sun.corba.se.impl.encoding.CDRInputObject; |
aoqi@0 | 93 | import com.sun.corba.se.impl.encoding.CDROutputObject; |
aoqi@0 | 94 | import com.sun.corba.se.impl.encoding.EncapsOutputStream; |
aoqi@0 | 95 | import com.sun.corba.se.impl.logging.ORBUtilSystemException; |
aoqi@0 | 96 | import com.sun.corba.se.impl.logging.InterceptorsSystemException; |
aoqi@0 | 97 | import com.sun.corba.se.impl.orbutil.ORBConstants; |
aoqi@0 | 98 | import com.sun.corba.se.impl.orbutil.ORBUtility; |
aoqi@0 | 99 | import com.sun.corba.se.impl.ior.iiop.JavaSerializationComponent; |
aoqi@0 | 100 | import com.sun.corba.se.impl.protocol.AddressingDispositionException; |
aoqi@0 | 101 | import com.sun.corba.se.impl.protocol.RequestCanceledException; |
aoqi@0 | 102 | import com.sun.corba.se.impl.protocol.giopmsgheaders.AddressingDispositionHelper; |
aoqi@0 | 103 | import com.sun.corba.se.impl.protocol.giopmsgheaders.CancelRequestMessage; |
aoqi@0 | 104 | import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage_1_1; |
aoqi@0 | 105 | import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage_1_2; |
aoqi@0 | 106 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateRequestMessage; |
aoqi@0 | 107 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateRequestMessage_1_0; |
aoqi@0 | 108 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateRequestMessage_1_1; |
aoqi@0 | 109 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateRequestMessage_1_2; |
aoqi@0 | 110 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyOrReplyMessage; |
aoqi@0 | 111 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyMessage; |
aoqi@0 | 112 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyMessage_1_0; |
aoqi@0 | 113 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyMessage_1_1; |
aoqi@0 | 114 | import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyMessage_1_2; |
aoqi@0 | 115 | import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; |
aoqi@0 | 116 | import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase; |
aoqi@0 | 117 | import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageHandler; |
aoqi@0 | 118 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage; |
aoqi@0 | 119 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_0; |
aoqi@0 | 120 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_1; |
aoqi@0 | 121 | import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage_1_2; |
aoqi@0 | 122 | import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage; |
aoqi@0 | 123 | import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_0 ; |
aoqi@0 | 124 | import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_1 ; |
aoqi@0 | 125 | import com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2 ; |
aoqi@0 | 126 | |
aoqi@0 | 127 | // REVISIT: make sure no memory leaks in client/server request/reply maps. |
aoqi@0 | 128 | // REVISIT: normalize requestHeader, replyHeader, messageHeader. |
aoqi@0 | 129 | |
aoqi@0 | 130 | /** |
aoqi@0 | 131 | * @author Harold Carr |
aoqi@0 | 132 | */ |
aoqi@0 | 133 | public class CorbaMessageMediatorImpl |
aoqi@0 | 134 | implements |
aoqi@0 | 135 | CorbaMessageMediator, |
aoqi@0 | 136 | CorbaProtocolHandler, |
aoqi@0 | 137 | MessageHandler |
aoqi@0 | 138 | { |
aoqi@0 | 139 | protected ORB orb; |
aoqi@0 | 140 | protected ORBUtilSystemException wrapper ; |
aoqi@0 | 141 | protected InterceptorsSystemException interceptorWrapper ; |
aoqi@0 | 142 | protected CorbaContactInfo contactInfo; |
aoqi@0 | 143 | protected CorbaConnection connection; |
aoqi@0 | 144 | protected short addrDisposition; |
aoqi@0 | 145 | protected CDROutputObject outputObject; |
aoqi@0 | 146 | protected CDRInputObject inputObject; |
aoqi@0 | 147 | protected Message messageHeader; |
aoqi@0 | 148 | protected RequestMessage requestHeader; |
aoqi@0 | 149 | protected LocateReplyOrReplyMessage replyHeader; |
aoqi@0 | 150 | protected String replyExceptionDetailMessage; |
aoqi@0 | 151 | protected IOR replyIOR; |
aoqi@0 | 152 | protected Integer requestIdInteger; |
aoqi@0 | 153 | protected Message dispatchHeader; |
aoqi@0 | 154 | protected ByteBuffer dispatchByteBuffer; |
aoqi@0 | 155 | protected byte streamFormatVersion; |
aoqi@0 | 156 | protected boolean streamFormatVersionSet = false; |
aoqi@0 | 157 | |
aoqi@0 | 158 | protected org.omg.CORBA.Request diiRequest; |
aoqi@0 | 159 | |
aoqi@0 | 160 | protected boolean cancelRequestAlreadySent = false; |
aoqi@0 | 161 | |
aoqi@0 | 162 | protected ProtocolHandler protocolHandler; |
aoqi@0 | 163 | protected boolean _executeReturnServantInResponseConstructor = false; |
aoqi@0 | 164 | protected boolean _executeRemoveThreadInfoInResponseConstructor = false; |
aoqi@0 | 165 | protected boolean _executePIInResponseConstructor = false; |
aoqi@0 | 166 | |
aoqi@0 | 167 | // |
aoqi@0 | 168 | // Client-side constructor. |
aoqi@0 | 169 | // |
aoqi@0 | 170 | |
aoqi@0 | 171 | public CorbaMessageMediatorImpl(ORB orb, |
aoqi@0 | 172 | ContactInfo contactInfo, |
aoqi@0 | 173 | Connection connection, |
aoqi@0 | 174 | GIOPVersion giopVersion, |
aoqi@0 | 175 | IOR ior, |
aoqi@0 | 176 | int requestId, |
aoqi@0 | 177 | short addrDisposition, |
aoqi@0 | 178 | String operationName, |
aoqi@0 | 179 | boolean isOneWay) |
aoqi@0 | 180 | { |
aoqi@0 | 181 | this( orb, connection ) ; |
aoqi@0 | 182 | |
aoqi@0 | 183 | this.contactInfo = (CorbaContactInfo) contactInfo; |
aoqi@0 | 184 | this.addrDisposition = addrDisposition; |
aoqi@0 | 185 | |
aoqi@0 | 186 | streamFormatVersion = |
aoqi@0 | 187 | getStreamFormatVersionForThisRequest( |
aoqi@0 | 188 | ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR(), |
aoqi@0 | 189 | giopVersion); |
aoqi@0 | 190 | streamFormatVersionSet = true; |
aoqi@0 | 191 | |
aoqi@0 | 192 | requestHeader = (RequestMessage) MessageBase.createRequest( |
aoqi@0 | 193 | this.orb, |
aoqi@0 | 194 | giopVersion, |
aoqi@0 | 195 | ORBUtility.getEncodingVersion(orb, ior), |
aoqi@0 | 196 | requestId, |
aoqi@0 | 197 | !isOneWay, |
aoqi@0 | 198 | ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR(), |
aoqi@0 | 199 | this.addrDisposition, |
aoqi@0 | 200 | operationName, |
aoqi@0 | 201 | new ServiceContexts(orb), |
aoqi@0 | 202 | null); |
aoqi@0 | 203 | } |
aoqi@0 | 204 | |
aoqi@0 | 205 | // |
aoqi@0 | 206 | // Acceptor constructor. |
aoqi@0 | 207 | // |
aoqi@0 | 208 | |
aoqi@0 | 209 | public CorbaMessageMediatorImpl(ORB orb, |
aoqi@0 | 210 | Connection connection) |
aoqi@0 | 211 | { |
aoqi@0 | 212 | this.orb = orb; |
aoqi@0 | 213 | this.connection = (CorbaConnection)connection; |
aoqi@0 | 214 | this.wrapper = ORBUtilSystemException.get( orb, |
aoqi@0 | 215 | CORBALogDomains.RPC_PROTOCOL ) ; |
aoqi@0 | 216 | this.interceptorWrapper = InterceptorsSystemException.get( orb, |
aoqi@0 | 217 | CORBALogDomains.RPC_PROTOCOL ) ; |
aoqi@0 | 218 | } |
aoqi@0 | 219 | |
aoqi@0 | 220 | // |
aoqi@0 | 221 | // Dispatcher constructor. |
aoqi@0 | 222 | // |
aoqi@0 | 223 | |
aoqi@0 | 224 | // Note: in some cases (e.g., a reply message) this message |
aoqi@0 | 225 | // mediator will only be used for dispatch. Then the original |
aoqi@0 | 226 | // request side mediator will take over. |
aoqi@0 | 227 | public CorbaMessageMediatorImpl(ORB orb, |
aoqi@0 | 228 | CorbaConnection connection, |
aoqi@0 | 229 | Message dispatchHeader, |
aoqi@0 | 230 | ByteBuffer byteBuffer) |
aoqi@0 | 231 | { |
aoqi@0 | 232 | this( orb, connection ) ; |
aoqi@0 | 233 | this.dispatchHeader = dispatchHeader; |
aoqi@0 | 234 | this.dispatchByteBuffer = byteBuffer; |
aoqi@0 | 235 | } |
aoqi@0 | 236 | |
aoqi@0 | 237 | //////////////////////////////////////////////////// |
aoqi@0 | 238 | // |
aoqi@0 | 239 | // MessageMediator |
aoqi@0 | 240 | // |
aoqi@0 | 241 | |
aoqi@0 | 242 | public Broker getBroker() |
aoqi@0 | 243 | { |
aoqi@0 | 244 | return orb; |
aoqi@0 | 245 | } |
aoqi@0 | 246 | |
aoqi@0 | 247 | public ContactInfo getContactInfo() |
aoqi@0 | 248 | { |
aoqi@0 | 249 | return contactInfo; |
aoqi@0 | 250 | } |
aoqi@0 | 251 | |
aoqi@0 | 252 | public Connection getConnection() |
aoqi@0 | 253 | { |
aoqi@0 | 254 | return connection; |
aoqi@0 | 255 | } |
aoqi@0 | 256 | |
aoqi@0 | 257 | public void initializeMessage() |
aoqi@0 | 258 | { |
aoqi@0 | 259 | getRequestHeader().write(outputObject); |
aoqi@0 | 260 | } |
aoqi@0 | 261 | |
aoqi@0 | 262 | public void finishSendingRequest() |
aoqi@0 | 263 | { |
aoqi@0 | 264 | // REVISIT: probably move logic in outputObject to here. |
aoqi@0 | 265 | outputObject.finishSendingMessage(); |
aoqi@0 | 266 | } |
aoqi@0 | 267 | |
aoqi@0 | 268 | public InputObject waitForResponse() |
aoqi@0 | 269 | { |
aoqi@0 | 270 | if (getRequestHeader().isResponseExpected()) { |
aoqi@0 | 271 | return connection.waitForResponse(this); |
aoqi@0 | 272 | } |
aoqi@0 | 273 | return null; |
aoqi@0 | 274 | } |
aoqi@0 | 275 | |
aoqi@0 | 276 | public void setOutputObject(OutputObject outputObject) |
aoqi@0 | 277 | { |
aoqi@0 | 278 | this.outputObject = (CDROutputObject) outputObject; |
aoqi@0 | 279 | } |
aoqi@0 | 280 | |
aoqi@0 | 281 | public OutputObject getOutputObject() |
aoqi@0 | 282 | { |
aoqi@0 | 283 | return outputObject; |
aoqi@0 | 284 | } |
aoqi@0 | 285 | |
aoqi@0 | 286 | public void setInputObject(InputObject inputObject) |
aoqi@0 | 287 | { |
aoqi@0 | 288 | this.inputObject = (CDRInputObject) inputObject; |
aoqi@0 | 289 | } |
aoqi@0 | 290 | |
aoqi@0 | 291 | public InputObject getInputObject() |
aoqi@0 | 292 | { |
aoqi@0 | 293 | return inputObject; |
aoqi@0 | 294 | } |
aoqi@0 | 295 | |
aoqi@0 | 296 | //////////////////////////////////////////////////// |
aoqi@0 | 297 | // |
aoqi@0 | 298 | // CorbaMessageMediator |
aoqi@0 | 299 | // |
aoqi@0 | 300 | |
aoqi@0 | 301 | public void setReplyHeader(LocateReplyOrReplyMessage header) |
aoqi@0 | 302 | { |
aoqi@0 | 303 | this.replyHeader = header; |
aoqi@0 | 304 | this.replyIOR = header.getIOR(); // REVISIT - need separate field? |
aoqi@0 | 305 | } |
aoqi@0 | 306 | |
aoqi@0 | 307 | public LocateReplyMessage getLocateReplyHeader() |
aoqi@0 | 308 | { |
aoqi@0 | 309 | return (LocateReplyMessage) replyHeader; |
aoqi@0 | 310 | } |
aoqi@0 | 311 | |
aoqi@0 | 312 | public ReplyMessage getReplyHeader() |
aoqi@0 | 313 | { |
aoqi@0 | 314 | return (ReplyMessage) replyHeader; |
aoqi@0 | 315 | } |
aoqi@0 | 316 | |
aoqi@0 | 317 | public void setReplyExceptionDetailMessage(String message) |
aoqi@0 | 318 | { |
aoqi@0 | 319 | replyExceptionDetailMessage = message; |
aoqi@0 | 320 | } |
aoqi@0 | 321 | |
aoqi@0 | 322 | public RequestMessage getRequestHeader() |
aoqi@0 | 323 | { |
aoqi@0 | 324 | return requestHeader; |
aoqi@0 | 325 | } |
aoqi@0 | 326 | |
aoqi@0 | 327 | public GIOPVersion getGIOPVersion() |
aoqi@0 | 328 | { |
aoqi@0 | 329 | if (messageHeader != null) { |
aoqi@0 | 330 | return messageHeader.getGIOPVersion(); |
aoqi@0 | 331 | } |
aoqi@0 | 332 | return getRequestHeader().getGIOPVersion(); |
aoqi@0 | 333 | } |
aoqi@0 | 334 | |
aoqi@0 | 335 | public byte getEncodingVersion() { |
aoqi@0 | 336 | if (messageHeader != null) { |
aoqi@0 | 337 | return messageHeader.getEncodingVersion(); |
aoqi@0 | 338 | } |
aoqi@0 | 339 | return getRequestHeader().getEncodingVersion(); |
aoqi@0 | 340 | } |
aoqi@0 | 341 | |
aoqi@0 | 342 | public int getRequestId() |
aoqi@0 | 343 | { |
aoqi@0 | 344 | return getRequestHeader().getRequestId(); |
aoqi@0 | 345 | } |
aoqi@0 | 346 | |
aoqi@0 | 347 | public Integer getRequestIdInteger() |
aoqi@0 | 348 | { |
aoqi@0 | 349 | if (requestIdInteger == null) { |
aoqi@0 | 350 | requestIdInteger = new Integer(getRequestHeader().getRequestId()); |
aoqi@0 | 351 | } |
aoqi@0 | 352 | return requestIdInteger; |
aoqi@0 | 353 | } |
aoqi@0 | 354 | |
aoqi@0 | 355 | public boolean isOneWay() |
aoqi@0 | 356 | { |
aoqi@0 | 357 | return ! getRequestHeader().isResponseExpected(); |
aoqi@0 | 358 | } |
aoqi@0 | 359 | |
aoqi@0 | 360 | public short getAddrDisposition() |
aoqi@0 | 361 | { |
aoqi@0 | 362 | return addrDisposition; |
aoqi@0 | 363 | } |
aoqi@0 | 364 | |
aoqi@0 | 365 | public String getOperationName() |
aoqi@0 | 366 | { |
aoqi@0 | 367 | return getRequestHeader().getOperation(); |
aoqi@0 | 368 | } |
aoqi@0 | 369 | |
aoqi@0 | 370 | public ServiceContexts getRequestServiceContexts() |
aoqi@0 | 371 | { |
aoqi@0 | 372 | return getRequestHeader().getServiceContexts(); |
aoqi@0 | 373 | } |
aoqi@0 | 374 | |
aoqi@0 | 375 | public ServiceContexts getReplyServiceContexts() |
aoqi@0 | 376 | { |
aoqi@0 | 377 | return getReplyHeader().getServiceContexts(); |
aoqi@0 | 378 | } |
aoqi@0 | 379 | |
aoqi@0 | 380 | public void sendCancelRequestIfFinalFragmentNotSent() |
aoqi@0 | 381 | { |
aoqi@0 | 382 | if ((!sentFullMessage()) && sentFragment() && |
aoqi@0 | 383 | (!cancelRequestAlreadySent)) |
aoqi@0 | 384 | { |
aoqi@0 | 385 | try { |
aoqi@0 | 386 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 387 | dprint(".sendCancelRequestIfFinalFragmentNotSent->: " |
aoqi@0 | 388 | + opAndId(this)); |
aoqi@0 | 389 | } |
aoqi@0 | 390 | connection.sendCancelRequestWithLock(getGIOPVersion(), |
aoqi@0 | 391 | getRequestId()); |
aoqi@0 | 392 | // Case: first a location forward, then a marshaling |
aoqi@0 | 393 | // exception (e.g., non-serializable object). Only |
aoqi@0 | 394 | // send cancel once. |
aoqi@0 | 395 | cancelRequestAlreadySent = true; |
aoqi@0 | 396 | } catch (IOException e) { |
aoqi@0 | 397 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 398 | dprint(".sendCancelRequestIfFinalFragmentNotSent: !ERROR : " + opAndId(this), |
aoqi@0 | 399 | e); |
aoqi@0 | 400 | } |
aoqi@0 | 401 | |
aoqi@0 | 402 | // REVISIT: we could attempt to send a final incomplete |
aoqi@0 | 403 | // fragment in this case. |
aoqi@0 | 404 | throw interceptorWrapper.ioexceptionDuringCancelRequest( |
aoqi@0 | 405 | CompletionStatus.COMPLETED_MAYBE, e ); |
aoqi@0 | 406 | } finally { |
aoqi@0 | 407 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 408 | dprint(".sendCancelRequestIfFinalFragmentNotSent<-: " |
aoqi@0 | 409 | + opAndId(this)); |
aoqi@0 | 410 | } |
aoqi@0 | 411 | } |
aoqi@0 | 412 | } |
aoqi@0 | 413 | } |
aoqi@0 | 414 | |
aoqi@0 | 415 | public boolean sentFullMessage() |
aoqi@0 | 416 | { |
aoqi@0 | 417 | return outputObject.getBufferManager().sentFullMessage(); |
aoqi@0 | 418 | } |
aoqi@0 | 419 | |
aoqi@0 | 420 | public boolean sentFragment() |
aoqi@0 | 421 | { |
aoqi@0 | 422 | return outputObject.getBufferManager().sentFragment(); |
aoqi@0 | 423 | } |
aoqi@0 | 424 | |
aoqi@0 | 425 | public void setDIIInfo(org.omg.CORBA.Request diiRequest) |
aoqi@0 | 426 | { |
aoqi@0 | 427 | this.diiRequest = diiRequest; |
aoqi@0 | 428 | } |
aoqi@0 | 429 | |
aoqi@0 | 430 | public boolean isDIIRequest() |
aoqi@0 | 431 | { |
aoqi@0 | 432 | return diiRequest != null; |
aoqi@0 | 433 | } |
aoqi@0 | 434 | |
aoqi@0 | 435 | public Exception unmarshalDIIUserException(String repoId, InputStream is) |
aoqi@0 | 436 | { |
aoqi@0 | 437 | if (! isDIIRequest()) { |
aoqi@0 | 438 | return null; |
aoqi@0 | 439 | } |
aoqi@0 | 440 | |
aoqi@0 | 441 | ExceptionList _exceptions = diiRequest.exceptions(); |
aoqi@0 | 442 | |
aoqi@0 | 443 | try { |
aoqi@0 | 444 | // Find the typecode for the exception |
aoqi@0 | 445 | for (int i=0; i<_exceptions.count() ; i++) { |
aoqi@0 | 446 | TypeCode tc = _exceptions.item(i); |
aoqi@0 | 447 | if ( tc.id().equals(repoId) ) { |
aoqi@0 | 448 | // Since we dont have the actual user exception |
aoqi@0 | 449 | // class, the spec says we have to create an |
aoqi@0 | 450 | // UnknownUserException and put it in the |
aoqi@0 | 451 | // environment. |
aoqi@0 | 452 | Any eany = orb.create_any(); |
aoqi@0 | 453 | eany.read_value(is, (TypeCode)tc); |
aoqi@0 | 454 | |
aoqi@0 | 455 | return new UnknownUserException(eany); |
aoqi@0 | 456 | } |
aoqi@0 | 457 | } |
aoqi@0 | 458 | } catch (Exception b) { |
aoqi@0 | 459 | throw wrapper.unexpectedDiiException(b); |
aoqi@0 | 460 | } |
aoqi@0 | 461 | |
aoqi@0 | 462 | // must be a truly unknown exception |
aoqi@0 | 463 | return wrapper.unknownCorbaExc( CompletionStatus.COMPLETED_MAYBE); |
aoqi@0 | 464 | } |
aoqi@0 | 465 | |
aoqi@0 | 466 | public void setDIIException(Exception exception) |
aoqi@0 | 467 | { |
aoqi@0 | 468 | diiRequest.env().exception(exception); |
aoqi@0 | 469 | } |
aoqi@0 | 470 | |
aoqi@0 | 471 | public void handleDIIReply(InputStream inputStream) |
aoqi@0 | 472 | { |
aoqi@0 | 473 | if (! isDIIRequest()) { |
aoqi@0 | 474 | return; |
aoqi@0 | 475 | } |
aoqi@0 | 476 | ((RequestImpl)diiRequest).unmarshalReply(inputStream); |
aoqi@0 | 477 | } |
aoqi@0 | 478 | |
aoqi@0 | 479 | public Message getDispatchHeader() |
aoqi@0 | 480 | { |
aoqi@0 | 481 | return dispatchHeader; |
aoqi@0 | 482 | } |
aoqi@0 | 483 | |
aoqi@0 | 484 | public void setDispatchHeader(Message msg) |
aoqi@0 | 485 | { |
aoqi@0 | 486 | dispatchHeader = msg; |
aoqi@0 | 487 | } |
aoqi@0 | 488 | |
aoqi@0 | 489 | public ByteBuffer getDispatchBuffer() |
aoqi@0 | 490 | { |
aoqi@0 | 491 | return dispatchByteBuffer; |
aoqi@0 | 492 | } |
aoqi@0 | 493 | |
aoqi@0 | 494 | public void setDispatchBuffer(ByteBuffer byteBuffer) |
aoqi@0 | 495 | { |
aoqi@0 | 496 | dispatchByteBuffer = byteBuffer; |
aoqi@0 | 497 | } |
aoqi@0 | 498 | |
aoqi@0 | 499 | public int getThreadPoolToUse() { |
aoqi@0 | 500 | int poolToUse = 0; |
aoqi@0 | 501 | Message msg = getDispatchHeader(); |
aoqi@0 | 502 | // A null msg should never happen. But, we'll be |
aoqi@0 | 503 | // defensive just in case. |
aoqi@0 | 504 | if (msg != null) { |
aoqi@0 | 505 | poolToUse = msg.getThreadPoolToUse(); |
aoqi@0 | 506 | } |
aoqi@0 | 507 | return poolToUse; |
aoqi@0 | 508 | } |
aoqi@0 | 509 | |
aoqi@0 | 510 | public byte getStreamFormatVersion() |
aoqi@0 | 511 | { |
aoqi@0 | 512 | // REVISIT: ContactInfo/Acceptor output object factories |
aoqi@0 | 513 | // just use this. Maybe need to distinguish: |
aoqi@0 | 514 | // createOutputObjectForRequest |
aoqi@0 | 515 | // createOutputObjectForReply |
aoqi@0 | 516 | // then do getStreamFormatVersionForRequest/ForReply here. |
aoqi@0 | 517 | if (streamFormatVersionSet) { |
aoqi@0 | 518 | return streamFormatVersion; |
aoqi@0 | 519 | } |
aoqi@0 | 520 | return getStreamFormatVersionForReply(); |
aoqi@0 | 521 | } |
aoqi@0 | 522 | |
aoqi@0 | 523 | /** |
aoqi@0 | 524 | * If the RMI-IIOP maximum stream format version service context |
aoqi@0 | 525 | * is present, it indicates the maximum stream format version we |
aoqi@0 | 526 | * could use for the reply. If it isn't present, the default is |
aoqi@0 | 527 | * 2 for GIOP 1.3 or greater, 1 for lower. |
aoqi@0 | 528 | * |
aoqi@0 | 529 | * This is only sent on requests. Clients can find out the |
aoqi@0 | 530 | * server's maximum by looking for a tagged component in the IOR. |
aoqi@0 | 531 | */ |
aoqi@0 | 532 | public byte getStreamFormatVersionForReply() { |
aoqi@0 | 533 | |
aoqi@0 | 534 | // NOTE: The request service contexts may indicate the max. |
aoqi@0 | 535 | ServiceContexts svc = getRequestServiceContexts(); |
aoqi@0 | 536 | |
aoqi@0 | 537 | MaxStreamFormatVersionServiceContext msfvsc |
aoqi@0 | 538 | = (MaxStreamFormatVersionServiceContext)svc.get( |
aoqi@0 | 539 | MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID); |
aoqi@0 | 540 | |
aoqi@0 | 541 | if (msfvsc != null) { |
aoqi@0 | 542 | byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion(); |
aoqi@0 | 543 | byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion(); |
aoqi@0 | 544 | |
aoqi@0 | 545 | return (byte)Math.min(localMaxVersion, remoteMaxVersion); |
aoqi@0 | 546 | } else { |
aoqi@0 | 547 | // Defaults to 1 for GIOP 1.2 or less, 2 for |
aoqi@0 | 548 | // GIOP 1.3 or higher. |
aoqi@0 | 549 | if (getGIOPVersion().lessThan(GIOPVersion.V1_3)) |
aoqi@0 | 550 | return ORBConstants.STREAM_FORMAT_VERSION_1; |
aoqi@0 | 551 | else |
aoqi@0 | 552 | return ORBConstants.STREAM_FORMAT_VERSION_2; |
aoqi@0 | 553 | } |
aoqi@0 | 554 | } |
aoqi@0 | 555 | |
aoqi@0 | 556 | public boolean isSystemExceptionReply() |
aoqi@0 | 557 | { |
aoqi@0 | 558 | return replyHeader.getReplyStatus() == ReplyMessage.SYSTEM_EXCEPTION; |
aoqi@0 | 559 | } |
aoqi@0 | 560 | |
aoqi@0 | 561 | public boolean isUserExceptionReply() |
aoqi@0 | 562 | { |
aoqi@0 | 563 | return replyHeader.getReplyStatus() == ReplyMessage.USER_EXCEPTION; |
aoqi@0 | 564 | } |
aoqi@0 | 565 | |
aoqi@0 | 566 | public boolean isLocationForwardReply() |
aoqi@0 | 567 | { |
aoqi@0 | 568 | return ( (replyHeader.getReplyStatus() == ReplyMessage.LOCATION_FORWARD) || |
aoqi@0 | 569 | (replyHeader.getReplyStatus() == ReplyMessage.LOCATION_FORWARD_PERM) ); |
aoqi@0 | 570 | //return replyHeader.getReplyStatus() == ReplyMessage.LOCATION_FORWARD; |
aoqi@0 | 571 | } |
aoqi@0 | 572 | |
aoqi@0 | 573 | public boolean isDifferentAddrDispositionRequestedReply() |
aoqi@0 | 574 | { |
aoqi@0 | 575 | return replyHeader.getReplyStatus() == ReplyMessage.NEEDS_ADDRESSING_MODE; |
aoqi@0 | 576 | } |
aoqi@0 | 577 | |
aoqi@0 | 578 | public short getAddrDispositionReply() |
aoqi@0 | 579 | { |
aoqi@0 | 580 | return replyHeader.getAddrDisposition(); |
aoqi@0 | 581 | } |
aoqi@0 | 582 | |
aoqi@0 | 583 | public IOR getForwardedIOR() |
aoqi@0 | 584 | { |
aoqi@0 | 585 | return replyHeader.getIOR(); |
aoqi@0 | 586 | } |
aoqi@0 | 587 | |
aoqi@0 | 588 | public SystemException getSystemExceptionReply() |
aoqi@0 | 589 | { |
aoqi@0 | 590 | return replyHeader.getSystemException(replyExceptionDetailMessage); |
aoqi@0 | 591 | } |
aoqi@0 | 592 | |
aoqi@0 | 593 | //////////////////////////////////////////////////// |
aoqi@0 | 594 | // |
aoqi@0 | 595 | // Used by server side. |
aoqi@0 | 596 | // |
aoqi@0 | 597 | |
aoqi@0 | 598 | public ObjectKey getObjectKey() |
aoqi@0 | 599 | { |
aoqi@0 | 600 | return getRequestHeader().getObjectKey(); |
aoqi@0 | 601 | } |
aoqi@0 | 602 | |
aoqi@0 | 603 | public void setProtocolHandler(CorbaProtocolHandler protocolHandler) |
aoqi@0 | 604 | { |
aoqi@0 | 605 | throw wrapper.methodShouldNotBeCalled() ; |
aoqi@0 | 606 | } |
aoqi@0 | 607 | |
aoqi@0 | 608 | public CorbaProtocolHandler getProtocolHandler() |
aoqi@0 | 609 | { |
aoqi@0 | 610 | // REVISIT: should look up in orb registry. |
aoqi@0 | 611 | return this; |
aoqi@0 | 612 | } |
aoqi@0 | 613 | |
aoqi@0 | 614 | //////////////////////////////////////////////////// |
aoqi@0 | 615 | // |
aoqi@0 | 616 | // ResponseHandler |
aoqi@0 | 617 | // |
aoqi@0 | 618 | |
aoqi@0 | 619 | public org.omg.CORBA.portable.OutputStream createReply() |
aoqi@0 | 620 | { |
aoqi@0 | 621 | // Note: relies on side-effect of setting mediator output field. |
aoqi@0 | 622 | // REVISIT - cast - need interface |
aoqi@0 | 623 | getProtocolHandler().createResponse(this, (ServiceContexts) null); |
aoqi@0 | 624 | return (OutputStream) getOutputObject(); |
aoqi@0 | 625 | } |
aoqi@0 | 626 | |
aoqi@0 | 627 | public org.omg.CORBA.portable.OutputStream createExceptionReply() |
aoqi@0 | 628 | { |
aoqi@0 | 629 | // Note: relies on side-effect of setting mediator output field. |
aoqi@0 | 630 | // REVISIT - cast - need interface |
aoqi@0 | 631 | getProtocolHandler().createUserExceptionResponse(this, (ServiceContexts) null); |
aoqi@0 | 632 | return (OutputStream) getOutputObject(); |
aoqi@0 | 633 | } |
aoqi@0 | 634 | |
aoqi@0 | 635 | public boolean executeReturnServantInResponseConstructor() |
aoqi@0 | 636 | { |
aoqi@0 | 637 | return _executeReturnServantInResponseConstructor; |
aoqi@0 | 638 | |
aoqi@0 | 639 | } |
aoqi@0 | 640 | |
aoqi@0 | 641 | public void setExecuteReturnServantInResponseConstructor(boolean b) |
aoqi@0 | 642 | { |
aoqi@0 | 643 | _executeReturnServantInResponseConstructor = b; |
aoqi@0 | 644 | } |
aoqi@0 | 645 | |
aoqi@0 | 646 | public boolean executeRemoveThreadInfoInResponseConstructor() |
aoqi@0 | 647 | { |
aoqi@0 | 648 | return _executeRemoveThreadInfoInResponseConstructor; |
aoqi@0 | 649 | } |
aoqi@0 | 650 | |
aoqi@0 | 651 | public void setExecuteRemoveThreadInfoInResponseConstructor(boolean b) |
aoqi@0 | 652 | { |
aoqi@0 | 653 | _executeRemoveThreadInfoInResponseConstructor = b; |
aoqi@0 | 654 | } |
aoqi@0 | 655 | |
aoqi@0 | 656 | public boolean executePIInResponseConstructor() |
aoqi@0 | 657 | { |
aoqi@0 | 658 | return _executePIInResponseConstructor; |
aoqi@0 | 659 | } |
aoqi@0 | 660 | |
aoqi@0 | 661 | public void setExecutePIInResponseConstructor( boolean b ) |
aoqi@0 | 662 | { |
aoqi@0 | 663 | _executePIInResponseConstructor = b; |
aoqi@0 | 664 | } |
aoqi@0 | 665 | |
aoqi@0 | 666 | private byte getStreamFormatVersionForThisRequest(IOR ior, |
aoqi@0 | 667 | GIOPVersion giopVersion) |
aoqi@0 | 668 | { |
aoqi@0 | 669 | |
aoqi@0 | 670 | byte localMaxVersion |
aoqi@0 | 671 | = ORBUtility.getMaxStreamFormatVersion(); |
aoqi@0 | 672 | |
aoqi@0 | 673 | IOR effectiveTargetIOR = |
aoqi@0 | 674 | ((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR(); |
aoqi@0 | 675 | IIOPProfileTemplate temp = |
aoqi@0 | 676 | (IIOPProfileTemplate)effectiveTargetIOR.getProfile().getTaggedProfileTemplate(); |
aoqi@0 | 677 | Iterator iter = temp.iteratorById(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.value); |
aoqi@0 | 678 | if (!iter.hasNext()) { |
aoqi@0 | 679 | // Didn't have the max stream format version tagged |
aoqi@0 | 680 | // component. |
aoqi@0 | 681 | if (giopVersion.lessThan(GIOPVersion.V1_3)) |
aoqi@0 | 682 | return ORBConstants.STREAM_FORMAT_VERSION_1; |
aoqi@0 | 683 | else |
aoqi@0 | 684 | return ORBConstants.STREAM_FORMAT_VERSION_2; |
aoqi@0 | 685 | } |
aoqi@0 | 686 | |
aoqi@0 | 687 | byte remoteMaxVersion |
aoqi@0 | 688 | = ((MaxStreamFormatVersionComponent)iter.next()).getMaxStreamFormatVersion(); |
aoqi@0 | 689 | |
aoqi@0 | 690 | return (byte)Math.min(localMaxVersion, remoteMaxVersion); |
aoqi@0 | 691 | } |
aoqi@0 | 692 | |
aoqi@0 | 693 | //////////////////////////////////////////////////////////////////////// |
aoqi@0 | 694 | //////////////////////////////////////////////////////////////////////// |
aoqi@0 | 695 | //////////////////////////////////////////////////////////////////////// |
aoqi@0 | 696 | |
aoqi@0 | 697 | // REVISIT - This could be a separate implementation object looked |
aoqi@0 | 698 | // up in a registry. However it needs some state in the message |
aoqi@0 | 699 | // mediator so combine for now. |
aoqi@0 | 700 | |
aoqi@0 | 701 | |
aoqi@0 | 702 | protected boolean isThreadDone = false; |
aoqi@0 | 703 | |
aoqi@0 | 704 | //////////////////////////////////////////////////// |
aoqi@0 | 705 | // |
aoqi@0 | 706 | // pept.protocol.ProtocolHandler |
aoqi@0 | 707 | // |
aoqi@0 | 708 | |
aoqi@0 | 709 | public boolean handleRequest(MessageMediator messageMediator) |
aoqi@0 | 710 | { |
aoqi@0 | 711 | try { |
aoqi@0 | 712 | dispatchHeader.callback(this); |
aoqi@0 | 713 | } catch (IOException e) { |
aoqi@0 | 714 | // REVISIT - this should be handled internally. |
aoqi@0 | 715 | ; |
aoqi@0 | 716 | } |
aoqi@0 | 717 | return isThreadDone; |
aoqi@0 | 718 | } |
aoqi@0 | 719 | |
aoqi@0 | 720 | //////////////////////////////////////////////////// |
aoqi@0 | 721 | // |
aoqi@0 | 722 | // iiop.messages.MessageHandler |
aoqi@0 | 723 | // |
aoqi@0 | 724 | |
aoqi@0 | 725 | private void setWorkThenPoolOrResumeSelect(Message header) |
aoqi@0 | 726 | { |
aoqi@0 | 727 | if (getConnection().getEventHandler().shouldUseSelectThreadToWait()) { |
aoqi@0 | 728 | resumeSelect(header); |
aoqi@0 | 729 | } else { |
aoqi@0 | 730 | // Leader/Follower when using reader thread. |
aoqi@0 | 731 | // When this thread is done working it will go back in pool. |
aoqi@0 | 732 | |
aoqi@0 | 733 | isThreadDone = true; |
aoqi@0 | 734 | |
aoqi@0 | 735 | // First unregister current registration. |
aoqi@0 | 736 | orb.getTransportManager().getSelector(0) |
aoqi@0 | 737 | .unregisterForEvent(getConnection().getEventHandler()); |
aoqi@0 | 738 | // Have another thread become the reader. |
aoqi@0 | 739 | orb.getTransportManager().getSelector(0) |
aoqi@0 | 740 | .registerForEvent(getConnection().getEventHandler()); |
aoqi@0 | 741 | } |
aoqi@0 | 742 | } |
aoqi@0 | 743 | |
aoqi@0 | 744 | private void setWorkThenReadOrResumeSelect(Message header) |
aoqi@0 | 745 | { |
aoqi@0 | 746 | if (getConnection().getEventHandler().shouldUseSelectThreadToWait()) { |
aoqi@0 | 747 | resumeSelect(header); |
aoqi@0 | 748 | } else { |
aoqi@0 | 749 | // When using reader thread then wen this thread is |
aoqi@0 | 750 | // done working it will continue reading. |
aoqi@0 | 751 | isThreadDone = false; |
aoqi@0 | 752 | } |
aoqi@0 | 753 | } |
aoqi@0 | 754 | |
aoqi@0 | 755 | private void resumeSelect(Message header) |
aoqi@0 | 756 | { |
aoqi@0 | 757 | // NOTE: VERY IMPORTANT: |
aoqi@0 | 758 | // Only participate in select after getting to the point |
aoqi@0 | 759 | // that proper serialization of fragments is ensured. |
aoqi@0 | 760 | |
aoqi@0 | 761 | if (transportDebug()) { |
aoqi@0 | 762 | dprint(".resumeSelect:->"); |
aoqi@0 | 763 | // REVISIT: not-OO: |
aoqi@0 | 764 | String requestId = "?"; |
aoqi@0 | 765 | if (header instanceof RequestMessage) { |
aoqi@0 | 766 | requestId = |
aoqi@0 | 767 | new Integer(((RequestMessage)header) |
aoqi@0 | 768 | .getRequestId()).toString(); |
aoqi@0 | 769 | } else if (header instanceof ReplyMessage) { |
aoqi@0 | 770 | requestId = |
aoqi@0 | 771 | new Integer(((ReplyMessage)header) |
aoqi@0 | 772 | .getRequestId()).toString(); |
aoqi@0 | 773 | } else if (header instanceof FragmentMessage_1_2) { |
aoqi@0 | 774 | requestId = |
aoqi@0 | 775 | new Integer(((FragmentMessage_1_2)header) |
aoqi@0 | 776 | .getRequestId()).toString(); |
aoqi@0 | 777 | } |
aoqi@0 | 778 | dprint(".resumeSelect: id/" |
aoqi@0 | 779 | + requestId |
aoqi@0 | 780 | + " " + getConnection() |
aoqi@0 | 781 | ); |
aoqi@0 | 782 | |
aoqi@0 | 783 | } |
aoqi@0 | 784 | |
aoqi@0 | 785 | // IMPORTANT: To avoid bug (4953599), we force the Thread that does the NIO select |
aoqi@0 | 786 | // to also do the enable/disable of Ops using SelectionKey.interestOps(Ops of Interest). |
aoqi@0 | 787 | // Otherwise, the SelectionKey.interestOps(Ops of Interest) may block indefinitely in |
aoqi@0 | 788 | // this thread. |
aoqi@0 | 789 | EventHandler eventHandler = getConnection().getEventHandler(); |
aoqi@0 | 790 | orb.getTransportManager().getSelector(0).registerInterestOps(eventHandler); |
aoqi@0 | 791 | |
aoqi@0 | 792 | if (transportDebug()) { |
aoqi@0 | 793 | dprint(".resumeSelect:<-"); |
aoqi@0 | 794 | } |
aoqi@0 | 795 | } |
aoqi@0 | 796 | |
aoqi@0 | 797 | private void setInputObject() |
aoqi@0 | 798 | { |
aoqi@0 | 799 | // REVISIT: refactor createInputObject (and createMessageMediator) |
aoqi@0 | 800 | // into base PlugInFactory. Get via connection (either ContactInfo |
aoqi@0 | 801 | // or Acceptor). |
aoqi@0 | 802 | if (getConnection().getContactInfo() != null) { |
aoqi@0 | 803 | inputObject = (CDRInputObject) |
aoqi@0 | 804 | getConnection().getContactInfo() |
aoqi@0 | 805 | .createInputObject(orb, this); |
aoqi@0 | 806 | } else if (getConnection().getAcceptor() != null) { |
aoqi@0 | 807 | inputObject = (CDRInputObject) |
aoqi@0 | 808 | getConnection().getAcceptor() |
aoqi@0 | 809 | .createInputObject(orb, this); |
aoqi@0 | 810 | } else { |
aoqi@0 | 811 | throw new RuntimeException("CorbaMessageMediatorImpl.setInputObject"); |
aoqi@0 | 812 | } |
aoqi@0 | 813 | inputObject.setMessageMediator(this); |
aoqi@0 | 814 | setInputObject(inputObject); |
aoqi@0 | 815 | } |
aoqi@0 | 816 | |
aoqi@0 | 817 | private void signalResponseReceived() |
aoqi@0 | 818 | { |
aoqi@0 | 819 | // This will end up using the MessageMediator associated with |
aoqi@0 | 820 | // the original request instead of the current mediator (which |
aoqi@0 | 821 | // need to be constructed to hold the dispatchBuffer and connection). |
aoqi@0 | 822 | connection.getResponseWaitingRoom() |
aoqi@0 | 823 | .responseReceived((InputObject)inputObject); |
aoqi@0 | 824 | } |
aoqi@0 | 825 | |
aoqi@0 | 826 | // This handles message types for which we don't create classes. |
aoqi@0 | 827 | public void handleInput(Message header) throws IOException |
aoqi@0 | 828 | { |
aoqi@0 | 829 | try { |
aoqi@0 | 830 | messageHeader = header; |
aoqi@0 | 831 | |
aoqi@0 | 832 | if (transportDebug()) |
aoqi@0 | 833 | dprint(".handleInput->: " |
aoqi@0 | 834 | + MessageBase.typeToString(header.getType())); |
aoqi@0 | 835 | |
aoqi@0 | 836 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 837 | |
aoqi@0 | 838 | switch(header.getType()) |
aoqi@0 | 839 | { |
aoqi@0 | 840 | case Message.GIOPCloseConnection: |
aoqi@0 | 841 | if (transportDebug()) { |
aoqi@0 | 842 | dprint(".handleInput: CloseConnection: purging"); |
aoqi@0 | 843 | } |
aoqi@0 | 844 | connection.purgeCalls(wrapper.connectionRebind(), true, false); |
aoqi@0 | 845 | break; |
aoqi@0 | 846 | case Message.GIOPMessageError: |
aoqi@0 | 847 | if (transportDebug()) { |
aoqi@0 | 848 | dprint(".handleInput: MessageError: purging"); |
aoqi@0 | 849 | } |
aoqi@0 | 850 | connection.purgeCalls(wrapper.recvMsgError(), true, false); |
aoqi@0 | 851 | break; |
aoqi@0 | 852 | default: |
aoqi@0 | 853 | if (transportDebug()) { |
aoqi@0 | 854 | dprint(".handleInput: ERROR: " |
aoqi@0 | 855 | + MessageBase.typeToString(header.getType())); |
aoqi@0 | 856 | } |
aoqi@0 | 857 | throw wrapper.badGiopRequestType() ; |
aoqi@0 | 858 | } |
aoqi@0 | 859 | releaseByteBufferToPool(); |
aoqi@0 | 860 | } finally { |
aoqi@0 | 861 | if (transportDebug()) { |
aoqi@0 | 862 | dprint(".handleInput<-: " |
aoqi@0 | 863 | + MessageBase.typeToString(header.getType())); |
aoqi@0 | 864 | } |
aoqi@0 | 865 | } |
aoqi@0 | 866 | } |
aoqi@0 | 867 | |
aoqi@0 | 868 | public void handleInput(RequestMessage_1_0 header) throws IOException |
aoqi@0 | 869 | { |
aoqi@0 | 870 | try { |
aoqi@0 | 871 | if (transportDebug()) dprint(".REQUEST 1.0->: " + header); |
aoqi@0 | 872 | try { |
aoqi@0 | 873 | messageHeader = requestHeader = (RequestMessage) header; |
aoqi@0 | 874 | setInputObject(); |
aoqi@0 | 875 | } finally { |
aoqi@0 | 876 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 877 | } |
aoqi@0 | 878 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 879 | } catch (Throwable t) { |
aoqi@0 | 880 | if (transportDebug()) |
aoqi@0 | 881 | dprint(".REQUEST 1.0: !!ERROR!!: " + header, t); |
aoqi@0 | 882 | // Mask the exception from thread.; |
aoqi@0 | 883 | } finally { |
aoqi@0 | 884 | if (transportDebug()) dprint(".REQUEST 1.0<-: " + header); |
aoqi@0 | 885 | } |
aoqi@0 | 886 | } |
aoqi@0 | 887 | |
aoqi@0 | 888 | public void handleInput(RequestMessage_1_1 header) throws IOException |
aoqi@0 | 889 | { |
aoqi@0 | 890 | try { |
aoqi@0 | 891 | if (transportDebug()) dprint(".REQUEST 1.1->: " + header); |
aoqi@0 | 892 | try { |
aoqi@0 | 893 | messageHeader = requestHeader = (RequestMessage) header; |
aoqi@0 | 894 | setInputObject(); |
aoqi@0 | 895 | connection.serverRequest_1_1_Put(this); |
aoqi@0 | 896 | } finally { |
aoqi@0 | 897 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 898 | } |
aoqi@0 | 899 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 900 | } catch (Throwable t) { |
aoqi@0 | 901 | if (transportDebug()) |
aoqi@0 | 902 | dprint(".REQUEST 1.1: !!ERROR!!: " + header, t); |
aoqi@0 | 903 | // Mask the exception from thread.; |
aoqi@0 | 904 | } finally { |
aoqi@0 | 905 | if (transportDebug()) dprint(".REQUEST 1.1<-: " + header); |
aoqi@0 | 906 | } |
aoqi@0 | 907 | } |
aoqi@0 | 908 | |
aoqi@0 | 909 | // REVISIT: this is identical to 1_0 except for fragment part. |
aoqi@0 | 910 | public void handleInput(RequestMessage_1_2 header) throws IOException |
aoqi@0 | 911 | { |
aoqi@0 | 912 | try { |
aoqi@0 | 913 | try { |
aoqi@0 | 914 | |
aoqi@0 | 915 | messageHeader = requestHeader = (RequestMessage) header; |
aoqi@0 | 916 | |
aoqi@0 | 917 | header.unmarshalRequestID(dispatchByteBuffer); |
aoqi@0 | 918 | setInputObject(); |
aoqi@0 | 919 | |
aoqi@0 | 920 | if (transportDebug()) dprint(".REQUEST 1.2->: id/" |
aoqi@0 | 921 | + header.getRequestId() |
aoqi@0 | 922 | + ": " |
aoqi@0 | 923 | + header); |
aoqi@0 | 924 | |
aoqi@0 | 925 | // NOTE: in the old code this used to be done conditionally: |
aoqi@0 | 926 | // if (header.moreFragmentsToFollow()). |
aoqi@0 | 927 | // Now we always put it in. We take it out when |
aoqi@0 | 928 | // the response is done. |
aoqi@0 | 929 | // This must happen now so if a header is fragmented the stream |
aoqi@0 | 930 | // may be found. |
aoqi@0 | 931 | connection.serverRequestMapPut(header.getRequestId(), this); |
aoqi@0 | 932 | } finally { |
aoqi@0 | 933 | // Leader/Follower. |
aoqi@0 | 934 | // Note: This *MUST* come after putting stream in above map |
aoqi@0 | 935 | // since the header may be fragmented and you do not want to |
aoqi@0 | 936 | // start reading again until the map above is set. |
aoqi@0 | 937 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 938 | } |
aoqi@0 | 939 | //inputObject.unmarshalHeader(); // done in subcontract. |
aoqi@0 | 940 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 941 | } catch (Throwable t) { |
aoqi@0 | 942 | if (transportDebug()) dprint(".REQUEST 1.2: id/" |
aoqi@0 | 943 | + header.getRequestId() |
aoqi@0 | 944 | + ": !!ERROR!!: " |
aoqi@0 | 945 | + header, |
aoqi@0 | 946 | t); |
aoqi@0 | 947 | // Mask the exception from thread.; |
aoqi@0 | 948 | } finally { |
aoqi@0 | 949 | connection.serverRequestMapRemove(header.getRequestId()); |
aoqi@0 | 950 | |
aoqi@0 | 951 | if (transportDebug()) dprint(".REQUEST 1.2<-: id/" |
aoqi@0 | 952 | + header.getRequestId() |
aoqi@0 | 953 | + ": " |
aoqi@0 | 954 | + header); |
aoqi@0 | 955 | } |
aoqi@0 | 956 | } |
aoqi@0 | 957 | |
aoqi@0 | 958 | public void handleInput(ReplyMessage_1_0 header) throws IOException |
aoqi@0 | 959 | { |
aoqi@0 | 960 | try { |
aoqi@0 | 961 | try { |
aoqi@0 | 962 | if (transportDebug()) dprint(".REPLY 1.0->: " + header); |
aoqi@0 | 963 | messageHeader = replyHeader = (ReplyMessage) header; |
aoqi@0 | 964 | setInputObject(); |
aoqi@0 | 965 | |
aoqi@0 | 966 | // REVISIT: this should be done by waiting thread. |
aoqi@0 | 967 | inputObject.unmarshalHeader(); |
aoqi@0 | 968 | |
aoqi@0 | 969 | signalResponseReceived(); |
aoqi@0 | 970 | } finally{ |
aoqi@0 | 971 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 972 | } |
aoqi@0 | 973 | } catch (Throwable t) { |
aoqi@0 | 974 | if (transportDebug())dprint(".REPLY 1.0: !!ERROR!!: " + header, t); |
aoqi@0 | 975 | // Mask the exception from thread.; |
aoqi@0 | 976 | } finally { |
aoqi@0 | 977 | if (transportDebug()) dprint(".REPLY 1.0<-: " + header); |
aoqi@0 | 978 | } |
aoqi@0 | 979 | } |
aoqi@0 | 980 | |
aoqi@0 | 981 | public void handleInput(ReplyMessage_1_1 header) throws IOException |
aoqi@0 | 982 | { |
aoqi@0 | 983 | try { |
aoqi@0 | 984 | if (transportDebug()) dprint(".REPLY 1.1->: " + header); |
aoqi@0 | 985 | messageHeader = replyHeader = (ReplyMessage) header; |
aoqi@0 | 986 | setInputObject(); |
aoqi@0 | 987 | |
aoqi@0 | 988 | if (header.moreFragmentsToFollow()) { |
aoqi@0 | 989 | |
aoqi@0 | 990 | // More fragments are coming to complete this reply, so keep |
aoqi@0 | 991 | // a reference to the InputStream so we can add the fragments |
aoqi@0 | 992 | connection.clientReply_1_1_Put(this); |
aoqi@0 | 993 | |
aoqi@0 | 994 | // In 1.1, we can't assume that we have the request ID in the |
aoqi@0 | 995 | // first fragment. Thus, another thread is used |
aoqi@0 | 996 | // to be the reader while this thread unmarshals |
aoqi@0 | 997 | // the extended header and wakes up the client thread. |
aoqi@0 | 998 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 999 | |
aoqi@0 | 1000 | // REVISIT - error handling. |
aoqi@0 | 1001 | // This must be done now. |
aoqi@0 | 1002 | inputObject.unmarshalHeader(); |
aoqi@0 | 1003 | |
aoqi@0 | 1004 | signalResponseReceived(); |
aoqi@0 | 1005 | |
aoqi@0 | 1006 | } else { |
aoqi@0 | 1007 | |
aoqi@0 | 1008 | // Not fragmented, therefore we know the request |
aoqi@0 | 1009 | // ID is here. Thus, we can unmarshal the extended header |
aoqi@0 | 1010 | // and wake up the client thread without using a third |
aoqi@0 | 1011 | // thread as above. |
aoqi@0 | 1012 | |
aoqi@0 | 1013 | // REVISIT - error handling during unmarshal. |
aoqi@0 | 1014 | // This must be done now to get the request id. |
aoqi@0 | 1015 | inputObject.unmarshalHeader(); |
aoqi@0 | 1016 | |
aoqi@0 | 1017 | signalResponseReceived(); |
aoqi@0 | 1018 | |
aoqi@0 | 1019 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1020 | } |
aoqi@0 | 1021 | } catch (Throwable t) { |
aoqi@0 | 1022 | if (transportDebug()) dprint(".REPLY 1.1: !!ERROR!!: " + header); |
aoqi@0 | 1023 | // Mask the exception from thread.; |
aoqi@0 | 1024 | } finally { |
aoqi@0 | 1025 | if (transportDebug()) dprint(".REPLY 1.1<-: " + header); |
aoqi@0 | 1026 | } |
aoqi@0 | 1027 | } |
aoqi@0 | 1028 | |
aoqi@0 | 1029 | public void handleInput(ReplyMessage_1_2 header) throws IOException |
aoqi@0 | 1030 | { |
aoqi@0 | 1031 | try { |
aoqi@0 | 1032 | try { |
aoqi@0 | 1033 | messageHeader = replyHeader = (ReplyMessage) header; |
aoqi@0 | 1034 | |
aoqi@0 | 1035 | // We know that the request ID is in the first fragment |
aoqi@0 | 1036 | header.unmarshalRequestID(dispatchByteBuffer); |
aoqi@0 | 1037 | |
aoqi@0 | 1038 | if (transportDebug()) { |
aoqi@0 | 1039 | dprint(".REPLY 1.2->: id/" |
aoqi@0 | 1040 | + + header.getRequestId() |
aoqi@0 | 1041 | + ": more?: " + header.moreFragmentsToFollow() |
aoqi@0 | 1042 | + ": " + header); |
aoqi@0 | 1043 | } |
aoqi@0 | 1044 | |
aoqi@0 | 1045 | setInputObject(); |
aoqi@0 | 1046 | |
aoqi@0 | 1047 | signalResponseReceived(); |
aoqi@0 | 1048 | } finally { |
aoqi@0 | 1049 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1050 | } |
aoqi@0 | 1051 | } catch (Throwable t) { |
aoqi@0 | 1052 | if (transportDebug()) dprint(".REPLY 1.2: id/" |
aoqi@0 | 1053 | + header.getRequestId() |
aoqi@0 | 1054 | + ": !!ERROR!!: " |
aoqi@0 | 1055 | + header, t); |
aoqi@0 | 1056 | // Mask the exception from thread.; |
aoqi@0 | 1057 | } finally { |
aoqi@0 | 1058 | if (transportDebug()) dprint(".REPLY 1.2<-: id/" |
aoqi@0 | 1059 | + header.getRequestId() |
aoqi@0 | 1060 | + ": " |
aoqi@0 | 1061 | + header); |
aoqi@0 | 1062 | } |
aoqi@0 | 1063 | } |
aoqi@0 | 1064 | |
aoqi@0 | 1065 | public void handleInput(LocateRequestMessage_1_0 header) throws IOException |
aoqi@0 | 1066 | { |
aoqi@0 | 1067 | try { |
aoqi@0 | 1068 | if (transportDebug()) |
aoqi@0 | 1069 | dprint(".LOCATE_REQUEST 1.0->: " + header); |
aoqi@0 | 1070 | try { |
aoqi@0 | 1071 | messageHeader = header; |
aoqi@0 | 1072 | setInputObject(); |
aoqi@0 | 1073 | } finally { |
aoqi@0 | 1074 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 1075 | } |
aoqi@0 | 1076 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 1077 | } catch (Throwable t) { |
aoqi@0 | 1078 | if (transportDebug()) |
aoqi@0 | 1079 | dprint(".LOCATE_REQUEST 1.0: !!ERROR!!: " + header, t); |
aoqi@0 | 1080 | // Mask the exception from thread.; |
aoqi@0 | 1081 | } finally { |
aoqi@0 | 1082 | if (transportDebug()) |
aoqi@0 | 1083 | dprint(".LOCATE_REQUEST 1.0<-: " + header); |
aoqi@0 | 1084 | } |
aoqi@0 | 1085 | |
aoqi@0 | 1086 | } |
aoqi@0 | 1087 | |
aoqi@0 | 1088 | public void handleInput(LocateRequestMessage_1_1 header) throws IOException |
aoqi@0 | 1089 | { |
aoqi@0 | 1090 | try { |
aoqi@0 | 1091 | if (transportDebug()) |
aoqi@0 | 1092 | dprint(".LOCATE_REQUEST 1.1->: " + header); |
aoqi@0 | 1093 | try { |
aoqi@0 | 1094 | messageHeader = header; |
aoqi@0 | 1095 | setInputObject(); |
aoqi@0 | 1096 | } finally { |
aoqi@0 | 1097 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 1098 | } |
aoqi@0 | 1099 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 1100 | } catch (Throwable t) { |
aoqi@0 | 1101 | if (transportDebug()) |
aoqi@0 | 1102 | dprint(".LOCATE_REQUEST 1.1: !!ERROR!!: " + header, t); |
aoqi@0 | 1103 | // Mask the exception from thread.; |
aoqi@0 | 1104 | } finally { |
aoqi@0 | 1105 | if (transportDebug()) |
aoqi@0 | 1106 | dprint(".LOCATE_REQUEST 1.1<-:" + header); |
aoqi@0 | 1107 | } |
aoqi@0 | 1108 | } |
aoqi@0 | 1109 | |
aoqi@0 | 1110 | public void handleInput(LocateRequestMessage_1_2 header) throws IOException |
aoqi@0 | 1111 | { |
aoqi@0 | 1112 | try { |
aoqi@0 | 1113 | try { |
aoqi@0 | 1114 | messageHeader = header; |
aoqi@0 | 1115 | |
aoqi@0 | 1116 | header.unmarshalRequestID(dispatchByteBuffer); |
aoqi@0 | 1117 | setInputObject(); |
aoqi@0 | 1118 | |
aoqi@0 | 1119 | if (transportDebug()) |
aoqi@0 | 1120 | dprint(".LOCATE_REQUEST 1.2->: id/" |
aoqi@0 | 1121 | + header.getRequestId() |
aoqi@0 | 1122 | + ": " |
aoqi@0 | 1123 | + header); |
aoqi@0 | 1124 | |
aoqi@0 | 1125 | if (header.moreFragmentsToFollow()) { |
aoqi@0 | 1126 | connection.serverRequestMapPut(header.getRequestId(),this); |
aoqi@0 | 1127 | } |
aoqi@0 | 1128 | } finally { |
aoqi@0 | 1129 | setWorkThenPoolOrResumeSelect(header); |
aoqi@0 | 1130 | } |
aoqi@0 | 1131 | getProtocolHandler().handleRequest(header, this); |
aoqi@0 | 1132 | } catch (Throwable t) { |
aoqi@0 | 1133 | if (transportDebug()) |
aoqi@0 | 1134 | dprint(".LOCATE_REQUEST 1.2: id/" |
aoqi@0 | 1135 | + header.getRequestId() |
aoqi@0 | 1136 | + ": !!ERROR!!: " |
aoqi@0 | 1137 | + header, t); |
aoqi@0 | 1138 | // Mask the exception from thread.; |
aoqi@0 | 1139 | } finally { |
aoqi@0 | 1140 | if (transportDebug()) |
aoqi@0 | 1141 | dprint(".LOCATE_REQUEST 1.2<-: id/" |
aoqi@0 | 1142 | + header.getRequestId() |
aoqi@0 | 1143 | + ": " |
aoqi@0 | 1144 | + header); |
aoqi@0 | 1145 | } |
aoqi@0 | 1146 | } |
aoqi@0 | 1147 | |
aoqi@0 | 1148 | public void handleInput(LocateReplyMessage_1_0 header) throws IOException |
aoqi@0 | 1149 | { |
aoqi@0 | 1150 | try { |
aoqi@0 | 1151 | if (transportDebug()) |
aoqi@0 | 1152 | dprint(".LOCATE_REPLY 1.0->:" + header); |
aoqi@0 | 1153 | try { |
aoqi@0 | 1154 | messageHeader = header; |
aoqi@0 | 1155 | setInputObject(); |
aoqi@0 | 1156 | inputObject.unmarshalHeader(); // REVISIT Put in subcontract. |
aoqi@0 | 1157 | signalResponseReceived(); |
aoqi@0 | 1158 | } finally { |
aoqi@0 | 1159 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1160 | } |
aoqi@0 | 1161 | } catch (Throwable t) { |
aoqi@0 | 1162 | if (transportDebug()) |
aoqi@0 | 1163 | dprint(".LOCATE_REPLY 1.0: !!ERROR!!: " + header, t); |
aoqi@0 | 1164 | // Mask the exception from thread.; |
aoqi@0 | 1165 | } finally { |
aoqi@0 | 1166 | if (transportDebug()) |
aoqi@0 | 1167 | dprint(".LOCATE_REPLY 1.0<-: " + header); |
aoqi@0 | 1168 | } |
aoqi@0 | 1169 | } |
aoqi@0 | 1170 | |
aoqi@0 | 1171 | public void handleInput(LocateReplyMessage_1_1 header) throws IOException |
aoqi@0 | 1172 | { |
aoqi@0 | 1173 | try { |
aoqi@0 | 1174 | if (transportDebug()) dprint(".LOCATE_REPLY 1.1->: " + header); |
aoqi@0 | 1175 | try { |
aoqi@0 | 1176 | messageHeader = header; |
aoqi@0 | 1177 | setInputObject(); |
aoqi@0 | 1178 | // Fragmented LocateReplies are not allowed in 1.1. |
aoqi@0 | 1179 | inputObject.unmarshalHeader(); |
aoqi@0 | 1180 | signalResponseReceived(); |
aoqi@0 | 1181 | } finally { |
aoqi@0 | 1182 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1183 | } |
aoqi@0 | 1184 | } catch (Throwable t) { |
aoqi@0 | 1185 | if (transportDebug()) |
aoqi@0 | 1186 | dprint(".LOCATE_REPLY 1.1: !!ERROR!!: " + header, t); |
aoqi@0 | 1187 | // Mask the exception from thread.; |
aoqi@0 | 1188 | } finally { |
aoqi@0 | 1189 | if (transportDebug()) dprint(".LOCATE_REPLY 1.1<-: " + header); |
aoqi@0 | 1190 | } |
aoqi@0 | 1191 | } |
aoqi@0 | 1192 | |
aoqi@0 | 1193 | public void handleInput(LocateReplyMessage_1_2 header) throws IOException |
aoqi@0 | 1194 | { |
aoqi@0 | 1195 | try { |
aoqi@0 | 1196 | try { |
aoqi@0 | 1197 | messageHeader = header; |
aoqi@0 | 1198 | |
aoqi@0 | 1199 | // No need to put in client reply map - already there. |
aoqi@0 | 1200 | header.unmarshalRequestID(dispatchByteBuffer); |
aoqi@0 | 1201 | |
aoqi@0 | 1202 | setInputObject(); |
aoqi@0 | 1203 | |
aoqi@0 | 1204 | if (transportDebug()) dprint(".LOCATE_REPLY 1.2->: id/" |
aoqi@0 | 1205 | + header.getRequestId() |
aoqi@0 | 1206 | + ": " |
aoqi@0 | 1207 | + header); |
aoqi@0 | 1208 | |
aoqi@0 | 1209 | signalResponseReceived(); |
aoqi@0 | 1210 | } finally { |
aoqi@0 | 1211 | setWorkThenPoolOrResumeSelect(header); // REVISIT |
aoqi@0 | 1212 | } |
aoqi@0 | 1213 | } catch (Throwable t) { |
aoqi@0 | 1214 | if (transportDebug()) |
aoqi@0 | 1215 | dprint(".LOCATE_REPLY 1.2: id/" |
aoqi@0 | 1216 | + header.getRequestId() |
aoqi@0 | 1217 | + ": !!ERROR!!: " |
aoqi@0 | 1218 | + header, t); |
aoqi@0 | 1219 | // Mask the exception from thread.; |
aoqi@0 | 1220 | } finally { |
aoqi@0 | 1221 | if (transportDebug()) dprint(".LOCATE_REPLY 1.2<-: id/" |
aoqi@0 | 1222 | + header.getRequestId() |
aoqi@0 | 1223 | + ": " |
aoqi@0 | 1224 | + header); |
aoqi@0 | 1225 | } |
aoqi@0 | 1226 | } |
aoqi@0 | 1227 | |
aoqi@0 | 1228 | public void handleInput(FragmentMessage_1_1 header) throws IOException |
aoqi@0 | 1229 | { |
aoqi@0 | 1230 | try { |
aoqi@0 | 1231 | if (transportDebug()) { |
aoqi@0 | 1232 | dprint(".FRAGMENT 1.1->: " |
aoqi@0 | 1233 | + "more?: " + header.moreFragmentsToFollow() |
aoqi@0 | 1234 | + ": " + header); |
aoqi@0 | 1235 | } |
aoqi@0 | 1236 | try { |
aoqi@0 | 1237 | messageHeader = header; |
aoqi@0 | 1238 | MessageMediator mediator = null; |
aoqi@0 | 1239 | CDRInputObject inputObject = null; |
aoqi@0 | 1240 | |
aoqi@0 | 1241 | if (connection.isServer()) { |
aoqi@0 | 1242 | mediator = connection.serverRequest_1_1_Get(); |
aoqi@0 | 1243 | } else { |
aoqi@0 | 1244 | mediator = connection.clientReply_1_1_Get(); |
aoqi@0 | 1245 | } |
aoqi@0 | 1246 | if (mediator != null) { |
aoqi@0 | 1247 | inputObject = (CDRInputObject) mediator.getInputObject(); |
aoqi@0 | 1248 | } |
aoqi@0 | 1249 | |
aoqi@0 | 1250 | // If no input stream available, then discard the fragment. |
aoqi@0 | 1251 | // This can happen: |
aoqi@0 | 1252 | // 1. if a fragment message is received prior to receiving |
aoqi@0 | 1253 | // the original request/reply message. Very unlikely. |
aoqi@0 | 1254 | // 2. if a fragment message is received after the |
aoqi@0 | 1255 | // reply has been sent (early replies) |
aoqi@0 | 1256 | // Note: In the case of early replies, the fragments received |
aoqi@0 | 1257 | // during the request processing (which are never unmarshaled), |
aoqi@0 | 1258 | // will eventually be discarded by the GC. |
aoqi@0 | 1259 | if (inputObject == null) { |
aoqi@0 | 1260 | if (transportDebug()) |
aoqi@0 | 1261 | dprint(".FRAGMENT 1.1: ++++DISCARDING++++: " + header); |
aoqi@0 | 1262 | // need to release dispatchByteBuffer to pool if |
aoqi@0 | 1263 | // we are discarding |
aoqi@0 | 1264 | releaseByteBufferToPool(); |
aoqi@0 | 1265 | return; |
aoqi@0 | 1266 | } |
aoqi@0 | 1267 | |
aoqi@0 | 1268 | inputObject.getBufferManager() |
aoqi@0 | 1269 | .processFragment(dispatchByteBuffer, header); |
aoqi@0 | 1270 | |
aoqi@0 | 1271 | if (! header.moreFragmentsToFollow()) { |
aoqi@0 | 1272 | if (connection.isServer()) { |
aoqi@0 | 1273 | connection.serverRequest_1_1_Remove(); |
aoqi@0 | 1274 | } else { |
aoqi@0 | 1275 | connection.clientReply_1_1_Remove(); |
aoqi@0 | 1276 | } |
aoqi@0 | 1277 | } |
aoqi@0 | 1278 | } finally { |
aoqi@0 | 1279 | // NOTE: This *must* come after queing the fragment |
aoqi@0 | 1280 | // when using the selector to ensure fragments stay in order. |
aoqi@0 | 1281 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1282 | } |
aoqi@0 | 1283 | } catch (Throwable t) { |
aoqi@0 | 1284 | if (transportDebug()) |
aoqi@0 | 1285 | dprint(".FRAGMENT 1.1: !!ERROR!!: " + header, t); |
aoqi@0 | 1286 | // Mask the exception from thread.; |
aoqi@0 | 1287 | } finally { |
aoqi@0 | 1288 | if (transportDebug()) dprint(".FRAGMENT 1.1<-: " + header); |
aoqi@0 | 1289 | } |
aoqi@0 | 1290 | } |
aoqi@0 | 1291 | |
aoqi@0 | 1292 | public void handleInput(FragmentMessage_1_2 header) throws IOException |
aoqi@0 | 1293 | { |
aoqi@0 | 1294 | try { |
aoqi@0 | 1295 | try { |
aoqi@0 | 1296 | messageHeader = header; |
aoqi@0 | 1297 | |
aoqi@0 | 1298 | // Note: We know it's a 1.2 fragment, we have the data, but |
aoqi@0 | 1299 | // we need the IIOPInputStream instance to unmarshal the |
aoqi@0 | 1300 | // request ID... but we need the request ID to get the |
aoqi@0 | 1301 | // IIOPInputStream instance. So we peek at the raw bytes. |
aoqi@0 | 1302 | |
aoqi@0 | 1303 | header.unmarshalRequestID(dispatchByteBuffer); |
aoqi@0 | 1304 | |
aoqi@0 | 1305 | if (transportDebug()) { |
aoqi@0 | 1306 | dprint(".FRAGMENT 1.2->: id/" |
aoqi@0 | 1307 | + header.getRequestId() |
aoqi@0 | 1308 | + ": more?: " + header.moreFragmentsToFollow() |
aoqi@0 | 1309 | + ": " + header); |
aoqi@0 | 1310 | } |
aoqi@0 | 1311 | |
aoqi@0 | 1312 | MessageMediator mediator = null; |
aoqi@0 | 1313 | InputObject inputObject = null; |
aoqi@0 | 1314 | |
aoqi@0 | 1315 | if (connection.isServer()) { |
aoqi@0 | 1316 | mediator = |
aoqi@0 | 1317 | connection.serverRequestMapGet(header.getRequestId()); |
aoqi@0 | 1318 | } else { |
aoqi@0 | 1319 | mediator = |
aoqi@0 | 1320 | connection.clientRequestMapGet(header.getRequestId()); |
aoqi@0 | 1321 | } |
aoqi@0 | 1322 | if (mediator != null) { |
aoqi@0 | 1323 | inputObject = mediator.getInputObject(); |
aoqi@0 | 1324 | } |
aoqi@0 | 1325 | // See 1.1 comments. |
aoqi@0 | 1326 | if (inputObject == null) { |
aoqi@0 | 1327 | if (transportDebug()) { |
aoqi@0 | 1328 | dprint(".FRAGMENT 1.2: id/" |
aoqi@0 | 1329 | + header.getRequestId() |
aoqi@0 | 1330 | + ": ++++DISCARDING++++: " |
aoqi@0 | 1331 | + header); |
aoqi@0 | 1332 | } |
aoqi@0 | 1333 | // need to release dispatchByteBuffer to pool if |
aoqi@0 | 1334 | // we are discarding |
aoqi@0 | 1335 | releaseByteBufferToPool(); |
aoqi@0 | 1336 | return; |
aoqi@0 | 1337 | } |
aoqi@0 | 1338 | ((CDRInputObject)inputObject) |
aoqi@0 | 1339 | .getBufferManager().processFragment( |
aoqi@0 | 1340 | dispatchByteBuffer, header); |
aoqi@0 | 1341 | |
aoqi@0 | 1342 | // REVISIT: but if it is a server don't you have to remove the |
aoqi@0 | 1343 | // stream from the map? |
aoqi@0 | 1344 | if (! connection.isServer()) { |
aoqi@0 | 1345 | /* REVISIT |
aoqi@0 | 1346 | * No need to do anything. |
aoqi@0 | 1347 | * Should we mark that last was received? |
aoqi@0 | 1348 | if (! header.moreFragmentsToFollow()) { |
aoqi@0 | 1349 | // Last fragment. |
aoqi@0 | 1350 | } |
aoqi@0 | 1351 | */ |
aoqi@0 | 1352 | } |
aoqi@0 | 1353 | } finally { |
aoqi@0 | 1354 | // NOTE: This *must* come after queing the fragment |
aoqi@0 | 1355 | // when using the selector to ensure fragments stay in order. |
aoqi@0 | 1356 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1357 | } |
aoqi@0 | 1358 | } catch (Throwable t) { |
aoqi@0 | 1359 | if (transportDebug()) |
aoqi@0 | 1360 | dprint(".FRAGMENT 1.2: id/" |
aoqi@0 | 1361 | + header.getRequestId() |
aoqi@0 | 1362 | + ": !!ERROR!!: " |
aoqi@0 | 1363 | + header, t); |
aoqi@0 | 1364 | // Mask the exception from thread.; |
aoqi@0 | 1365 | } finally { |
aoqi@0 | 1366 | if (transportDebug()) dprint(".FRAGMENT 1.2<-: id/" |
aoqi@0 | 1367 | + header.getRequestId() |
aoqi@0 | 1368 | + ": " |
aoqi@0 | 1369 | + header); |
aoqi@0 | 1370 | } |
aoqi@0 | 1371 | } |
aoqi@0 | 1372 | |
aoqi@0 | 1373 | public void handleInput(CancelRequestMessage header) throws IOException |
aoqi@0 | 1374 | { |
aoqi@0 | 1375 | try { |
aoqi@0 | 1376 | try { |
aoqi@0 | 1377 | messageHeader = header; |
aoqi@0 | 1378 | setInputObject(); |
aoqi@0 | 1379 | |
aoqi@0 | 1380 | // REVISIT: Move these two to subcontract. |
aoqi@0 | 1381 | inputObject.unmarshalHeader(); |
aoqi@0 | 1382 | |
aoqi@0 | 1383 | if (transportDebug()) dprint(".CANCEL->: id/" |
aoqi@0 | 1384 | + header.getRequestId() + ": " |
aoqi@0 | 1385 | + header.getGIOPVersion() + ": " |
aoqi@0 | 1386 | + header); |
aoqi@0 | 1387 | |
aoqi@0 | 1388 | processCancelRequest(header.getRequestId()); |
aoqi@0 | 1389 | releaseByteBufferToPool(); |
aoqi@0 | 1390 | } finally { |
aoqi@0 | 1391 | setWorkThenReadOrResumeSelect(header); |
aoqi@0 | 1392 | } |
aoqi@0 | 1393 | } catch (Throwable t) { |
aoqi@0 | 1394 | if (transportDebug()) dprint(".CANCEL: id/" |
aoqi@0 | 1395 | + header.getRequestId() |
aoqi@0 | 1396 | + ": !!ERROR!!: " |
aoqi@0 | 1397 | + header, t); |
aoqi@0 | 1398 | // Mask the exception from thread.; |
aoqi@0 | 1399 | } finally { |
aoqi@0 | 1400 | if (transportDebug()) dprint(".CANCEL<-: id/" |
aoqi@0 | 1401 | + header.getRequestId() + ": " |
aoqi@0 | 1402 | + header.getGIOPVersion() + ": " |
aoqi@0 | 1403 | + header); |
aoqi@0 | 1404 | } |
aoqi@0 | 1405 | } |
aoqi@0 | 1406 | |
aoqi@0 | 1407 | private void throwNotImplemented() |
aoqi@0 | 1408 | { |
aoqi@0 | 1409 | isThreadDone = false; |
aoqi@0 | 1410 | throwNotImplemented(""); |
aoqi@0 | 1411 | } |
aoqi@0 | 1412 | |
aoqi@0 | 1413 | private void throwNotImplemented(String msg) |
aoqi@0 | 1414 | { |
aoqi@0 | 1415 | throw new RuntimeException("CorbaMessageMediatorImpl: not implemented " + msg); |
aoqi@0 | 1416 | } |
aoqi@0 | 1417 | |
aoqi@0 | 1418 | private void dprint(String msg, Throwable t) |
aoqi@0 | 1419 | { |
aoqi@0 | 1420 | dprint(msg); |
aoqi@0 | 1421 | t.printStackTrace(System.out); |
aoqi@0 | 1422 | } |
aoqi@0 | 1423 | |
aoqi@0 | 1424 | private void dprint(String msg) |
aoqi@0 | 1425 | { |
aoqi@0 | 1426 | ORBUtility.dprint("CorbaMessageMediatorImpl", msg); |
aoqi@0 | 1427 | } |
aoqi@0 | 1428 | |
aoqi@0 | 1429 | protected String opAndId(CorbaMessageMediator mediator) |
aoqi@0 | 1430 | { |
aoqi@0 | 1431 | return ORBUtility.operationNameAndRequestId(mediator); |
aoqi@0 | 1432 | } |
aoqi@0 | 1433 | |
aoqi@0 | 1434 | private boolean transportDebug() |
aoqi@0 | 1435 | { |
aoqi@0 | 1436 | return orb.transportDebugFlag; |
aoqi@0 | 1437 | } |
aoqi@0 | 1438 | |
aoqi@0 | 1439 | // REVISIT: move this to subcontract (but both client and server need it). |
aoqi@0 | 1440 | private final void processCancelRequest(int cancelReqId) { |
aoqi@0 | 1441 | |
aoqi@0 | 1442 | // The GIOP version of CancelRequest does not matter, since |
aoqi@0 | 1443 | // CancelRequest_1_0 could be sent to cancel a request which |
aoqi@0 | 1444 | // has a different GIOP version. |
aoqi@0 | 1445 | |
aoqi@0 | 1446 | /* |
aoqi@0 | 1447 | * CancelRequest processing logic : |
aoqi@0 | 1448 | * |
aoqi@0 | 1449 | * - find the request with matching requestId |
aoqi@0 | 1450 | * |
aoqi@0 | 1451 | * - call cancelProcessing() in BufferManagerRead [BMR] |
aoqi@0 | 1452 | * |
aoqi@0 | 1453 | * - the hope is that worker thread would call BMR.underflow() |
aoqi@0 | 1454 | * to wait for more fragments to come in. When BMR.underflow() is |
aoqi@0 | 1455 | * called, if a CancelRequest had already arrived, |
aoqi@0 | 1456 | * the worker thread would throw ThreadDeath, |
aoqi@0 | 1457 | * else the thread would wait to be notified of the |
aoqi@0 | 1458 | * arrival of a new fragment or CancelRequest. Upon notification, |
aoqi@0 | 1459 | * the woken up thread would check to see if a CancelRequest had |
aoqi@0 | 1460 | * arrived and if so throw a ThreadDeath or it will continue to |
aoqi@0 | 1461 | * process the received fragment. |
aoqi@0 | 1462 | * |
aoqi@0 | 1463 | * - if all the fragments had been received prior to CancelRequest |
aoqi@0 | 1464 | * then the worker thread would never block in BMR.underflow(). |
aoqi@0 | 1465 | * So, setting the abort flag in BMR has no effect. The request |
aoqi@0 | 1466 | * processing will complete normally. |
aoqi@0 | 1467 | * |
aoqi@0 | 1468 | * - in the case where the server has received enough fragments to |
aoqi@0 | 1469 | * start processing the request and the server sends out |
aoqi@0 | 1470 | * an early reply. In such a case if the CancelRequest arrives |
aoqi@0 | 1471 | * after the reply has been sent, it has no effect. |
aoqi@0 | 1472 | */ |
aoqi@0 | 1473 | |
aoqi@0 | 1474 | if (!connection.isServer()) { |
aoqi@0 | 1475 | return; // we do not support bi-directional giop yet, ignore. |
aoqi@0 | 1476 | } |
aoqi@0 | 1477 | |
aoqi@0 | 1478 | // Try to get hold of the InputStream buffer. |
aoqi@0 | 1479 | // In the case of 1.0 requests there is no way to get hold of |
aoqi@0 | 1480 | // InputStream. Try out the 1.1 and 1.2 cases. |
aoqi@0 | 1481 | |
aoqi@0 | 1482 | // was the request 1.2 ? |
aoqi@0 | 1483 | MessageMediator mediator = connection.serverRequestMapGet(cancelReqId); |
aoqi@0 | 1484 | int requestId ; |
aoqi@0 | 1485 | if (mediator == null) { |
aoqi@0 | 1486 | // was the request 1.1 ? |
aoqi@0 | 1487 | mediator = connection.serverRequest_1_1_Get(); |
aoqi@0 | 1488 | if (mediator == null) { |
aoqi@0 | 1489 | // XXX log this! |
aoqi@0 | 1490 | // either the request was 1.0 |
aoqi@0 | 1491 | // or an early reply has already been sent |
aoqi@0 | 1492 | // or request processing is over |
aoqi@0 | 1493 | // or its a spurious CancelRequest |
aoqi@0 | 1494 | return; // do nothing. |
aoqi@0 | 1495 | } |
aoqi@0 | 1496 | |
aoqi@0 | 1497 | requestId = ((CorbaMessageMediator) mediator).getRequestId(); |
aoqi@0 | 1498 | |
aoqi@0 | 1499 | if (requestId != cancelReqId) { |
aoqi@0 | 1500 | // A spurious 1.1 CancelRequest has been received. |
aoqi@0 | 1501 | // XXX log this! |
aoqi@0 | 1502 | return; // do nothing |
aoqi@0 | 1503 | } |
aoqi@0 | 1504 | |
aoqi@0 | 1505 | if (requestId == 0) { // special case |
aoqi@0 | 1506 | // XXX log this |
aoqi@0 | 1507 | // this means that |
aoqi@0 | 1508 | // 1. the 1.1 requests' requestId has not been received |
aoqi@0 | 1509 | // i.e., a CancelRequest was received even before the |
aoqi@0 | 1510 | // 1.1 request was received. The spec disallows this. |
aoqi@0 | 1511 | // 2. or the 1.1 request has a requestId 0. |
aoqi@0 | 1512 | // |
aoqi@0 | 1513 | // It is a little tricky to distinguish these two. So, be |
aoqi@0 | 1514 | // conservative and do not cancel the request. Downside is that |
aoqi@0 | 1515 | // 1.1 requests with requestId of 0 will never be cancelled. |
aoqi@0 | 1516 | return; // do nothing |
aoqi@0 | 1517 | } |
aoqi@0 | 1518 | } else { |
aoqi@0 | 1519 | requestId = ((CorbaMessageMediator) mediator).getRequestId(); |
aoqi@0 | 1520 | } |
aoqi@0 | 1521 | |
aoqi@0 | 1522 | Message msg = ((CorbaMessageMediator)mediator).getRequestHeader(); |
aoqi@0 | 1523 | if (msg.getType() != Message.GIOPRequest) { |
aoqi@0 | 1524 | // Any mediator obtained here should only ever be for a GIOP |
aoqi@0 | 1525 | // request. |
aoqi@0 | 1526 | wrapper.badMessageTypeForCancel() ; |
aoqi@0 | 1527 | } |
aoqi@0 | 1528 | |
aoqi@0 | 1529 | // At this point we have a valid message mediator that contains |
aoqi@0 | 1530 | // a valid requestId. |
aoqi@0 | 1531 | |
aoqi@0 | 1532 | // at this point we have chosen a request to be cancelled. But we |
aoqi@0 | 1533 | // do not know if the target object's method has been invoked or not. |
aoqi@0 | 1534 | // Request input stream being available simply means that the request |
aoqi@0 | 1535 | // processing is not over yet. simply set the abort flag in the |
aoqi@0 | 1536 | // BMRS and hope that the worker thread would notice it (this can |
aoqi@0 | 1537 | // happen only if the request stream is being unmarshalled and the |
aoqi@0 | 1538 | // target's method has not been invoked yet). This guarantees |
aoqi@0 | 1539 | // that the requests which have been dispatched to the |
aoqi@0 | 1540 | // target's method will never be cancelled. |
aoqi@0 | 1541 | |
aoqi@0 | 1542 | BufferManagerReadStream bufferManager = (BufferManagerReadStream) |
aoqi@0 | 1543 | ((CDRInputObject)mediator.getInputObject()).getBufferManager(); |
aoqi@0 | 1544 | bufferManager.cancelProcessing(cancelReqId); |
aoqi@0 | 1545 | } |
aoqi@0 | 1546 | |
aoqi@0 | 1547 | //////////////////////////////////////////////////// |
aoqi@0 | 1548 | // |
aoqi@0 | 1549 | // spi.protocol.CorbaProtocolHandler |
aoqi@0 | 1550 | // |
aoqi@0 | 1551 | |
aoqi@0 | 1552 | public void handleRequest(RequestMessage msg, |
aoqi@0 | 1553 | CorbaMessageMediator messageMediator) |
aoqi@0 | 1554 | { |
aoqi@0 | 1555 | try { |
aoqi@0 | 1556 | beginRequest(messageMediator); |
aoqi@0 | 1557 | try { |
aoqi@0 | 1558 | handleRequestRequest(messageMediator); |
aoqi@0 | 1559 | if (messageMediator.isOneWay()) { |
aoqi@0 | 1560 | return; |
aoqi@0 | 1561 | } |
aoqi@0 | 1562 | } catch (Throwable t) { |
aoqi@0 | 1563 | if (messageMediator.isOneWay()) { |
aoqi@0 | 1564 | return; |
aoqi@0 | 1565 | } |
aoqi@0 | 1566 | handleThrowableDuringServerDispatch( |
aoqi@0 | 1567 | messageMediator, t, CompletionStatus.COMPLETED_MAYBE); |
aoqi@0 | 1568 | } |
aoqi@0 | 1569 | sendResponse(messageMediator); |
aoqi@0 | 1570 | } catch (Throwable t) { |
aoqi@0 | 1571 | dispatchError(messageMediator, "RequestMessage", t); |
aoqi@0 | 1572 | } finally { |
aoqi@0 | 1573 | endRequest(messageMediator); |
aoqi@0 | 1574 | } |
aoqi@0 | 1575 | } |
aoqi@0 | 1576 | |
aoqi@0 | 1577 | public void handleRequest(LocateRequestMessage msg, |
aoqi@0 | 1578 | CorbaMessageMediator messageMediator) |
aoqi@0 | 1579 | { |
aoqi@0 | 1580 | try { |
aoqi@0 | 1581 | beginRequest(messageMediator); |
aoqi@0 | 1582 | try { |
aoqi@0 | 1583 | handleLocateRequest(messageMediator); |
aoqi@0 | 1584 | } catch (Throwable t) { |
aoqi@0 | 1585 | handleThrowableDuringServerDispatch( |
aoqi@0 | 1586 | messageMediator, t, CompletionStatus.COMPLETED_MAYBE); |
aoqi@0 | 1587 | } |
aoqi@0 | 1588 | sendResponse(messageMediator); |
aoqi@0 | 1589 | } catch (Throwable t) { |
aoqi@0 | 1590 | dispatchError(messageMediator, "LocateRequestMessage", t); |
aoqi@0 | 1591 | } finally { |
aoqi@0 | 1592 | endRequest(messageMediator); |
aoqi@0 | 1593 | } |
aoqi@0 | 1594 | } |
aoqi@0 | 1595 | |
aoqi@0 | 1596 | private void beginRequest(CorbaMessageMediator messageMediator) |
aoqi@0 | 1597 | { |
aoqi@0 | 1598 | ORB orb = (ORB) messageMediator.getBroker(); |
aoqi@0 | 1599 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1600 | dprint(".handleRequest->:"); |
aoqi@0 | 1601 | } |
aoqi@0 | 1602 | connection.serverRequestProcessingBegins(); |
aoqi@0 | 1603 | } |
aoqi@0 | 1604 | |
aoqi@0 | 1605 | private void dispatchError(CorbaMessageMediator messageMediator, |
aoqi@0 | 1606 | String msg, Throwable t) |
aoqi@0 | 1607 | { |
aoqi@0 | 1608 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1609 | dprint(".handleRequest: " + opAndId(messageMediator) |
aoqi@0 | 1610 | + ": !!ERROR!!: " |
aoqi@0 | 1611 | + msg, |
aoqi@0 | 1612 | t); |
aoqi@0 | 1613 | } |
aoqi@0 | 1614 | // REVISIT - this makes hcks sendTwoObjects fail |
aoqi@0 | 1615 | // messageMediator.getConnection().close(); |
aoqi@0 | 1616 | } |
aoqi@0 | 1617 | |
aoqi@0 | 1618 | private void sendResponse(CorbaMessageMediator messageMediator) |
aoqi@0 | 1619 | { |
aoqi@0 | 1620 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1621 | dprint(".handleRequest: " + opAndId(messageMediator) |
aoqi@0 | 1622 | + ": sending response"); |
aoqi@0 | 1623 | } |
aoqi@0 | 1624 | // REVISIT - type and location |
aoqi@0 | 1625 | CDROutputObject outputObject = (CDROutputObject) |
aoqi@0 | 1626 | messageMediator.getOutputObject(); |
aoqi@0 | 1627 | if (outputObject != null) { |
aoqi@0 | 1628 | // REVISIT - can be null for TRANSIENT below. |
aoqi@0 | 1629 | outputObject.finishSendingMessage(); |
aoqi@0 | 1630 | } |
aoqi@0 | 1631 | } |
aoqi@0 | 1632 | |
aoqi@0 | 1633 | private void endRequest(CorbaMessageMediator messageMediator) |
aoqi@0 | 1634 | { |
aoqi@0 | 1635 | ORB orb = (ORB) messageMediator.getBroker(); |
aoqi@0 | 1636 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1637 | dprint(".handleRequest<-: " + opAndId(messageMediator)); |
aoqi@0 | 1638 | } |
aoqi@0 | 1639 | |
aoqi@0 | 1640 | // release NIO ByteBuffers to ByteBufferPool |
aoqi@0 | 1641 | |
aoqi@0 | 1642 | try { |
aoqi@0 | 1643 | OutputObject outputObj = messageMediator.getOutputObject(); |
aoqi@0 | 1644 | if (outputObj != null) { |
aoqi@0 | 1645 | outputObj.close(); |
aoqi@0 | 1646 | } |
aoqi@0 | 1647 | InputObject inputObj = messageMediator.getInputObject(); |
aoqi@0 | 1648 | if (inputObj != null) { |
aoqi@0 | 1649 | inputObj.close(); |
aoqi@0 | 1650 | } |
aoqi@0 | 1651 | } catch (IOException ex) { |
aoqi@0 | 1652 | // Given what close() does, this catch shouldn't ever happen. |
aoqi@0 | 1653 | // See CDRInput/OutputObject.close() for more info. |
aoqi@0 | 1654 | // It also won't result in a Corba error if an IOException happens. |
aoqi@0 | 1655 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1656 | dprint(".endRequest: IOException:" + ex.getMessage(), ex); |
aoqi@0 | 1657 | } |
aoqi@0 | 1658 | } finally { |
aoqi@0 | 1659 | ((CorbaConnection)messageMediator.getConnection()).serverRequestProcessingEnds(); |
aoqi@0 | 1660 | } |
aoqi@0 | 1661 | } |
aoqi@0 | 1662 | |
aoqi@0 | 1663 | protected void handleRequestRequest(CorbaMessageMediator messageMediator) |
aoqi@0 | 1664 | { |
aoqi@0 | 1665 | // Does nothing if already unmarshaled. |
aoqi@0 | 1666 | ((CDRInputObject)messageMediator.getInputObject()).unmarshalHeader(); |
aoqi@0 | 1667 | |
aoqi@0 | 1668 | ORB orb = (ORB)messageMediator.getBroker(); |
aoqi@0 | 1669 | synchronized (orb) { |
aoqi@0 | 1670 | orb.checkShutdownState(); |
aoqi@0 | 1671 | } |
aoqi@0 | 1672 | |
aoqi@0 | 1673 | ObjectKey okey = messageMediator.getObjectKey(); |
aoqi@0 | 1674 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1675 | ObjectKeyTemplate oktemp = okey.getTemplate() ; |
aoqi@0 | 1676 | dprint( ".handleRequest: " + opAndId(messageMediator) |
aoqi@0 | 1677 | + ": dispatching to scid: " + oktemp.getSubcontractId()); |
aoqi@0 | 1678 | } |
aoqi@0 | 1679 | |
aoqi@0 | 1680 | CorbaServerRequestDispatcher sc = okey.getServerRequestDispatcher(orb); |
aoqi@0 | 1681 | |
aoqi@0 | 1682 | if (orb.subcontractDebugFlag) { |
aoqi@0 | 1683 | dprint(".handleRequest: " + opAndId(messageMediator) |
aoqi@0 | 1684 | + ": dispatching to sc: " + sc); |
aoqi@0 | 1685 | } |
aoqi@0 | 1686 | |
aoqi@0 | 1687 | if (sc == null) { |
aoqi@0 | 1688 | throw wrapper.noServerScInDispatch() ; |
aoqi@0 | 1689 | } |
aoqi@0 | 1690 | |
aoqi@0 | 1691 | // NOTE: |
aoqi@0 | 1692 | // This is necessary so mediator can act as ResponseHandler |
aoqi@0 | 1693 | // and pass necessary info to response constructors located |
aoqi@0 | 1694 | // in the subcontract. |
aoqi@0 | 1695 | // REVISIT - same class right now. |
aoqi@0 | 1696 | //messageMediator.setProtocolHandler(this); |
aoqi@0 | 1697 | |
aoqi@0 | 1698 | try { |
aoqi@0 | 1699 | orb.startingDispatch(); |
aoqi@0 | 1700 | sc.dispatch(messageMediator); |
aoqi@0 | 1701 | } finally { |
aoqi@0 | 1702 | orb.finishedDispatch(); |
aoqi@0 | 1703 | } |
aoqi@0 | 1704 | } |
aoqi@0 | 1705 | |
aoqi@0 | 1706 | protected void handleLocateRequest(CorbaMessageMediator messageMediator) |
aoqi@0 | 1707 | { |
aoqi@0 | 1708 | ORB orb = (ORB)messageMediator.getBroker(); |
aoqi@0 | 1709 | LocateRequestMessage msg = (LocateRequestMessage) |
aoqi@0 | 1710 | messageMediator.getDispatchHeader(); |
aoqi@0 | 1711 | IOR ior = null; |
aoqi@0 | 1712 | LocateReplyMessage reply = null; |
aoqi@0 | 1713 | short addrDisp = -1; |
aoqi@0 | 1714 | |
aoqi@0 | 1715 | try { |
aoqi@0 | 1716 | ((CDRInputObject)messageMediator.getInputObject()).unmarshalHeader(); |
aoqi@0 | 1717 | CorbaServerRequestDispatcher sc = |
aoqi@0 | 1718 | msg.getObjectKey().getServerRequestDispatcher( orb ) ; |
aoqi@0 | 1719 | if (sc == null) { |
aoqi@0 | 1720 | return; |
aoqi@0 | 1721 | } |
aoqi@0 | 1722 | |
aoqi@0 | 1723 | ior = sc.locate(msg.getObjectKey()); |
aoqi@0 | 1724 | |
aoqi@0 | 1725 | if ( ior == null ) { |
aoqi@0 | 1726 | reply = MessageBase.createLocateReply( |
aoqi@0 | 1727 | orb, msg.getGIOPVersion(), |
aoqi@0 | 1728 | msg.getEncodingVersion(), |
aoqi@0 | 1729 | msg.getRequestId(), |
aoqi@0 | 1730 | LocateReplyMessage.OBJECT_HERE, null); |
aoqi@0 | 1731 | |
aoqi@0 | 1732 | } else { |
aoqi@0 | 1733 | reply = MessageBase.createLocateReply( |
aoqi@0 | 1734 | orb, msg.getGIOPVersion(), |
aoqi@0 | 1735 | msg.getEncodingVersion(), |
aoqi@0 | 1736 | msg.getRequestId(), |
aoqi@0 | 1737 | LocateReplyMessage.OBJECT_FORWARD, ior); |
aoqi@0 | 1738 | } |
aoqi@0 | 1739 | // REVISIT: Should we catch SystemExceptions? |
aoqi@0 | 1740 | |
aoqi@0 | 1741 | } catch (AddressingDispositionException ex) { |
aoqi@0 | 1742 | |
aoqi@0 | 1743 | // create a response containing the expected target |
aoqi@0 | 1744 | // addressing disposition. |
aoqi@0 | 1745 | |
aoqi@0 | 1746 | reply = MessageBase.createLocateReply( |
aoqi@0 | 1747 | orb, msg.getGIOPVersion(), |
aoqi@0 | 1748 | msg.getEncodingVersion(), |
aoqi@0 | 1749 | msg.getRequestId(), |
aoqi@0 | 1750 | LocateReplyMessage.LOC_NEEDS_ADDRESSING_MODE, null); |
aoqi@0 | 1751 | |
aoqi@0 | 1752 | addrDisp = ex.expectedAddrDisp(); |
aoqi@0 | 1753 | |
aoqi@0 | 1754 | } catch (RequestCanceledException ex) { |
aoqi@0 | 1755 | |
aoqi@0 | 1756 | return; // no need to send reply |
aoqi@0 | 1757 | |
aoqi@0 | 1758 | } catch ( Exception ex ) { |
aoqi@0 | 1759 | |
aoqi@0 | 1760 | // REVISIT If exception is not OBJECT_NOT_EXIST, it should |
aoqi@0 | 1761 | // have a different reply |
aoqi@0 | 1762 | |
aoqi@0 | 1763 | // This handles OBJECT_NOT_EXIST exceptions thrown in |
aoqi@0 | 1764 | // the subcontract or obj manager. Send back UNKNOWN_OBJECT. |
aoqi@0 | 1765 | |
aoqi@0 | 1766 | reply = MessageBase.createLocateReply( |
aoqi@0 | 1767 | orb, msg.getGIOPVersion(), |
aoqi@0 | 1768 | msg.getEncodingVersion(), |
aoqi@0 | 1769 | msg.getRequestId(), |
aoqi@0 | 1770 | LocateReplyMessage.UNKNOWN_OBJECT, null); |
aoqi@0 | 1771 | } |
aoqi@0 | 1772 | |
aoqi@0 | 1773 | CDROutputObject outputObject = |
aoqi@0 | 1774 | createAppropriateOutputObject(messageMediator, |
aoqi@0 | 1775 | msg, reply); |
aoqi@0 | 1776 | messageMediator.setOutputObject(outputObject); |
aoqi@0 | 1777 | outputObject.setMessageMediator(messageMediator); |
aoqi@0 | 1778 | |
aoqi@0 | 1779 | reply.write(outputObject); |
aoqi@0 | 1780 | // outputObject.setMessage(reply); // REVISIT - not necessary |
aoqi@0 | 1781 | if (ior != null) { |
aoqi@0 | 1782 | ior.write(outputObject); |
aoqi@0 | 1783 | } |
aoqi@0 | 1784 | if (addrDisp != -1) { |
aoqi@0 | 1785 | AddressingDispositionHelper.write(outputObject, addrDisp); |
aoqi@0 | 1786 | } |
aoqi@0 | 1787 | } |
aoqi@0 | 1788 | |
aoqi@0 | 1789 | private CDROutputObject createAppropriateOutputObject( |
aoqi@0 | 1790 | CorbaMessageMediator messageMediator, |
aoqi@0 | 1791 | Message msg, LocateReplyMessage reply) |
aoqi@0 | 1792 | { |
aoqi@0 | 1793 | CDROutputObject outputObject; |
aoqi@0 | 1794 | |
aoqi@0 | 1795 | if (msg.getGIOPVersion().lessThan(GIOPVersion.V1_2)) { |
aoqi@0 | 1796 | // locate msgs 1.0 & 1.1 :=> grow, |
aoqi@0 | 1797 | outputObject = sun.corba.OutputStreamFactory.newCDROutputObject( |
aoqi@0 | 1798 | (ORB) messageMediator.getBroker(), |
aoqi@0 | 1799 | this, |
aoqi@0 | 1800 | GIOPVersion.V1_0, |
aoqi@0 | 1801 | (CorbaConnection) messageMediator.getConnection(), |
aoqi@0 | 1802 | reply, |
aoqi@0 | 1803 | ORBConstants.STREAM_FORMAT_VERSION_1); |
aoqi@0 | 1804 | } else { |
aoqi@0 | 1805 | // 1.2 :=> stream |
aoqi@0 | 1806 | outputObject = sun.corba.OutputStreamFactory.newCDROutputObject( |
aoqi@0 | 1807 | (ORB) messageMediator.getBroker(), |
aoqi@0 | 1808 | messageMediator, |
aoqi@0 | 1809 | reply, |
aoqi@0 | 1810 | ORBConstants.STREAM_FORMAT_VERSION_1); |
aoqi@0 | 1811 | } |
aoqi@0 | 1812 | return outputObject; |
aoqi@0 | 1813 | } |
aoqi@0 | 1814 | |
aoqi@0 | 1815 | public void handleThrowableDuringServerDispatch( |
aoqi@0 | 1816 | CorbaMessageMediator messageMediator, |
aoqi@0 | 1817 | Throwable throwable, |
aoqi@0 | 1818 | CompletionStatus completionStatus) |
aoqi@0 | 1819 | { |
aoqi@0 | 1820 | if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) { |
aoqi@0 | 1821 | dprint(".handleThrowableDuringServerDispatch: " |
aoqi@0 | 1822 | + opAndId(messageMediator) + ": " |
aoqi@0 | 1823 | + throwable); |
aoqi@0 | 1824 | } |
aoqi@0 | 1825 | |
aoqi@0 | 1826 | // If we haven't unmarshaled the header, we probably don't |
aoqi@0 | 1827 | // have enough information to even send back a reply. |
aoqi@0 | 1828 | |
aoqi@0 | 1829 | // REVISIT |
aoqi@0 | 1830 | // Cannot do this check. When target addressing disposition does |
aoqi@0 | 1831 | // not match (during header unmarshaling) it throws an exception |
aoqi@0 | 1832 | // to be handled here. |
aoqi@0 | 1833 | /* |
aoqi@0 | 1834 | if (! ((CDRInputObject)messageMediator.getInputObject()) |
aoqi@0 | 1835 | .unmarshaledHeader()) { |
aoqi@0 | 1836 | return; |
aoqi@0 | 1837 | } |
aoqi@0 | 1838 | */ |
aoqi@0 | 1839 | handleThrowableDuringServerDispatch(messageMediator, |
aoqi@0 | 1840 | throwable, |
aoqi@0 | 1841 | completionStatus, |
aoqi@0 | 1842 | 1); |
aoqi@0 | 1843 | } |
aoqi@0 | 1844 | |
aoqi@0 | 1845 | |
aoqi@0 | 1846 | // REVISIT - catch and ignore RequestCanceledException. |
aoqi@0 | 1847 | |
aoqi@0 | 1848 | protected void handleThrowableDuringServerDispatch( |
aoqi@0 | 1849 | CorbaMessageMediator messageMediator, |
aoqi@0 | 1850 | Throwable throwable, |
aoqi@0 | 1851 | CompletionStatus completionStatus, |
aoqi@0 | 1852 | int iteration) |
aoqi@0 | 1853 | { |
aoqi@0 | 1854 | if (iteration > 10) { |
aoqi@0 | 1855 | if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) { |
aoqi@0 | 1856 | dprint(".handleThrowableDuringServerDispatch: " |
aoqi@0 | 1857 | + opAndId(messageMediator) |
aoqi@0 | 1858 | + ": cannot handle: " |
aoqi@0 | 1859 | + throwable); |
aoqi@0 | 1860 | } |
aoqi@0 | 1861 | |
aoqi@0 | 1862 | // REVISIT - should we close connection? |
aoqi@0 | 1863 | RuntimeException rte = |
aoqi@0 | 1864 | new RuntimeException("handleThrowableDuringServerDispatch: " + |
aoqi@0 | 1865 | "cannot create response."); |
aoqi@0 | 1866 | rte.initCause(throwable); |
aoqi@0 | 1867 | throw rte; |
aoqi@0 | 1868 | } |
aoqi@0 | 1869 | |
aoqi@0 | 1870 | try { |
aoqi@0 | 1871 | if (throwable instanceof ForwardException) { |
aoqi@0 | 1872 | ForwardException fex = (ForwardException)throwable ; |
aoqi@0 | 1873 | createLocationForward( messageMediator, fex.getIOR(), null ) ; |
aoqi@0 | 1874 | return; |
aoqi@0 | 1875 | } |
aoqi@0 | 1876 | |
aoqi@0 | 1877 | if (throwable instanceof AddressingDispositionException) { |
aoqi@0 | 1878 | handleAddressingDisposition( |
aoqi@0 | 1879 | messageMediator, |
aoqi@0 | 1880 | (AddressingDispositionException)throwable); |
aoqi@0 | 1881 | return; |
aoqi@0 | 1882 | } |
aoqi@0 | 1883 | |
aoqi@0 | 1884 | // Else. |
aoqi@0 | 1885 | |
aoqi@0 | 1886 | SystemException sex = |
aoqi@0 | 1887 | convertThrowableToSystemException(throwable, completionStatus); |
aoqi@0 | 1888 | |
aoqi@0 | 1889 | createSystemExceptionResponse(messageMediator, sex, null); |
aoqi@0 | 1890 | return; |
aoqi@0 | 1891 | |
aoqi@0 | 1892 | } catch (Throwable throwable2) { |
aoqi@0 | 1893 | |
aoqi@0 | 1894 | // User code (e.g., postinvoke, interceptors) may change |
aoqi@0 | 1895 | // the exception, so we end up back here. |
aoqi@0 | 1896 | // Report the changed exception. |
aoqi@0 | 1897 | |
aoqi@0 | 1898 | handleThrowableDuringServerDispatch(messageMediator, |
aoqi@0 | 1899 | throwable2, |
aoqi@0 | 1900 | completionStatus, |
aoqi@0 | 1901 | iteration + 1); |
aoqi@0 | 1902 | return; |
aoqi@0 | 1903 | } |
aoqi@0 | 1904 | } |
aoqi@0 | 1905 | |
aoqi@0 | 1906 | protected SystemException convertThrowableToSystemException( |
aoqi@0 | 1907 | Throwable throwable, |
aoqi@0 | 1908 | CompletionStatus completionStatus) |
aoqi@0 | 1909 | { |
aoqi@0 | 1910 | if (throwable instanceof SystemException) { |
aoqi@0 | 1911 | return (SystemException)throwable; |
aoqi@0 | 1912 | } |
aoqi@0 | 1913 | |
aoqi@0 | 1914 | if (throwable instanceof RequestCanceledException) { |
aoqi@0 | 1915 | // Reporting an exception response causes the |
aoqi@0 | 1916 | // poa current stack, the interceptor stacks, etc. |
aoqi@0 | 1917 | // to be balanced. It also notifies interceptors |
aoqi@0 | 1918 | // that the request was cancelled. |
aoqi@0 | 1919 | |
aoqi@0 | 1920 | return wrapper.requestCanceled( throwable ) ; |
aoqi@0 | 1921 | } |
aoqi@0 | 1922 | |
aoqi@0 | 1923 | // NOTE: We do not trap ThreadDeath above Throwable. |
aoqi@0 | 1924 | // There is no reason to stop the thread. It is |
aoqi@0 | 1925 | // just a worker thread. The ORB never throws |
aoqi@0 | 1926 | // ThreadDeath. Client code may (e.g., in ServantManagers, |
aoqi@0 | 1927 | // interceptors, or servants) but that should not |
aoqi@0 | 1928 | // effect the ORB threads. So it is just handled |
aoqi@0 | 1929 | // generically. |
aoqi@0 | 1930 | |
aoqi@0 | 1931 | // |
aoqi@0 | 1932 | // Last resort. |
aoqi@0 | 1933 | // If user code throws a non-SystemException report it generically. |
aoqi@0 | 1934 | // |
aoqi@0 | 1935 | |
aoqi@0 | 1936 | return wrapper.runtimeexception( CompletionStatus.COMPLETED_MAYBE, throwable ) ; |
aoqi@0 | 1937 | } |
aoqi@0 | 1938 | |
aoqi@0 | 1939 | protected void handleAddressingDisposition( |
aoqi@0 | 1940 | CorbaMessageMediator messageMediator, |
aoqi@0 | 1941 | AddressingDispositionException ex) |
aoqi@0 | 1942 | { |
aoqi@0 | 1943 | |
aoqi@0 | 1944 | short addrDisp = -1; |
aoqi@0 | 1945 | |
aoqi@0 | 1946 | // from iiop.RequestProcessor. |
aoqi@0 | 1947 | |
aoqi@0 | 1948 | // Respond with expected target addressing disposition. |
aoqi@0 | 1949 | |
aoqi@0 | 1950 | switch (messageMediator.getRequestHeader().getType()) { |
aoqi@0 | 1951 | case Message.GIOPRequest : |
aoqi@0 | 1952 | ReplyMessage replyHeader = MessageBase.createReply( |
aoqi@0 | 1953 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 1954 | messageMediator.getGIOPVersion(), |
aoqi@0 | 1955 | messageMediator.getEncodingVersion(), |
aoqi@0 | 1956 | messageMediator.getRequestId(), |
aoqi@0 | 1957 | ReplyMessage.NEEDS_ADDRESSING_MODE, |
aoqi@0 | 1958 | null, null); |
aoqi@0 | 1959 | // REVISIT: via acceptor factory. |
aoqi@0 | 1960 | CDROutputObject outputObject = |
aoqi@0 | 1961 | sun.corba.OutputStreamFactory.newCDROutputObject( |
aoqi@0 | 1962 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 1963 | this, |
aoqi@0 | 1964 | messageMediator.getGIOPVersion(), |
aoqi@0 | 1965 | (CorbaConnection)messageMediator.getConnection(), |
aoqi@0 | 1966 | replyHeader, |
aoqi@0 | 1967 | ORBConstants.STREAM_FORMAT_VERSION_1); |
aoqi@0 | 1968 | messageMediator.setOutputObject(outputObject); |
aoqi@0 | 1969 | outputObject.setMessageMediator(messageMediator); |
aoqi@0 | 1970 | replyHeader.write(outputObject); |
aoqi@0 | 1971 | AddressingDispositionHelper.write(outputObject, |
aoqi@0 | 1972 | ex.expectedAddrDisp()); |
aoqi@0 | 1973 | return; |
aoqi@0 | 1974 | |
aoqi@0 | 1975 | case Message.GIOPLocateRequest : |
aoqi@0 | 1976 | LocateReplyMessage locateReplyHeader = MessageBase.createLocateReply( |
aoqi@0 | 1977 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 1978 | messageMediator.getGIOPVersion(), |
aoqi@0 | 1979 | messageMediator.getEncodingVersion(), |
aoqi@0 | 1980 | messageMediator.getRequestId(), |
aoqi@0 | 1981 | LocateReplyMessage.LOC_NEEDS_ADDRESSING_MODE, |
aoqi@0 | 1982 | null); |
aoqi@0 | 1983 | |
aoqi@0 | 1984 | addrDisp = ex.expectedAddrDisp(); |
aoqi@0 | 1985 | |
aoqi@0 | 1986 | // REVISIT: via acceptor factory. |
aoqi@0 | 1987 | outputObject = |
aoqi@0 | 1988 | createAppropriateOutputObject(messageMediator, |
aoqi@0 | 1989 | messageMediator.getRequestHeader(), |
aoqi@0 | 1990 | locateReplyHeader); |
aoqi@0 | 1991 | messageMediator.setOutputObject(outputObject); |
aoqi@0 | 1992 | outputObject.setMessageMediator(messageMediator); |
aoqi@0 | 1993 | locateReplyHeader.write(outputObject); |
aoqi@0 | 1994 | IOR ior = null; |
aoqi@0 | 1995 | if (ior != null) { |
aoqi@0 | 1996 | ior.write(outputObject); |
aoqi@0 | 1997 | } |
aoqi@0 | 1998 | if (addrDisp != -1) { |
aoqi@0 | 1999 | AddressingDispositionHelper.write(outputObject, addrDisp); |
aoqi@0 | 2000 | } |
aoqi@0 | 2001 | return; |
aoqi@0 | 2002 | } |
aoqi@0 | 2003 | } |
aoqi@0 | 2004 | |
aoqi@0 | 2005 | public CorbaMessageMediator createResponse( |
aoqi@0 | 2006 | CorbaMessageMediator messageMediator, |
aoqi@0 | 2007 | ServiceContexts svc) |
aoqi@0 | 2008 | { |
aoqi@0 | 2009 | // REVISIT: ignore service contexts during framework transition. |
aoqi@0 | 2010 | // They are set in SubcontractResponseHandler to the wrong connection. |
aoqi@0 | 2011 | // Then they would be set again here and a duplicate contexts |
aoqi@0 | 2012 | // exception occurs. |
aoqi@0 | 2013 | return createResponseHelper( |
aoqi@0 | 2014 | messageMediator, |
aoqi@0 | 2015 | getServiceContextsForReply(messageMediator, null)); |
aoqi@0 | 2016 | } |
aoqi@0 | 2017 | |
aoqi@0 | 2018 | public CorbaMessageMediator createUserExceptionResponse( |
aoqi@0 | 2019 | CorbaMessageMediator messageMediator, ServiceContexts svc) |
aoqi@0 | 2020 | { |
aoqi@0 | 2021 | // REVISIT - same as above |
aoqi@0 | 2022 | return createResponseHelper( |
aoqi@0 | 2023 | messageMediator, |
aoqi@0 | 2024 | getServiceContextsForReply(messageMediator, null), |
aoqi@0 | 2025 | true); |
aoqi@0 | 2026 | } |
aoqi@0 | 2027 | |
aoqi@0 | 2028 | public CorbaMessageMediator createUnknownExceptionResponse( |
aoqi@0 | 2029 | CorbaMessageMediator messageMediator, UnknownException ex) |
aoqi@0 | 2030 | { |
aoqi@0 | 2031 | // NOTE: This service context container gets augmented in |
aoqi@0 | 2032 | // tail call. |
aoqi@0 | 2033 | ServiceContexts contexts = null; |
aoqi@0 | 2034 | SystemException sys = new UNKNOWN( 0, |
aoqi@0 | 2035 | CompletionStatus.COMPLETED_MAYBE); |
aoqi@0 | 2036 | contexts = new ServiceContexts( (ORB)messageMediator.getBroker() ); |
aoqi@0 | 2037 | UEInfoServiceContext uei = new UEInfoServiceContext(sys); |
aoqi@0 | 2038 | contexts.put( uei ) ; |
aoqi@0 | 2039 | return createSystemExceptionResponse(messageMediator, sys, contexts); |
aoqi@0 | 2040 | } |
aoqi@0 | 2041 | |
aoqi@0 | 2042 | public CorbaMessageMediator createSystemExceptionResponse( |
aoqi@0 | 2043 | CorbaMessageMediator messageMediator, |
aoqi@0 | 2044 | SystemException ex, |
aoqi@0 | 2045 | ServiceContexts svc) |
aoqi@0 | 2046 | { |
aoqi@0 | 2047 | if (messageMediator.getConnection() != null) { |
aoqi@0 | 2048 | // It is possible that fragments of response have already been |
aoqi@0 | 2049 | // sent. Then an error may occur (e.g. marshaling error like |
aoqi@0 | 2050 | // non serializable object). In that case it is too late |
aoqi@0 | 2051 | // to send the exception. We just return the existing fragmented |
aoqi@0 | 2052 | // stream here. This will cause an incomplete last fragment |
aoqi@0 | 2053 | // to be sent. Then the other side will get a marshaling error |
aoqi@0 | 2054 | // when attempting to unmarshal. |
aoqi@0 | 2055 | |
aoqi@0 | 2056 | // REVISIT: Impl - make interface method to do the following. |
aoqi@0 | 2057 | CorbaMessageMediatorImpl mediator = (CorbaMessageMediatorImpl) |
aoqi@0 | 2058 | ((CorbaConnection)messageMediator.getConnection()) |
aoqi@0 | 2059 | .serverRequestMapGet(messageMediator.getRequestId()); |
aoqi@0 | 2060 | |
aoqi@0 | 2061 | OutputObject existingOutputObject = null; |
aoqi@0 | 2062 | if (mediator != null) { |
aoqi@0 | 2063 | existingOutputObject = mediator.getOutputObject(); |
aoqi@0 | 2064 | } |
aoqi@0 | 2065 | |
aoqi@0 | 2066 | // REVISIT: need to think about messageMediator containing correct |
aoqi@0 | 2067 | // pointer to output object. |
aoqi@0 | 2068 | if (existingOutputObject != null && |
aoqi@0 | 2069 | mediator.sentFragment() && |
aoqi@0 | 2070 | ! mediator.sentFullMessage()) |
aoqi@0 | 2071 | { |
aoqi@0 | 2072 | return mediator; |
aoqi@0 | 2073 | } |
aoqi@0 | 2074 | } |
aoqi@0 | 2075 | |
aoqi@0 | 2076 | // Only do this if interceptors have been initialized on this request |
aoqi@0 | 2077 | // and have not completed their lifecycle (otherwise the info stack |
aoqi@0 | 2078 | // may be empty or have a different request's entry on top). |
aoqi@0 | 2079 | if (messageMediator.executePIInResponseConstructor()) { |
aoqi@0 | 2080 | // REVISIT: not necessary in framework now? |
aoqi@0 | 2081 | // Inform Portable Interceptors of the SystemException. This is |
aoqi@0 | 2082 | // required to be done here because the ending interception point |
aoqi@0 | 2083 | // is called in the when creating the response below |
aoqi@0 | 2084 | // but we do not currently write the SystemException into the |
aoqi@0 | 2085 | // response until after the ending point is called. |
aoqi@0 | 2086 | ((ORB)messageMediator.getBroker()).getPIHandler().setServerPIInfo( ex ); |
aoqi@0 | 2087 | } |
aoqi@0 | 2088 | |
aoqi@0 | 2089 | if (((ORB)messageMediator.getBroker()).subcontractDebugFlag && |
aoqi@0 | 2090 | ex != null) |
aoqi@0 | 2091 | { |
aoqi@0 | 2092 | dprint(".createSystemExceptionResponse: " |
aoqi@0 | 2093 | + opAndId(messageMediator), |
aoqi@0 | 2094 | ex); |
aoqi@0 | 2095 | } |
aoqi@0 | 2096 | |
aoqi@0 | 2097 | ServiceContexts serviceContexts = |
aoqi@0 | 2098 | getServiceContextsForReply(messageMediator, svc); |
aoqi@0 | 2099 | |
aoqi@0 | 2100 | // NOTE: We MUST add the service context before creating |
aoqi@0 | 2101 | // the response since service contexts are written to the |
aoqi@0 | 2102 | // stream when the response object is created. |
aoqi@0 | 2103 | |
aoqi@0 | 2104 | addExceptionDetailMessage(messageMediator, ex, serviceContexts); |
aoqi@0 | 2105 | |
aoqi@0 | 2106 | CorbaMessageMediator response = |
aoqi@0 | 2107 | createResponseHelper(messageMediator, serviceContexts, false); |
aoqi@0 | 2108 | |
aoqi@0 | 2109 | // NOTE: From here on, it is too late to add more service contexts. |
aoqi@0 | 2110 | // They have already been serialized to the stream (and maybe fragments |
aoqi@0 | 2111 | // sent). |
aoqi@0 | 2112 | |
aoqi@0 | 2113 | ORBUtility.writeSystemException( |
aoqi@0 | 2114 | ex, (OutputStream)response.getOutputObject()); |
aoqi@0 | 2115 | |
aoqi@0 | 2116 | return response; |
aoqi@0 | 2117 | } |
aoqi@0 | 2118 | |
aoqi@0 | 2119 | private void addExceptionDetailMessage(CorbaMessageMediator mediator, |
aoqi@0 | 2120 | SystemException ex, |
aoqi@0 | 2121 | ServiceContexts serviceContexts) |
aoqi@0 | 2122 | { |
aoqi@0 | 2123 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
aoqi@0 | 2124 | PrintWriter pw = new PrintWriter(baos); |
aoqi@0 | 2125 | ex.printStackTrace(pw); |
aoqi@0 | 2126 | pw.flush(); // NOTE: you must flush or baos will be empty. |
aoqi@0 | 2127 | EncapsOutputStream encapsOutputStream = |
aoqi@0 | 2128 | sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)mediator.getBroker()); |
aoqi@0 | 2129 | encapsOutputStream.putEndian(); |
aoqi@0 | 2130 | encapsOutputStream.write_wstring(baos.toString()); |
aoqi@0 | 2131 | UnknownServiceContext serviceContext = |
aoqi@0 | 2132 | new UnknownServiceContext(ExceptionDetailMessage.value, |
aoqi@0 | 2133 | encapsOutputStream.toByteArray()); |
aoqi@0 | 2134 | serviceContexts.put(serviceContext); |
aoqi@0 | 2135 | } |
aoqi@0 | 2136 | |
aoqi@0 | 2137 | public CorbaMessageMediator createLocationForward( |
aoqi@0 | 2138 | CorbaMessageMediator messageMediator, IOR ior, ServiceContexts svc) |
aoqi@0 | 2139 | { |
aoqi@0 | 2140 | ReplyMessage reply |
aoqi@0 | 2141 | = MessageBase.createReply( |
aoqi@0 | 2142 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 2143 | messageMediator.getGIOPVersion(), |
aoqi@0 | 2144 | messageMediator.getEncodingVersion(), |
aoqi@0 | 2145 | messageMediator.getRequestId(), |
aoqi@0 | 2146 | ReplyMessage.LOCATION_FORWARD, |
aoqi@0 | 2147 | getServiceContextsForReply(messageMediator, svc), |
aoqi@0 | 2148 | ior); |
aoqi@0 | 2149 | |
aoqi@0 | 2150 | return createResponseHelper(messageMediator, reply, ior); |
aoqi@0 | 2151 | } |
aoqi@0 | 2152 | |
aoqi@0 | 2153 | protected CorbaMessageMediator createResponseHelper( |
aoqi@0 | 2154 | CorbaMessageMediator messageMediator, ServiceContexts svc) |
aoqi@0 | 2155 | { |
aoqi@0 | 2156 | ReplyMessage message = |
aoqi@0 | 2157 | MessageBase.createReply( |
aoqi@0 | 2158 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 2159 | messageMediator.getGIOPVersion(), |
aoqi@0 | 2160 | messageMediator.getEncodingVersion(), |
aoqi@0 | 2161 | messageMediator.getRequestId(), |
aoqi@0 | 2162 | ReplyMessage.NO_EXCEPTION, |
aoqi@0 | 2163 | svc, |
aoqi@0 | 2164 | null); |
aoqi@0 | 2165 | return createResponseHelper(messageMediator, message, null); |
aoqi@0 | 2166 | } |
aoqi@0 | 2167 | |
aoqi@0 | 2168 | protected CorbaMessageMediator createResponseHelper( |
aoqi@0 | 2169 | CorbaMessageMediator messageMediator, ServiceContexts svc,boolean user) |
aoqi@0 | 2170 | { |
aoqi@0 | 2171 | ReplyMessage message = |
aoqi@0 | 2172 | MessageBase.createReply( |
aoqi@0 | 2173 | (ORB)messageMediator.getBroker(), |
aoqi@0 | 2174 | messageMediator.getGIOPVersion(), |
aoqi@0 | 2175 | messageMediator.getEncodingVersion(), |
aoqi@0 | 2176 | messageMediator.getRequestId(), |
aoqi@0 | 2177 | user ? ReplyMessage.USER_EXCEPTION : |
aoqi@0 | 2178 | ReplyMessage.SYSTEM_EXCEPTION, |
aoqi@0 | 2179 | svc, |
aoqi@0 | 2180 | null); |
aoqi@0 | 2181 | return createResponseHelper(messageMediator, message, null); |
aoqi@0 | 2182 | } |
aoqi@0 | 2183 | |
aoqi@0 | 2184 | // REVISIT - IOR arg is ignored. |
aoqi@0 | 2185 | protected CorbaMessageMediator createResponseHelper( |
aoqi@0 | 2186 | CorbaMessageMediator messageMediator, ReplyMessage reply, IOR ior) |
aoqi@0 | 2187 | { |
aoqi@0 | 2188 | // REVISIT - these should be invoked from subcontract. |
aoqi@0 | 2189 | runServantPostInvoke(messageMediator); |
aoqi@0 | 2190 | runInterceptors(messageMediator, reply); |
aoqi@0 | 2191 | runRemoveThreadInfo(messageMediator); |
aoqi@0 | 2192 | |
aoqi@0 | 2193 | if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) { |
aoqi@0 | 2194 | dprint(".createResponseHelper: " |
aoqi@0 | 2195 | + opAndId(messageMediator) + ": " |
aoqi@0 | 2196 | + reply); |
aoqi@0 | 2197 | } |
aoqi@0 | 2198 | |
aoqi@0 | 2199 | messageMediator.setReplyHeader(reply); |
aoqi@0 | 2200 | |
aoqi@0 | 2201 | OutputObject replyOutputObject; |
aoqi@0 | 2202 | // REVISIT = do not use null. |
aoqi@0 | 2203 | // |
aoqi@0 | 2204 | if (messageMediator.getConnection() == null) { |
aoqi@0 | 2205 | replyOutputObject = |
aoqi@0 | 2206 | sun.corba.OutputStreamFactory.newCDROutputObject(orb, |
aoqi@0 | 2207 | messageMediator, messageMediator.getReplyHeader(), |
aoqi@0 | 2208 | messageMediator.getStreamFormatVersion(), |
aoqi@0 | 2209 | BufferManagerFactory.GROW); |
aoqi@0 | 2210 | } else { |
aoqi@0 | 2211 | replyOutputObject = messageMediator.getConnection().getAcceptor() |
aoqi@0 | 2212 | .createOutputObject(messageMediator.getBroker(), messageMediator); |
aoqi@0 | 2213 | } |
aoqi@0 | 2214 | messageMediator.setOutputObject(replyOutputObject); |
aoqi@0 | 2215 | messageMediator.getOutputObject().setMessageMediator(messageMediator); |
aoqi@0 | 2216 | |
aoqi@0 | 2217 | reply.write((OutputStream) messageMediator.getOutputObject()); |
aoqi@0 | 2218 | if (reply.getIOR() != null) { |
aoqi@0 | 2219 | reply.getIOR().write((OutputStream) messageMediator.getOutputObject()); |
aoqi@0 | 2220 | } |
aoqi@0 | 2221 | // REVISIT - not necessary? |
aoqi@0 | 2222 | //messageMediator.this.replyIOR = reply.getIOR(); |
aoqi@0 | 2223 | |
aoqi@0 | 2224 | // NOTE: The mediator holds onto output object so return value |
aoqi@0 | 2225 | // not really necessary. |
aoqi@0 | 2226 | return messageMediator; |
aoqi@0 | 2227 | } |
aoqi@0 | 2228 | |
aoqi@0 | 2229 | protected void runServantPostInvoke(CorbaMessageMediator messageMediator) |
aoqi@0 | 2230 | { |
aoqi@0 | 2231 | // Run ServantLocator::postinvoke. This may cause a SystemException |
aoqi@0 | 2232 | // which will throw out of the constructor and return later |
aoqi@0 | 2233 | // to construct a reply for that exception. The internal logic |
aoqi@0 | 2234 | // of returnServant makes sure that postinvoke is only called once. |
aoqi@0 | 2235 | // REVISIT: instead of instanceof, put method on all orbs. |
aoqi@0 | 2236 | ORB orb = null; |
aoqi@0 | 2237 | // This flag is to deal with BootstrapServer use of reply streams, |
aoqi@0 | 2238 | // with ServerRequestDispatcher's use of reply streams, etc. |
aoqi@0 | 2239 | if (messageMediator.executeReturnServantInResponseConstructor()) { |
aoqi@0 | 2240 | // It is possible to get marshaling errors in the skeleton after |
aoqi@0 | 2241 | // postinvoke has completed. We must set this to false so that |
aoqi@0 | 2242 | // when the error exception reply is constructed we don't try |
aoqi@0 | 2243 | // to incorrectly access poa current (which will be the wrong |
aoqi@0 | 2244 | // one or an empty stack. |
aoqi@0 | 2245 | messageMediator.setExecuteReturnServantInResponseConstructor(false); |
aoqi@0 | 2246 | messageMediator.setExecuteRemoveThreadInfoInResponseConstructor(true); |
aoqi@0 | 2247 | |
aoqi@0 | 2248 | try { |
aoqi@0 | 2249 | orb = (ORB)messageMediator.getBroker(); |
aoqi@0 | 2250 | OAInvocationInfo info = orb.peekInvocationInfo() ; |
aoqi@0 | 2251 | ObjectAdapter oa = info.oa(); |
aoqi@0 | 2252 | try { |
aoqi@0 | 2253 | oa.returnServant() ; |
aoqi@0 | 2254 | } catch (Throwable thr) { |
aoqi@0 | 2255 | wrapper.unexpectedException( thr ) ; |
aoqi@0 | 2256 | |
aoqi@0 | 2257 | if (thr instanceof Error) |
aoqi@0 | 2258 | throw (Error)thr ; |
aoqi@0 | 2259 | else if (thr instanceof RuntimeException) |
aoqi@0 | 2260 | throw (RuntimeException)thr ; |
aoqi@0 | 2261 | } finally { |
aoqi@0 | 2262 | oa.exit(); |
aoqi@0 | 2263 | } |
aoqi@0 | 2264 | } catch (EmptyStackException ese) { |
aoqi@0 | 2265 | throw wrapper.emptyStackRunServantPostInvoke( ese ) ; |
aoqi@0 | 2266 | } |
aoqi@0 | 2267 | } |
aoqi@0 | 2268 | } |
aoqi@0 | 2269 | |
aoqi@0 | 2270 | protected void runInterceptors(CorbaMessageMediator messageMediator, |
aoqi@0 | 2271 | ReplyMessage reply) |
aoqi@0 | 2272 | { |
aoqi@0 | 2273 | if( messageMediator.executePIInResponseConstructor() ) { |
aoqi@0 | 2274 | // Invoke server request ending interception points (send_*): |
aoqi@0 | 2275 | // Note: this may end up with a SystemException or an internal |
aoqi@0 | 2276 | // Runtime ForwardRequest |
aoqi@0 | 2277 | ((ORB)messageMediator.getBroker()).getPIHandler(). |
aoqi@0 | 2278 | invokeServerPIEndingPoint( reply ); |
aoqi@0 | 2279 | |
aoqi@0 | 2280 | // Note this will be executed even if a ForwardRequest or |
aoqi@0 | 2281 | // SystemException is thrown by a Portable Interceptors ending |
aoqi@0 | 2282 | // point since we end up in this constructor again anyway. |
aoqi@0 | 2283 | ((ORB)messageMediator.getBroker()).getPIHandler(). |
aoqi@0 | 2284 | cleanupServerPIRequest(); |
aoqi@0 | 2285 | |
aoqi@0 | 2286 | // See createSystemExceptionResponse for why this is necesary. |
aoqi@0 | 2287 | messageMediator.setExecutePIInResponseConstructor(false); |
aoqi@0 | 2288 | } |
aoqi@0 | 2289 | } |
aoqi@0 | 2290 | |
aoqi@0 | 2291 | protected void runRemoveThreadInfo(CorbaMessageMediator messageMediator) |
aoqi@0 | 2292 | { |
aoqi@0 | 2293 | // Once you get here then the final reply is available (i.e., |
aoqi@0 | 2294 | // postinvoke and interceptors have completed. |
aoqi@0 | 2295 | if (messageMediator.executeRemoveThreadInfoInResponseConstructor()) { |
aoqi@0 | 2296 | messageMediator.setExecuteRemoveThreadInfoInResponseConstructor(false); |
aoqi@0 | 2297 | ((ORB)messageMediator.getBroker()).popInvocationInfo() ; |
aoqi@0 | 2298 | } |
aoqi@0 | 2299 | } |
aoqi@0 | 2300 | |
aoqi@0 | 2301 | protected ServiceContexts getServiceContextsForReply( |
aoqi@0 | 2302 | CorbaMessageMediator messageMediator, ServiceContexts contexts) |
aoqi@0 | 2303 | { |
aoqi@0 | 2304 | CorbaConnection c = (CorbaConnection) messageMediator.getConnection(); |
aoqi@0 | 2305 | |
aoqi@0 | 2306 | if (((ORB)messageMediator.getBroker()).subcontractDebugFlag) { |
aoqi@0 | 2307 | dprint(".getServiceContextsForReply: " |
aoqi@0 | 2308 | + opAndId(messageMediator) |
aoqi@0 | 2309 | + ": " + c); |
aoqi@0 | 2310 | } |
aoqi@0 | 2311 | |
aoqi@0 | 2312 | if (contexts == null) { |
aoqi@0 | 2313 | contexts = new ServiceContexts(((ORB)messageMediator.getBroker())); |
aoqi@0 | 2314 | } |
aoqi@0 | 2315 | |
aoqi@0 | 2316 | // NOTE : We only want to send the runtime context the first time |
aoqi@0 | 2317 | |
aoqi@0 | 2318 | if (c != null && !c.isPostInitialContexts()) { |
aoqi@0 | 2319 | c.setPostInitialContexts(); |
aoqi@0 | 2320 | SendingContextServiceContext scsc = |
aoqi@0 | 2321 | new SendingContextServiceContext( |
aoqi@0 | 2322 | ((ORB)messageMediator.getBroker()).getFVDCodeBaseIOR()) ; |
aoqi@0 | 2323 | |
aoqi@0 | 2324 | if (contexts.get( scsc.getId() ) != null) |
aoqi@0 | 2325 | throw wrapper.duplicateSendingContextServiceContext() ; |
aoqi@0 | 2326 | |
aoqi@0 | 2327 | contexts.put( scsc ) ; |
aoqi@0 | 2328 | |
aoqi@0 | 2329 | if ( ((ORB)messageMediator.getBroker()).subcontractDebugFlag) |
aoqi@0 | 2330 | dprint(".getServiceContextsForReply: " |
aoqi@0 | 2331 | + opAndId(messageMediator) |
aoqi@0 | 2332 | + ": added SendingContextServiceContext" ) ; |
aoqi@0 | 2333 | } |
aoqi@0 | 2334 | |
aoqi@0 | 2335 | // send ORBVersion servicecontext as part of the Reply |
aoqi@0 | 2336 | |
aoqi@0 | 2337 | ORBVersionServiceContext ovsc |
aoqi@0 | 2338 | = new ORBVersionServiceContext(ORBVersionFactory.getORBVersion()); |
aoqi@0 | 2339 | |
aoqi@0 | 2340 | if (contexts.get( ovsc.getId() ) != null) |
aoqi@0 | 2341 | throw wrapper.duplicateOrbVersionServiceContext() ; |
aoqi@0 | 2342 | |
aoqi@0 | 2343 | contexts.put( ovsc ) ; |
aoqi@0 | 2344 | |
aoqi@0 | 2345 | if ( ((ORB)messageMediator.getBroker()).subcontractDebugFlag) |
aoqi@0 | 2346 | dprint(".getServiceContextsForReply: " |
aoqi@0 | 2347 | + opAndId(messageMediator) |
aoqi@0 | 2348 | + ": added ORB version service context"); |
aoqi@0 | 2349 | |
aoqi@0 | 2350 | return contexts; |
aoqi@0 | 2351 | } |
aoqi@0 | 2352 | |
aoqi@0 | 2353 | // REVISIT - this method should be migrated to orbutil.ORBUtility |
aoqi@0 | 2354 | // since all locations that release ByteBuffers use |
aoqi@0 | 2355 | // very similar logic and debug information. |
aoqi@0 | 2356 | private void releaseByteBufferToPool() { |
aoqi@0 | 2357 | if (dispatchByteBuffer != null) { |
aoqi@0 | 2358 | orb.getByteBufferPool().releaseByteBuffer(dispatchByteBuffer); |
aoqi@0 | 2359 | if (transportDebug()) { |
aoqi@0 | 2360 | int bbId = System.identityHashCode(dispatchByteBuffer); |
aoqi@0 | 2361 | StringBuffer sb = new StringBuffer(); |
aoqi@0 | 2362 | sb.append(".handleInput: releasing ByteBuffer (" + bbId + |
aoqi@0 | 2363 | ") to ByteBufferPool"); |
aoqi@0 | 2364 | dprint(sb.toString()); |
aoqi@0 | 2365 | } |
aoqi@0 | 2366 | } |
aoqi@0 | 2367 | } |
aoqi@0 | 2368 | } |
aoqi@0 | 2369 | |
aoqi@0 | 2370 | // End of file. |