corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaResponseWaitingRoomImpl.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
child 13619 187e43fd5607
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
package com.sun.corba.se.impl.transport;
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import java.util.Hashtable;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import org.omg.CORBA.CompletionStatus;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import org.omg.CORBA.SystemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
import com.sun.corba.se.pept.encoding.InputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
import com.sun.corba.se.pept.encoding.OutputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import com.sun.corba.se.pept.protocol.MessageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import com.sun.corba.se.spi.logging.CORBALogDomains;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import com.sun.corba.se.spi.orb.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import com.sun.corba.se.spi.transport.CorbaConnection;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import com.sun.corba.se.spi.transport.CorbaResponseWaitingRoom;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import com.sun.corba.se.impl.encoding.BufferManagerReadStream;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import com.sun.corba.se.impl.encoding.CDRInputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import com.sun.corba.se.impl.orbutil.ORBUtility;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import com.sun.corba.se.impl.protocol.giopmsgheaders.LocateReplyOrReplyMessage;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
 * @author Harold Carr
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
public class CorbaResponseWaitingRoomImpl
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
    implements
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
        CorbaResponseWaitingRoom
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
    final static class OutCallDesc
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
        java.lang.Object done = new java.lang.Object();
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
        Thread thread;
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
        MessageMediator messageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
        SystemException exception;
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
        InputObject inputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
    private ORB orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
    private ORBUtilSystemException wrapper ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
    private CorbaConnection connection;
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
    // Maps requestId to an OutCallDesc.
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
    private Hashtable out_calls = null; // REVISIT - use int hastable/map
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
    public CorbaResponseWaitingRoomImpl(ORB orb, CorbaConnection connection)
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
        this.orb = orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
        wrapper = ORBUtilSystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
            CORBALogDomains.RPC_TRANSPORT ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
        this.connection = connection;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
        out_calls = new Hashtable();
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    ////////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    // pept.transport.ResponseWaitingRoom
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
    public void registerWaiter(MessageMediator mediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
        CorbaMessageMediator messageMediator = (CorbaMessageMediator) mediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
            dprint(".registerWaiter: " + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
        Integer requestId = messageMediator.getRequestIdInteger();
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
        OutCallDesc call = new OutCallDesc();
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
        call.thread = Thread.currentThread();
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
        call.messageMediator = messageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
        out_calls.put(requestId, call);
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
    public void unregisterWaiter(MessageMediator mediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
        CorbaMessageMediator messageMediator = (CorbaMessageMediator) mediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
            dprint(".unregisterWaiter: " + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
        Integer requestId = messageMediator.getRequestIdInteger();
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
        out_calls.remove(requestId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
    public InputObject waitForResponse(MessageMediator mediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
      CorbaMessageMediator messageMediator = (CorbaMessageMediator) mediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
      try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
        InputObject returnStream = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
            dprint(".waitForResponse->: " + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
        Integer requestId = messageMediator.getRequestIdInteger();
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
        if (messageMediator.isOneWay()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
            // The waiter is removed in releaseReply in the same
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
            // way as a normal request.
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
            if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
                dprint(".waitForResponse: one way - not waiting: "
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
                       + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
            return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
        OutCallDesc call = (OutCallDesc)out_calls.get(requestId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
        if (call == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
            throw wrapper.nullOutCall(CompletionStatus.COMPLETED_MAYBE);
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
        synchronized(call.done) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
            while (call.inputObject == null && call.exception == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
                // Wait for the reply from the server.
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
                // The ReaderThread reads in the reply IIOP message
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
                // and signals us.
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
                try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
                    if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
                        dprint(".waitForResponse: waiting: "
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
                               + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
                    call.done.wait();
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
                } catch (InterruptedException ie) {};
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
            if (call.exception != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
                if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
                    dprint(".waitForResponse: exception: "
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
                           + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
                throw call.exception;
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
            returnStream = call.inputObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
        // REVISIT -- exceptions from unmarshaling code will
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
        // go up through this client thread!
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
        if (returnStream != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
            // On fragmented streams the header MUST be unmarshaled here
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
            // (in the client thread) in case it blocks.
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
            // If the header was already unmarshaled, this won't
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
            // do anything
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
            // REVISIT: cast - need interface method.
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
            ((CDRInputObject)returnStream).unmarshalHeader();
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
        return returnStream;
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
      } finally {
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
            dprint(".waitForResponse<-: " + opAndId(messageMediator));
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
      }
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
    public void responseReceived(InputObject is)
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
        CDRInputObject inputObject = (CDRInputObject) is;
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
        LocateReplyOrReplyMessage header = (LocateReplyOrReplyMessage)
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
            inputObject.getMessageHeader();
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
        Integer requestId = new Integer(header.getRequestId());
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
        OutCallDesc call = (OutCallDesc) out_calls.get(requestId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
            dprint(".responseReceived: id/"
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
                   + requestId  + ": "
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
                   + header);
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
        // This is an interesting case.  It could mean that someone sent us a
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
        // reply message, but we don't know what request it was for.  That
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
        // would probably call for an error.  However, there's another case
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
        // that's normal and we should think about --
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        //
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
        // If the unmarshaling thread does all of its work inbetween the time
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
        // the ReaderThread gives it the last fragment and gets to the
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
        // out_calls.get line, then it will also be null, so just return;
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
        if (call == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
            if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
                dprint(".responseReceived: id/"
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
                       + requestId
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
                       + ": no waiter: "
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
                       + header);
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
            return;
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
        // Set the reply InputObject and signal the client thread
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
        // that the reply has been received.
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
        // The thread signalled will remove outcall descriptor if appropriate.
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
        // Otherwise, it'll be removed when last fragment for it has been put on
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
        // BufferManagerRead's queue.
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
        synchronized (call.done) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
            CorbaMessageMediator messageMediator = (CorbaMessageMediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
                call.messageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
            if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
                dprint(".responseReceived: "
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
                       + opAndId(messageMediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
                       + ": notifying waiters");
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
            messageMediator.setReplyHeader(header);
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
            messageMediator.setInputObject(is);
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
            inputObject.setMessageMediator(messageMediator);
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
            call.inputObject = is;
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
            call.done.notify();
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
    public int numberRegistered()
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
        // Note: Hashtable.size() is not synchronized
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
        return out_calls.size();
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
    //////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
    // CorbaResponseWaitingRoom
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
    public void signalExceptionToAllWaiters(SystemException systemException)
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
        if (orb.transportDebugFlag) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
            dprint(".signalExceptionToAllWaiters: " + systemException);
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
        OutCallDesc call;
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
        java.util.Enumeration e = out_calls.elements();
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
        while(e.hasMoreElements()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
            call = (OutCallDesc) e.nextElement();
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
            synchronized(call.done){
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
                // anything waiting for BufferManagerRead's fragment queue
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
                // needs to be cancelled
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
                CorbaMessageMediator corbaMsgMediator =
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
                             (CorbaMessageMediator)call.messageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
                CDRInputObject inputObject =
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
                           (CDRInputObject)corbaMsgMediator.getInputObject();
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
                // IMPORTANT: If inputObject is null, then no need to tell
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
                //            BufferManagerRead to cancel request processing.
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
                if (inputObject != null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
                    BufferManagerReadStream bufferManager =
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
                        (BufferManagerReadStream)inputObject.getBufferManager();
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
                    int requestId = corbaMsgMediator.getRequestId();
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
                    bufferManager.cancelProcessing(requestId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
                call.inputObject = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
                call.exception = systemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
                call.done.notify();
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
    public MessageMediator getMessageMediator(int requestId)
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
        Integer id = new Integer(requestId);
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
        OutCallDesc call = (OutCallDesc) out_calls.get(id);
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
        if (call == null) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
            // This can happen when getting early reply fragments for a
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
            // request which has completed (e.g., client marshaling error).
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
            return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
        return call.messageMediator;
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
    ////////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
    // Implementation.
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
    //
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
    protected void dprint(String msg)
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
        ORBUtility.dprint("CorbaResponseWaitingRoomImpl", msg);
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
    protected String opAndId(CorbaMessageMediator mediator)
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
        return ORBUtility.operationNameAndRequestId(mediator);
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
}
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
// End of file.