📄 clientrequestinfoimpl.java
字号:
/** * Contains the exception to be returned to the client. */ public Any received_exception (){ checkAccess( MID_RECEIVED_EXCEPTION ); if( cachedReceivedException == null ) { cachedReceivedException = exceptionToAny( exception ); } // Good citizen: In the interest of efficiency, we assume interceptors // will not modify the returned Any in any way so we need // not make a deep copy of it. return cachedReceivedException; } /** * The CORBA::RepositoryId of the exception to be returned to the client. */ public String received_exception_id (){ checkAccess( MID_RECEIVED_EXCEPTION_ID ); if( cachedReceivedExceptionId == null ) { String result = null; if( exception == null ) { // Note: exception should never be null here since we will // throw a BAD_INV_ORDER if this is not called from // receive_exception. throw wrapper.exceptionWasNull() ; } else if( exception instanceof SystemException ) { String name = exception.getClass().getName(); result = ORBUtility.repositoryIdOf(name); } else if( exception instanceof ApplicationException ) { result = ((ApplicationException)exception).getId(); } // _REVISIT_ We need to be able to handle a UserException in the // DII case. How do we extract the ID from a UserException? cachedReceivedExceptionId = result; } return cachedReceivedExceptionId; } /** * Returns the IOP::TaggedComponent with the given ID from the profile * selected for this request. IF there is more than one component for a * given component ID, it is undefined which component this operation * returns (get_effective_component should be called instead). */ public TaggedComponent get_effective_component (int id){ checkAccess( MID_GET_EFFECTIVE_COMPONENT ); return get_effective_components( id )[0]; } /** * Returns all the tagged components with the given ID from the profile * selected for this request. */ public TaggedComponent[] get_effective_components (int id){ checkAccess( MID_GET_EFFECTIVE_COMPONENTS ); Integer integerId = new Integer( id ); TaggedComponent[] result = null; boolean justCreatedCache = false; if( cachedEffectiveComponents == null ) { cachedEffectiveComponents = new HashMap(); justCreatedCache = true; } else { // Look in cache: result = (TaggedComponent[])cachedEffectiveComponents.get( integerId ); } // null could mean we cached null or not in cache. if( (result == null) && (justCreatedCache || !cachedEffectiveComponents.containsKey( integerId ) ) ) { // Not in cache. Get it from the profile: CorbaContactInfo corbaContactInfo = (CorbaContactInfo) messageMediator.getContactInfo(); IIOPProfileTemplate ptemp = (IIOPProfileTemplate)corbaContactInfo.getEffectiveProfile(). getTaggedProfileTemplate(); result = ptemp.getIOPComponents(myORB, id); cachedEffectiveComponents.put( integerId, result ); } // As per ptc/00-08-06, section 21.3.13.6., If not found, raise // BAD_PARAM with minor code INVALID_COMPONENT_ID. if( (result == null) || (result.length == 0) ) { throw stdWrapper.invalidComponentId( integerId ) ; } // Good citizen: In the interest of efficiency, we will assume // interceptors will not modify the returned TaggedCompoent[], or // the TaggedComponents inside of it. Otherwise, we would need to // clone the array and make a deep copy of its contents. return result; } /** * Returns the given policy in effect for this operation. */ public Policy get_request_policy (int type){ checkAccess( MID_GET_REQUEST_POLICY ); // _REVISIT_ Our ORB is not policy-based at this time. throw wrapper.piOrbNotPolicyBased() ; } /** * Allows interceptors to add service contexts to the request. * <p> * There is no declaration of the order of the service contexts. They * may or may not appear in the order they are added. */ public void add_request_service_context (ServiceContext service_context, boolean replace) { checkAccess( MID_ADD_REQUEST_SERVICE_CONTEXT ); if( cachedRequestServiceContexts == null ) { cachedRequestServiceContexts = new HashMap(); } addServiceContext( cachedRequestServiceContexts, messageMediator.getRequestServiceContexts(), service_context, replace ); } // NOTE: When adding a method, be sure to: // 1. Add a MID_* constant for that method // 2. Call checkAccess at the start of the method // 3. Define entries in the validCall[][] table for interception points. /* ********************************************************************** * Public RequestInfo interfaces * * These are implemented here because they have differing * implementations depending on whether this is a client or a server * request info object. **********************************************************************/ /** * See RequestInfoImpl for javadoc. */ public int request_id (){ // access is currently valid for all states: //checkAccess( MID_REQUEST_ID ); /* * NOTE: The requestId in client interceptors is the same as the * GIOP request id. This works because both interceptors and * request ids are scoped by the ORB on the client side. */ return messageMediator.getRequestId(); } /** * See RequestInfoImpl for javadoc. */ public String operation (){ // access is currently valid for all states: //checkAccess( MID_OPERATION ); return messageMediator.getOperationName(); } /** * See RequestInfoImpl for javadoc. */ public Parameter[] arguments (){ checkAccess( MID_ARGUMENTS ); if( cachedArguments == null ) { if( request == null ) { throw stdWrapper.piOperationNotSupported1() ; } // If it is DII request then get the arguments from the DII req // and convert that into parameters. cachedArguments = nvListToParameterArray( request.arguments() ); } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the Parameter[] array. We also assume // they will not change the values of the containing Anys. return cachedArguments; } /** * See RequestInfoImpl for javadoc. */ public TypeCode[] exceptions (){ checkAccess( MID_EXCEPTIONS ); if( cachedExceptions == null ) { if( request == null ) { throw stdWrapper.piOperationNotSupported2() ; } // Get the list of exceptions from DII request data, If there are // no exceptions raised then this method will return null. ExceptionList excList = request.exceptions( ); int count = excList.count(); TypeCode[] excTCList = new TypeCode[count]; try { for( int i = 0; i < count; i++ ) { excTCList[i] = excList.item( i ); } } catch( Exception e ) { throw wrapper.exceptionInExceptions( e ) ; } cachedExceptions = excTCList; } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the TypeCode[] array. We also assume // they will not change the values of the containing TypeCodes. return cachedExceptions; } /** * See RequestInfoImpl for javadoc. */ public String[] contexts (){ checkAccess( MID_CONTEXTS ); if( cachedContexts == null ) { if( request == null ) { throw stdWrapper.piOperationNotSupported3() ; } // Get the list of contexts from DII request data, If there are // no contexts then this method will return null. ContextList ctxList = request.contexts( ); int count = ctxList.count(); String[] ctxListToReturn = new String[count]; try { for( int i = 0; i < count; i++ ) { ctxListToReturn[i] = ctxList.item( i ); } } catch( Exception e ) { throw wrapper.exceptionInContexts( e ) ; } cachedContexts = ctxListToReturn; } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the String[] array. return cachedContexts; } /** * See RequestInfoImpl for javadoc. */ public String[] operation_context (){ checkAccess( MID_OPERATION_CONTEXT ); if( cachedOperationContext == null ) { if( request == null ) { throw stdWrapper.piOperationNotSupported4() ; } // Get the list of contexts from DII request data, If there are // no contexts then this method will return null. Context ctx = request.ctx( ); // _REVISIT_ The API for get_values is not compliant with the spec, // Revisit this code once it's fixed. // _REVISIT_ Our ORB doesn't support Operation Context, This code // will not be excerscised until it's supported. // The first parameter in get_values is the start_scope which // if blank makes it as a global scope. // The second parameter is op_flags which is set to RESTRICT_SCOPE // As there is only one defined in the spec. // The Third param is the pattern which is '*' requiring it to // get all the contexts. NVList nvList = ctx.get_values( "", CTX_RESTRICT_SCOPE.value,"*" ); String[] context = new String[(nvList.count() * 2) ]; if( ( nvList != null ) &&( nvList.count() != 0 ) ) { // The String[] array will contain Name and Value for each // context and hence double the size in the array. int index = 0; for( int i = 0; i < nvList.count(); i++ ) { NamedValue nv; try { nv = nvList.item( i ); } catch (Exception e ) { return (String[]) null; } context[index] = nv.name(); index++; context[index] = nv.value().extract_string(); index++; } } cachedOperationContext = context; } // Good citizen: In the interest of efficiency, we assume // interceptors will be "good citizens" in that they will not // modify the contents of the String[] array.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -