clientrequestinfoimpl.java
来自「java jdk 1.4的源码」· Java 代码 · 共 977 行 · 第 1/3 页
JAVA
977 行
/* * @(#)ClientRequestInfoImpl.java 1.42 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.corba.se.internal.Interceptors;import java.io.*;import java.lang.reflect.*;import org.omg.CORBA.Any;import org.omg.CORBA.BAD_INV_ORDER;import org.omg.CORBA.BAD_PARAM;import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.Context;import org.omg.CORBA.ContextList;import org.omg.CORBA.CTX_RESTRICT_SCOPE;import org.omg.CORBA.ExceptionList;import org.omg.CORBA.LocalObject;import org.omg.CORBA.NamedValue;import org.omg.CORBA.NO_IMPLEMENT;import org.omg.CORBA.NO_RESOURCES;import org.omg.CORBA.NVList;import org.omg.CORBA.Object;import org.omg.CORBA.ParameterMode;import org.omg.CORBA.Policy;import org.omg.CORBA.SystemException;import org.omg.CORBA.TypeCode;import org.omg.CORBA.INTERNAL;import org.omg.CORBA.UserException;import org.omg.CORBA.portable.ApplicationException;import org.omg.CORBA.portable.InputStream;import com.sun.corba.se.internal.corba.ClientDelegate;import com.sun.corba.se.internal.core.ClientResponse;import com.sun.corba.se.internal.core.ClientRequest;import com.sun.corba.se.internal.core.DuplicateServiceContext;import com.sun.corba.se.internal.core.GIOPVersion;import com.sun.corba.se.internal.core.IOR;import com.sun.corba.se.internal.core.NoSuchServiceContext;import com.sun.corba.se.internal.core.ServiceContexts;import com.sun.corba.se.internal.core.UnknownServiceContext;import com.sun.corba.se.internal.iiop.CDROutputStream;import com.sun.corba.se.internal.iiop.Connection;import com.sun.corba.se.internal.iiop.CDRInputStream_1_0;import com.sun.corba.se.internal.ior.IIOPProfile;import com.sun.corba.se.internal.orbutil.ORBUtility;import com.sun.corba.se.internal.util.RepositoryId;import org.omg.IOP.ServiceContext;import org.omg.IOP.ServiceContextHelper;import org.omg.IOP.TaggedProfile;import org.omg.IOP.TaggedProfileHelper;import org.omg.IOP.TaggedComponent;import org.omg.IOP.TaggedComponentHelper;import org.omg.IOP.TAG_INTERNET_IOP;import org.omg.PortableInterceptor.ClientRequestInfo;import org.omg.PortableInterceptor.LOCATION_FORWARD;import org.omg.Dynamic.Parameter;import org.omg.PortableInterceptor.SUCCESSFUL;import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;import org.omg.PortableInterceptor.TRANSPORT_RETRY;import org.omg.PortableInterceptor.USER_EXCEPTION;import java.util.*;/** * Implementation of the ClientRequestInfo interface as specified in * orbos/99-12-02 section 5.4.2. */public final class ClientRequestInfoImpl extends RequestInfoImpl implements ClientRequestInfo { // The available constants for startingPointCall static final int CALL_SEND_REQUEST = 0; static final int CALL_SEND_POLL = 1; // The available constants for endingPointCall static final int CALL_RECEIVE_REPLY = 0; static final int CALL_RECEIVE_EXCEPTION = 1; static final int CALL_RECEIVE_OTHER = 2; ////////////////////////////////////////////////////////////////////// // // NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET(); // ////////////////////////////////////////////////////////////////////// // The current retry request status. True if this request is being // retried and this info object is to be reused, or false otherwise. private boolean retryRequest; // The number of times this info object has been (re)used. This is // incremented every time a request is retried, and decremented every // time a request is complete. When this reaches zero, the info object // is popped from the ClientRequestInfoImpl ThreadLocal stack in PIORB. private int entryCount = 0; // The RequestImpl is set when the call is DII based. // The DII query calls like ParameterList, ExceptionList, // ContextList will be delegated to RequestImpl. private org.omg.CORBA.Request request; // Sources of client request information private IIOPProfile profile; private IOR targetIOR; private IOR effectiveTargetIOR; private int requestId; private String opName; private boolean isOneWay; private boolean diiInitiate; private ClientDelegate clientDelegate; private ClientResponse response; // Cached information: private org.omg.CORBA.Object cachedTargetObject; private org.omg.CORBA.Object cachedEffectiveTargetObject; private Parameter[] cachedArguments; private TypeCode[] cachedExceptions; private String[] cachedContexts; private String[] cachedOperationContext; private String cachedReceivedExceptionId; private Any cachedResult; private Any cachedReceivedException; private TaggedProfile cachedEffectiveProfile; // key = Integer, value = IOP.ServiceContext. private HashMap cachedRequestServiceContexts; // key = Integer, value = IOP.ServiceContext. private HashMap cachedReplyServiceContexts; // key = Integer, value = TaggedComponent private HashMap cachedEffectiveComponents; protected boolean piCurrentPushed; ////////////////////////////////////////////////////////////////////// // // NOTE: IF AN ATTRIBUTE IS ADDED, PLEASE UPDATE RESET(); // ////////////////////////////////////////////////////////////////////// /** * Reset the info object so that it can be reused for a retry, * for example. */ void reset() { super.reset(); // Please keep these in the same order that they're declared above. retryRequest = false; // Do not reset entryCount because we need to know when to pop this // from the stack. request = null; profile = null; targetIOR = null; effectiveTargetIOR = null; requestId = 0; opName = null; isOneWay = false; diiInitiate = false; clientDelegate = null; response = null; // Clear cached attributes: cachedTargetObject = null; cachedEffectiveTargetObject = null; cachedArguments = null; cachedExceptions = null; cachedContexts = null; cachedOperationContext = null; cachedReceivedExceptionId = null; cachedResult = null; cachedReceivedException = null; cachedEffectiveProfile = null; cachedRequestServiceContexts = null; cachedReplyServiceContexts = null; cachedEffectiveComponents = null; piCurrentPushed = false; startingPointCall = CALL_SEND_REQUEST; endingPointCall = CALL_RECEIVE_REPLY; } /* ********************************************************************** * Access protection **********************************************************************/ // Method IDs for all methods in ClientRequestInfo. This allows for a // convenient O(1) lookup for checkAccess(). protected static final int MID_TARGET = MID_RI_LAST + 1; protected static final int MID_EFFECTIVE_TARGET = MID_RI_LAST + 2; protected static final int MID_EFFECTIVE_PROFILE = MID_RI_LAST + 3; protected static final int MID_RECEIVED_EXCEPTION = MID_RI_LAST + 4; protected static final int MID_RECEIVED_EXCEPTION_ID = MID_RI_LAST + 5; protected static final int MID_GET_EFFECTIVE_COMPONENT = MID_RI_LAST + 6; protected static final int MID_GET_EFFECTIVE_COMPONENTS = MID_RI_LAST + 7; protected static final int MID_GET_REQUEST_POLICY = MID_RI_LAST + 8; protected static final int MID_ADD_REQUEST_SERVICE_CONTEXT = MID_RI_LAST + 9; // ClientRequestInfo validity table (see ptc/00-08-06 table 21-1). // Note: These must be in the same order as specified in contants. protected static final boolean validCall[][] = { // LEGEND: // s_req = send_request r_rep = receive_reply // s_pol = send_poll r_exc = receive_exception // r_oth = receive_other // // A true value indicates call is valid at specified point. // A false value indicates the call is invalid. // // // NOTE: If the order or number of columns change, update // checkAccess() accordingly. // // { s_req, s_pol, r_rep, r_exc, r_oth } // RequestInfo methods: /*request_id*/ { true , true , true , true , true }, /*operation*/ { true , true , true , true , true }, /*arguments*/ { true , false, true , false, false }, /*exceptions*/ { true , false, true , true , true }, /*contexts*/ { true , false, true , true , true }, /*operation_context*/ { true , false, true , true , true }, /*result*/ { false, false, true , false, false }, /*response_expected*/ { true , true , true , true , true }, /*sync_scope*/ { true , false, true , true , true }, /*reply_status*/ { false, false, true , true , true }, /*forward_reference*/ { false, false, false, false, true }, /*get_slot*/ { true , true , true , true , true }, /*get_request_service_context*/ { true , false, true , true , true }, /*get_reply_service_context*/ { false, false, true , true , true }, // // ClientRequestInfo methods:: /*target*/ { true , true , true , true , true }, /*effective_target*/ { true , true , true , true , true }, /*effective_profile*/ { true , true , true , true , true }, /*received_exception*/ { false, false, false, true , false }, /*received_exception_id*/ { false, false, false, true , false }, /*get_effective_component*/ { true , false, true , true , true }, /*get_effective_components*/ { true , false, true , true , true }, /*get_request_policy*/ { true , false, true , true , true }, /*add_request_service_context*/ { true , false, false, false, false } }; /* ********************************************************************** * Public ClientRequestInfo interfaces **********************************************************************/ /** * Creates a new ClientRequestInfo implementation. * The constructor is package scope since no other package need create * an instance of this class. */ protected ClientRequestInfoImpl( PIORB piOrb ) { super( piOrb ); startingPointCall = CALL_SEND_REQUEST; endingPointCall = CALL_RECEIVE_REPLY; } /** * The object which the client called to perform the operation. */ public org.omg.CORBA.Object target (){ // access is currently valid for all states: //checkAccess( MID_TARGET ); if (cachedTargetObject == null) { // No synchronization since not worth it here. cachedTargetObject = iorToObject(targetIOR); } return cachedTargetObject; } /** * The actual object on which the operation will be invoked. If the * reply_status is LOCATION_FORWARD, then on subsequent requests, * effective_target will contain the forwarded IOR while target will * remain unchanged. */ public org.omg.CORBA.Object effective_target() { // access is currently valid for all states: //checkAccess( MID_EFFECTIVE_TARGET ); // Note: This is not necessarily the same as locatedIOR. // Reason: See the way we handle COMM_FAILURES in // ClientDelegate.createRequest, v1.32 if (cachedEffectiveTargetObject == null) { // No synchronization since not worth it here. cachedEffectiveTargetObject = iorToObject(effectiveTargetIOR); } return cachedEffectiveTargetObject; } /** * The profile that will be used to send the request. If a location * forward has occurred for this operation's object and that object's * profile change accordingly, then this profile will be that located * profile. */ public TaggedProfile effective_profile (){ // access is currently valid for all states: //checkAccess( MID_EFFECTIVE_PROFILE ); if( cachedEffectiveProfile == null ) { cachedEffectiveProfile = profile.getIOPProfile( piOrb ) ; } // Good citizen: In the interest of efficiency, we assume interceptors // will not modify the returned TaggedProfile in any way so we need // not make a deep copy of it. return cachedEffectiveProfile; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?