📄 clientrequestinfoimpl.java
字号:
/* * @(#)ClientRequestInfoImpl.java 1.46 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.corba.se.impl.interceptors;import java.util.HashMap ;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.spi.servicecontext.ServiceContexts;import com.sun.corba.se.spi.servicecontext.UnknownServiceContext;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.Dynamic.Parameter;import org.omg.PortableInterceptor.ClientRequestInfo;import org.omg.PortableInterceptor.LOCATION_FORWARD;import org.omg.PortableInterceptor.SUCCESSFUL;import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;import org.omg.PortableInterceptor.TRANSPORT_RETRY;import org.omg.PortableInterceptor.USER_EXCEPTION;import com.sun.corba.se.pept.protocol.MessageMediator;import com.sun.corba.se.spi.ior.IOR;import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate;import com.sun.corba.se.spi.ior.iiop.GIOPVersion;import com.sun.corba.se.spi.orb.ORB;import com.sun.corba.se.spi.protocol.CorbaMessageMediator;import com.sun.corba.se.spi.transport.CorbaContactInfo;import com.sun.corba.se.spi.transport.CorbaContactInfoList;import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator;import com.sun.corba.se.impl.encoding.CDROutputStream;import com.sun.corba.se.impl.encoding.CDRInputStream_1_0;import com.sun.corba.se.impl.orbutil.ORBUtility;import com.sun.corba.se.impl.protocol.CorbaInvocationInfo;import com.sun.corba.se.impl.util.RepositoryId;/** * 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 the ORB. 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 boolean diiInitiate; private CorbaMessageMediator messageMediator; // 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; diiInitiate = false; messageMediator = 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( ORB myORB ) { super( myORB ); 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) { CorbaContactInfo corbaContactInfo = (CorbaContactInfo) messageMediator.getContactInfo(); cachedTargetObject = iorToObject(corbaContactInfo.getTargetIOR()); } 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 // ClientRequestDispatcher.createRequest, v1.32 if (cachedEffectiveTargetObject == null) { CorbaContactInfo corbaContactInfo = (CorbaContactInfo) messageMediator.getContactInfo(); // REVISIT - get through chain like getLocatedIOR helper below. cachedEffectiveTargetObject = iorToObject(corbaContactInfo.getEffectiveTargetIOR()); } 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 ) { CorbaContactInfo corbaContactInfo = (CorbaContactInfo) messageMediator.getContactInfo(); cachedEffectiveProfile = corbaContactInfo.getEffectiveProfile().getIOPProfile(); } // 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -