requestimpl.java
来自「java jdk 1.4的源码」· Java 代码 · 共 649 行 · 第 1/2 页
JAVA
649 行
/* * @(#)RequestImpl.java 1.62 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* * Licensed Materials - Property of IBM * RMI-IIOP v1.0 * Copyright IBM Corp. 1998 1999 All Rights Reserved * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */package com.sun.corba.se.internal.corba;import org.omg.CORBA.Any;import org.omg.CORBA.ARG_IN;import org.omg.CORBA.ARG_OUT;import org.omg.CORBA.ARG_INOUT;import org.omg.CORBA.Context;import org.omg.CORBA.ContextList;import org.omg.CORBA.Environment;import org.omg.CORBA.ExceptionList;import org.omg.CORBA.NVList;import org.omg.CORBA.NamedValue;import org.omg.CORBA.Request;import org.omg.CORBA.SystemException;import org.omg.CORBA.TCKind;import org.omg.CORBA.TypeCode;import org.omg.CORBA.TypeCodePackage.BadKind;import org.omg.CORBA.UnknownUserException;import org.omg.CORBA.Bounds;import org.omg.CORBA.UNKNOWN;import org.omg.CORBA.INTERNAL;import org.omg.CORBA.NO_IMPLEMENT;import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.WrongTransaction;import org.omg.CORBA.portable.*;import com.sun.corba.se.internal.corba.ClientDelegate;import com.sun.corba.se.internal.core.*;import com.sun.corba.se.internal.iiop.messages.ReplyMessage;import com.sun.corba.se.internal.orbutil.MinorCodes;public class RequestImpl extends Request { /////////////////////////////////////////////////////////////////////////// // data members protected ObjectImpl _target = null; protected String _opName = null; protected NVList _arguments = null; protected ExceptionList _exceptions = null; private NamedValue _result = null; protected Environment _env = null; private Context _ctx = null; private ContextList _ctxList = null; protected ORB _orb = null; // invocation-specific stuff protected boolean _isOneWay = false; private int[] _paramCodes = null; private long[] _paramLongs = null; private java.lang.Object[] _paramObjects = null; // support for deferred invocations. // protected instead of private since it needs to be set by the // thread object doing the asynchronous invocation. protected boolean gotResponse = false; /////////////////////////////////////////////////////////////////////////// // constructor protected RequestImpl (ORB orb, org.omg.CORBA.Object targetObject, Context ctx, String operationName, NVList argumentList, NamedValue resultContainer, ExceptionList exceptionList, ContextList ctxList) { // initialize the orb _orb = orb; // initialize target, context and operation name _target = (ObjectImpl) targetObject; _ctx = ctx; _opName = operationName; // initialize argument list if not passed in if (argumentList == null) _arguments = new NVListImpl(_orb); else _arguments = argumentList; // set result container. _result = resultContainer; // initialize exception list if not passed in if (exceptionList == null) _exceptions = new ExceptionListImpl(); else _exceptions = exceptionList; // initialize context list if not passed in if (ctxList == null) _ctxList = new ContextListImpl(_orb); else _ctxList = ctxList; // initialize environment _env = new EnvironmentImpl(); } public org.omg.CORBA.Object target() { return _target; } public String operation() { return _opName; } public NVList arguments() { return _arguments; } public NamedValue result() { return _result; } public Environment env() { return _env; } public ExceptionList exceptions() { return _exceptions; } public ContextList contexts() { return _ctxList; } public synchronized Context ctx() { if (_ctx == null) _ctx = new ContextImpl(_orb); return _ctx; } public synchronized void ctx(Context newCtx) { _ctx = newCtx; } public synchronized Any add_in_arg() { return _arguments.add(org.omg.CORBA.ARG_IN.value).value(); } public synchronized Any add_named_in_arg(String name) { return _arguments.add_item(name, org.omg.CORBA.ARG_IN.value).value(); } public synchronized Any add_inout_arg() { return _arguments.add(org.omg.CORBA.ARG_INOUT.value).value(); } public synchronized Any add_named_inout_arg(String name) { return _arguments.add_item(name, org.omg.CORBA.ARG_INOUT.value).value(); } public synchronized Any add_out_arg() { return _arguments.add(org.omg.CORBA.ARG_OUT.value).value(); } public synchronized Any add_named_out_arg(String name) { return _arguments.add_item(name, org.omg.CORBA.ARG_OUT.value).value(); } public synchronized void set_return_type(TypeCode tc) { if (_result == null) _result = new NamedValueImpl(_orb); _result.value().type(tc); } public synchronized Any return_value() { if (_result == null) _result = new NamedValueImpl(_orb); return _result.value(); } public synchronized void add_exception(TypeCode exceptionType) { _exceptions.add(exceptionType); } public synchronized void invoke() { doInvocation(); } public synchronized void send_oneway() { _isOneWay = true; doInvocation(); } public synchronized void send_deferred() { AsynchInvoke invokeObject = new AsynchInvoke((com.sun.corba.se.internal.corba.ORB) _orb, this, false); new Thread(invokeObject).start(); } public synchronized boolean poll_response() { // this method has to be synchronized even though it seems // "readonly" since the thread object doing the asynchronous // invocation can potentially update this variable in parallel. // updates are currently simply synchronized againt the request // object. return gotResponse; } public synchronized void get_response() throws org.omg.CORBA.WrongTransaction { while (gotResponse == false) { // release the lock. wait to be notified by the thread that is // doing the asynchronous invocation. try { wait(); } catch (InterruptedException e) {} } } /////////////////////////////////////////////////////////////////////////// // private helper methods /* * The doInvocation operation is where the real mechanics of * performing the request invocation is done. */ protected void doInvocation() { // Get delegate // CHANGE(RAM J) (05/01/2000) changed ClientSubContract to ClientDelegate //ClientSubcontract delegate = (ClientSubcontract)_target._get_delegate(); // Initiate Client Portable Interceptors. Inform the PIORB that // this is a DII request so that it knows to ignore the second // inevitable call to initiateClientPIRequest in createRequest. // Also, save the RequestImpl object for later use. _orb.initiateClientPIRequest( true ); _orb.setClientPIInfo( this ); ClientDelegate delegate = (ClientDelegate)_target._get_delegate(); ClientRequest req; Exception exception=null; ClientResponse resp=null; // Note: This try/catch was added for PI. It is analogous to the // try / catch / finally found below for the line // "resp = delegate.invoke(req);". The finally is moved into the // catch body of SystemException since it should only be executed // if the request creation failed. try { req = delegate.createRequest(_opName, _isOneWay); } catch( SystemException ex ) { _env.exception(ex); exception = ex; // Note, this try block is copied directly from the one that // appears later in this method. Please synchronize changes. // _REVISIT_ This code needs to be reviewed by Ram. try { _orb.sendCancelRequestIfFinalFragmentNotSent(); // REVISIT: Talk to sanjeevk and verify if this signature of // is releaseReply is important to DII. Can we just use one // releaseReply in ClientDelegate, instead of two? // _REVISIT_ The call to cleanupClientPIRequest should // really should go in releaseReply(). // However, because GenericPOAClientSC:305 v1.54 is // explicitly calling releaseReply, this would cause // cleanup to occur twice. Ask Ram why releaseReply is // being called instead of receivedReply. // Invoke Portable Interceptors cleanup. This is done to // handle exceptions during stream marshalling. _orb.cleanupClientPIRequest(); delegate.releaseReply(resp, _opName, exception); } catch ( WrongTransaction ex2 ) { // XXX return this for deferred sends throw new NO_IMPLEMENT(MinorCodes.SEND_DEFERRED_NOTIMPLEMENTED, CompletionStatus.COMPLETED_MAYBE); } catch ( SystemException ex2 ) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?