corba/src/java.corba/share/classes/com/sun/corba/se/impl/corba/RequestImpl.java
author chegar
Tue, 19 Apr 2016 14:34:43 +0100
changeset 37620 230612715768
parent 33680 56aa0b79bf5a
permissions -rw-r--r--
8148863: Remove sun.misc.ManagedLocalsThread from corba Reviewed-by: alanb, coffeys, msheppar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
29937
c774371adf92 8048997: Enhance thread contexts in CORBA
msheppar
parents: 25862
diff changeset
     2
 * Copyright (c) 1996, 2015, 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
 * Licensed Materials - Property of IBM
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
 * RMI-IIOP v1.0
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1998 1999  All Rights Reserved
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
package com.sun.corba.se.impl.corba;
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
import org.omg.CORBA.Any;
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
import org.omg.CORBA.ARG_IN;
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
import org.omg.CORBA.ARG_OUT;
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
import org.omg.CORBA.ARG_INOUT;
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
import org.omg.CORBA.Context;
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
import org.omg.CORBA.ContextList;
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
import org.omg.CORBA.Environment;
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
import org.omg.CORBA.ExceptionList;
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
import org.omg.CORBA.NVList;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
import org.omg.CORBA.NamedValue;
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
import org.omg.CORBA.Request;
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
import org.omg.CORBA.SystemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
import org.omg.CORBA.TCKind;
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
import org.omg.CORBA.TypeCode;
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
import org.omg.CORBA.TypeCodePackage.BadKind;
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
import org.omg.CORBA.UnknownUserException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
import org.omg.CORBA.Bounds;
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
import org.omg.CORBA.UNKNOWN;
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
import org.omg.CORBA.INTERNAL;
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
import org.omg.CORBA.NO_IMPLEMENT;
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
import org.omg.CORBA.CompletionStatus;
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
import org.omg.CORBA.WrongTransaction;
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
import org.omg.CORBA.portable.ApplicationException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
import org.omg.CORBA.portable.RemarshalException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
import org.omg.CORBA.portable.InputStream ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
import org.omg.CORBA.portable.OutputStream ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
import com.sun.corba.se.spi.orb.ORB;
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
import com.sun.corba.se.spi.logging.CORBALogDomains;
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
import com.sun.corba.se.impl.corba.AsynchInvoke;
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
public class RequestImpl
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
    extends Request
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
    ///////////////////////////////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
    // data members
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
    protected org.omg.CORBA.Object _target;
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
    protected String             _opName;
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
    protected NVList             _arguments;
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
    protected ExceptionList      _exceptions;
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
    private NamedValue           _result;
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
    protected Environment        _env;
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
    private Context              _ctx;
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
    private ContextList          _ctxList;
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
    protected ORB                _orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
    private ORBUtilSystemException _wrapper;
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
    // invocation-specific stuff
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
    protected boolean            _isOneWay      = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
    private int[]                _paramCodes;
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
    private long[]               _paramLongs;
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
    private java.lang.Object[]   _paramObjects;
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
    // support for deferred invocations.
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
    // protected instead of private since it needs to be set by the
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
    // thread object doing the asynchronous invocation.
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
    protected boolean            gotResponse    = false;
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
    ///////////////////////////////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
    // constructor
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
    // REVISIT - used to be protected.  Now public so it can be
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
    // accessed from xgiop.
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
    public RequestImpl (ORB orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
                        org.omg.CORBA.Object targetObject,
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
                        Context ctx,
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
                        String operationName,
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
                        NVList argumentList,
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
                        NamedValue resultContainer,
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
                        ExceptionList exceptionList,
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
                        ContextList ctxList)
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
        // initialize the orb
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
        _orb    = orb;
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
        _wrapper = ORBUtilSystemException.get( orb,
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
            CORBALogDomains.OA_INVOCATION ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
        // initialize target, context and operation name
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
        _target     = targetObject;
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
        _ctx    = ctx;
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
        _opName = operationName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
        // initialize argument list if not passed in
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
        if (argumentList == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
            _arguments = new NVListImpl(_orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
            _arguments = argumentList;
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
        // set result container.
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
        _result = resultContainer;
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
        // initialize exception list if not passed in
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
        if (exceptionList == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
            _exceptions = new ExceptionListImpl();
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
            _exceptions = exceptionList;
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
        // initialize context list if not passed in
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
        if (ctxList == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
            _ctxList = new ContextListImpl(_orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
        else
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
            _ctxList = ctxList;
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
        // initialize environment
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
        _env    = new EnvironmentImpl();
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
    public org.omg.CORBA.Object target()
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
        return _target;
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
    public String operation()
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
        return _opName;
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
    public NVList arguments()
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
        return _arguments;
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
    public NamedValue result()
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
        return _result;
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
    public Environment env()
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
        return _env;
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
    public ExceptionList exceptions()
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
        return _exceptions;
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
    public ContextList contexts()
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
        return _ctxList;
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
    public synchronized Context ctx()
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
        if (_ctx == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
            _ctx = new ContextImpl(_orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
        return _ctx;
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
    public synchronized void ctx(Context newCtx)
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
        _ctx = newCtx;
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
    public synchronized Any add_in_arg()
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
        return _arguments.add(org.omg.CORBA.ARG_IN.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
    public synchronized Any add_named_in_arg(String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
        return _arguments.add_item(name, org.omg.CORBA.ARG_IN.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
    public synchronized Any add_inout_arg()
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
        return _arguments.add(org.omg.CORBA.ARG_INOUT.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
    public synchronized Any add_named_inout_arg(String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
        return _arguments.add_item(name, org.omg.CORBA.ARG_INOUT.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
    public synchronized Any add_out_arg()
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
        return _arguments.add(org.omg.CORBA.ARG_OUT.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
    public synchronized Any add_named_out_arg(String name)
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
        return _arguments.add_item(name, org.omg.CORBA.ARG_OUT.value).value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
    public synchronized void set_return_type(TypeCode tc)
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
        if (_result == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
            _result = new NamedValueImpl(_orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
        _result.value().type(tc);
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
    public synchronized Any return_value()
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
        if (_result == null)
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
            _result = new NamedValueImpl(_orb);
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
        return _result.value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
    public synchronized void add_exception(TypeCode exceptionType)
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
        _exceptions.add(exceptionType);
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
    public synchronized void invoke()
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
        doInvocation();
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 synchronized void send_oneway()
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
        _isOneWay = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
        doInvocation();
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
    public synchronized void send_deferred()
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
        AsynchInvoke invokeObject = new AsynchInvoke(_orb, this, false);
37620
230612715768 8148863: Remove sun.misc.ManagedLocalsThread from corba
chegar
parents: 33680
diff changeset
   258
        new Thread(null, invokeObject, "Async-Request-Invoker-Thread", 0, false).start();
4
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
    public synchronized boolean poll_response()
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
        // this method has to be synchronized even though it seems
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
        // "readonly" since the thread object doing the asynchronous
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
        // invocation can potentially update this variable in parallel.
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
        // updates are currently simply synchronized againt the request
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
        // object.
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
        return gotResponse;
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
    public synchronized void get_response()
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
        throws org.omg.CORBA.WrongTransaction
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
        while (gotResponse == false) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
            // release the lock. wait to be notified by the thread that is
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
            // doing the asynchronous invocation.
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
                wait();
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
            catch (InterruptedException e) {}
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
    ///////////////////////////////////////////////////////////////////////////
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
    // private helper methods
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
    /*
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
     * The doInvocation operation is where the real mechanics of
02bb8761fcce Initial load
duke
parents:
diff changeset
   289
     * performing the request invocation is done.
02bb8761fcce Initial load
duke
parents:
diff changeset
   290
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   291
    protected void doInvocation()
02bb8761fcce Initial load
duke
parents:
diff changeset
   292
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   293
        org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
02bb8761fcce Initial load
duke
parents:
diff changeset
   294
            _target ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   295
02bb8761fcce Initial load
duke
parents:
diff changeset
   296
        // Initiate Client Portable Interceptors.  Inform the PIHandler that
02bb8761fcce Initial load
duke
parents:
diff changeset
   297
        // this is a DII request so that it knows to ignore the second
02bb8761fcce Initial load
duke
parents:
diff changeset
   298
        // inevitable call to initiateClientPIRequest in createRequest.
02bb8761fcce Initial load
duke
parents:
diff changeset
   299
        // Also, save the RequestImpl object for later use.
02bb8761fcce Initial load
duke
parents:
diff changeset
   300
        _orb.getPIHandler().initiateClientPIRequest( true );
02bb8761fcce Initial load
duke
parents:
diff changeset
   301
        _orb.getPIHandler().setClientPIInfo( this );
02bb8761fcce Initial load
duke
parents:
diff changeset
   302
02bb8761fcce Initial load
duke
parents:
diff changeset
   303
        InputStream $in = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   304
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   305
            OutputStream $out = delegate.request(null, _opName, !_isOneWay);
02bb8761fcce Initial load
duke
parents:
diff changeset
   306
            // Marshal args
02bb8761fcce Initial load
duke
parents:
diff changeset
   307
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   308
                for (int i=0; i<_arguments.count() ; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   309
                    NamedValue nv = _arguments.item(i);
02bb8761fcce Initial load
duke
parents:
diff changeset
   310
                    switch (nv.flags()) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   311
                    case ARG_IN.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   312
                        nv.value().write_value($out);
02bb8761fcce Initial load
duke
parents:
diff changeset
   313
                        break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   314
                    case ARG_OUT.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   315
                        break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   316
                    case ARG_INOUT.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   317
                        nv.value().write_value($out);
02bb8761fcce Initial load
duke
parents:
diff changeset
   318
                        break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   319
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   320
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   321
            } catch ( org.omg.CORBA.Bounds ex ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   322
                throw _wrapper.boundsErrorInDiiRequest( ex ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   323
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   324
02bb8761fcce Initial load
duke
parents:
diff changeset
   325
            $in = delegate.invoke(null, $out);
02bb8761fcce Initial load
duke
parents:
diff changeset
   326
        } catch (ApplicationException e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   327
            // REVISIT - minor code.
02bb8761fcce Initial load
duke
parents:
diff changeset
   328
            // This is already handled in subcontract.
02bb8761fcce Initial load
duke
parents:
diff changeset
   329
            // REVISIT - uncomment.
02bb8761fcce Initial load
duke
parents:
diff changeset
   330
            //throw new INTERNAL();
02bb8761fcce Initial load
duke
parents:
diff changeset
   331
        } catch (RemarshalException e) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   332
            doInvocation();
02bb8761fcce Initial load
duke
parents:
diff changeset
   333
        } catch( SystemException ex ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   334
            _env.exception(ex);
02bb8761fcce Initial load
duke
parents:
diff changeset
   335
            // NOTE: The exception should not be thrown.
02bb8761fcce Initial load
duke
parents:
diff changeset
   336
            // However, JDK 1.4 and earlier threw the exception,
02bb8761fcce Initial load
duke
parents:
diff changeset
   337
            // so we keep the behavior to be compatible.
02bb8761fcce Initial load
duke
parents:
diff changeset
   338
            throw ex;
02bb8761fcce Initial load
duke
parents:
diff changeset
   339
        } finally {
02bb8761fcce Initial load
duke
parents:
diff changeset
   340
            delegate.releaseReply(null, $in);
02bb8761fcce Initial load
duke
parents:
diff changeset
   341
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   342
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   343
02bb8761fcce Initial load
duke
parents:
diff changeset
   344
    // REVISIT -  make protected after development - so xgiop can get it.
02bb8761fcce Initial load
duke
parents:
diff changeset
   345
    public void unmarshalReply(InputStream is)
02bb8761fcce Initial load
duke
parents:
diff changeset
   346
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   347
        // First unmarshal the return value if it is not void
02bb8761fcce Initial load
duke
parents:
diff changeset
   348
        if ( _result != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   349
            Any returnAny = _result.value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   350
            TypeCode returnType = returnAny.type();
02bb8761fcce Initial load
duke
parents:
diff changeset
   351
            if ( returnType.kind().value() != TCKind._tk_void )
02bb8761fcce Initial load
duke
parents:
diff changeset
   352
                returnAny.read_value(is, returnType);
02bb8761fcce Initial load
duke
parents:
diff changeset
   353
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   354
02bb8761fcce Initial load
duke
parents:
diff changeset
   355
        // Now unmarshal the out/inout args
02bb8761fcce Initial load
duke
parents:
diff changeset
   356
        try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   357
            for ( int i=0; i<_arguments.count() ; i++) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   358
                NamedValue nv = _arguments.item(i);
02bb8761fcce Initial load
duke
parents:
diff changeset
   359
                switch( nv.flags() ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   360
                case ARG_IN.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   361
                    break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   362
                case ARG_OUT.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   363
                case ARG_INOUT.value:
02bb8761fcce Initial load
duke
parents:
diff changeset
   364
                    Any any = nv.value();
02bb8761fcce Initial load
duke
parents:
diff changeset
   365
                    any.read_value(is, any.type());
02bb8761fcce Initial load
duke
parents:
diff changeset
   366
                    break;
02bb8761fcce Initial load
duke
parents:
diff changeset
   367
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   368
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   369
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   370
        catch ( org.omg.CORBA.Bounds ex ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   371
            // Cannot happen since we only iterate till _arguments.count()
02bb8761fcce Initial load
duke
parents:
diff changeset
   372
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   373
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   374
}