📄 interceptorinvoker.java
字号:
} // Only step through the interceptors whose starting points // have successfully returned. // Unlike the previous loop, this one counts backwards for a // reason - we must execute these in the reverse order of the // starting points. for( int i = (flowStackIndex - 1); i >= 0; i-- ) { try { switch( endingPointCall ) { case ClientRequestInfoImpl.CALL_RECEIVE_REPLY: clientInterceptors[i].receive_reply( info ); break; case ClientRequestInfoImpl.CALL_RECEIVE_EXCEPTION: clientInterceptors[i].receive_exception( info ); break; case ClientRequestInfoImpl.CALL_RECEIVE_OTHER: clientInterceptors[i].receive_other( info ); break; } } catch( ForwardRequest e ) { // as per PI spec (orbos/99-12-02 sec 5.2.1.), if // interception point throws a ForwardException, // ending point call changes to receive_other. endingPointCall = ClientRequestInfoImpl.CALL_RECEIVE_OTHER; info.setEndingPointCall( endingPointCall ); info.setReplyStatus( LOCATION_FORWARD.value ); info.setForwardRequest( e ); updateClientRequestDispatcherForward( info ); } catch( SystemException e ) { // as per PI spec (orbos/99-12-02 sec 5.2.1.), if // interception point throws a SystemException, // ending point call changes to receive_exception. endingPointCall = ClientRequestInfoImpl.CALL_RECEIVE_EXCEPTION; info.setEndingPointCall( endingPointCall ); info.setReplyStatus( SYSTEM_EXCEPTION.value ); info.setException( e ); } } } finally { // See doc for setPICurrentPushed as to why this is necessary. // Check info for null in case errors happen before initiate. if (info != null && info.isPICurrentPushed()) { current.popSlotTable( ); // After the pop, original client's TSC slot table // remains avaiable via PICurrent. } } } // end enabled check } /* ********************************************************************** * Server Interceptor invocation **********************************************************************/ /** * Invokes receive_request_service_context interception points. */ void invokeServerInterceptorStartingPoint( ServerRequestInfoImpl info ) { // If invocation is not yet enabled, don't do anything. if( enabled ) { try { // Make a fresh slot table for RSC. current.pushSlotTable(); info.setSlotTable(current.getSlotTable()); // Make a fresh slot table for TSC in case // interceptors need to make out calls. current.pushSlotTable( ); info.setCurrentExecutionPoint( info.EXECUTION_POINT_STARTING ); // Get all ServerRequestInterceptors: ServerRequestInterceptor[] serverInterceptors = (ServerRequestInterceptor[])interceptorList. getInterceptors( InterceptorList.INTERCEPTOR_TYPE_SERVER ); int size = serverInterceptors.length; // We will assume that all interceptors returned successfully, // and adjust the flowStackIndex to the appropriate value if // we later discover otherwise. int flowStackIndex = size; boolean continueProcessing = true; // Currently, there is only one server-side starting point // interceptor called receive_request_service_contexts. for( int i = 0; continueProcessing && (i < size); i++ ) { try { serverInterceptors[i]. receive_request_service_contexts( info ); } catch( ForwardRequest e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a ForwardRequest, // no other Interceptors' starting points are // called and send_other is called. flowStackIndex = i; info.setForwardRequest( e ); info.setIntermediatePointCall( ServerRequestInfoImpl.CALL_INTERMEDIATE_NONE ); info.setEndingPointCall( ServerRequestInfoImpl.CALL_SEND_OTHER ); info.setReplyStatus( LOCATION_FORWARD.value ); // For some reason, using break here causes the VM on // NT to lose track of the value of flowStackIndex // after exiting the for loop. I changed this to // check a boolean value instead and it seems to work // fine. continueProcessing = false; } catch( SystemException e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a SystemException, // no other Interceptors' starting points are // called. flowStackIndex = i; info.setException( e ); info.setIntermediatePointCall( ServerRequestInfoImpl.CALL_INTERMEDIATE_NONE ); info.setEndingPointCall( ServerRequestInfoImpl.CALL_SEND_EXCEPTION ); info.setReplyStatus( SYSTEM_EXCEPTION.value ); // For some reason, using break here causes the VM on // NT to lose track of the value of flowStackIndex // after exiting the for loop. I changed this to // check a boolean value instead and it seems to // work fine. continueProcessing = false; } } // Remember where we left off in the flow stack: info.setFlowStackIndex( flowStackIndex ); } finally { // The remaining points, ServantManager and Servant // all run in the same logical thread. current.popSlotTable( ); // Now TSC and RSC are equivalent. } } // end enabled check } /** * Invokes receive_request interception points */ void invokeServerInterceptorIntermediatePoint( ServerRequestInfoImpl info ) { int intermediatePointCall = info.getIntermediatePointCall(); // If invocation is not yet enabled, don't do anything. if( enabled && ( intermediatePointCall != ServerRequestInfoImpl.CALL_INTERMEDIATE_NONE ) ) { // NOTE: do not touch the slotStack. The RSC and TSC are // equivalent at this point. info.setCurrentExecutionPoint( info.EXECUTION_POINT_INTERMEDIATE ); // Get all ServerRequestInterceptors: ServerRequestInterceptor[] serverInterceptors = (ServerRequestInterceptor[]) interceptorList.getInterceptors( InterceptorList.INTERCEPTOR_TYPE_SERVER ); int size = serverInterceptors.length; // Currently, there is only one server-side intermediate point // interceptor called receive_request. for( int i = 0; i < size; i++ ) { try { serverInterceptors[i].receive_request( info ); } catch( ForwardRequest e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a ForwardRequest, // no other Interceptors' intermediate points are // called and send_other is called. info.setForwardRequest( e ); info.setEndingPointCall( ServerRequestInfoImpl.CALL_SEND_OTHER ); info.setReplyStatus( LOCATION_FORWARD.value ); break; } catch( SystemException e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a SystemException, // no other Interceptors' starting points are // called. info.setException( e ); info.setEndingPointCall( ServerRequestInfoImpl.CALL_SEND_EXCEPTION ); info.setReplyStatus( SYSTEM_EXCEPTION.value ); break; } } } // end enabled check } /** * Invokes either send_reply, send_exception, or send_other, * depending on the value of info.getEndingPointCall() */ void invokeServerInterceptorEndingPoint( ServerRequestInfoImpl info ) { // If invocation is not yet enabled, don't do anything. if( enabled ) { try { // NOTE: do not touch the slotStack. The RSC and TSC are // equivalent at this point. // REVISIT: This is moved out to PIHandlerImpl until dispatch // path is rearchitected. It must be there so that // it always gets executed so if an interceptor raises // an exception any service contexts added in earlier points // this point get put in the exception reply (via the SC Q). //info.setCurrentExecutionPoint( info.EXECUTION_POINT_ENDING ); // Get all ServerRequestInterceptors: ServerRequestInterceptor[] serverInterceptors = (ServerRequestInterceptor[])interceptorList. getInterceptors( InterceptorList.INTERCEPTOR_TYPE_SERVER ); int flowStackIndex = info.getFlowStackIndex(); // Determine whether we are calling // send_exception, or send_other: int endingPointCall = info.getEndingPointCall(); // Only step through the interceptors whose starting points // have successfully returned. for( int i = (flowStackIndex - 1); i >= 0; i-- ) { try { switch( endingPointCall ) { case ServerRequestInfoImpl.CALL_SEND_REPLY: serverInterceptors[i].send_reply( info ); break; case ServerRequestInfoImpl.CALL_SEND_EXCEPTION: serverInterceptors[i].send_exception( info ); break; case ServerRequestInfoImpl.CALL_SEND_OTHER: serverInterceptors[i].send_other( info ); break; } } catch( ForwardRequest e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a ForwardException, // ending point call changes to receive_other. endingPointCall = ServerRequestInfoImpl.CALL_SEND_OTHER; info.setEndingPointCall( endingPointCall ); info.setForwardRequest( e ); info.setReplyStatus( LOCATION_FORWARD.value ); info.setForwardRequestRaisedInEnding(); } catch( SystemException e ) { // as per PI spec (orbos/99-12-02 sec 5.3.1.), if // interception point throws a SystemException, // ending point call changes to send_exception. endingPointCall = ServerRequestInfoImpl.CALL_SEND_EXCEPTION; info.setEndingPointCall( endingPointCall ); info.setException( e ); info.setReplyStatus( SYSTEM_EXCEPTION.value ); } } // Remember that all interceptors' starting and ending points // have already been executed so we need not do anything. info.setAlreadyExecuted( true ); } finally { // Get rid of the Server side RSC. current.popSlotTable(); } } // end enabled check } /* ********************************************************************** * Private utility methods **********************************************************************/ /** * Update the client delegate in the event of a ForwardRequest, given the * information in the passed-in info object. */ private void updateClientRequestDispatcherForward( ClientRequestInfoImpl info ) { ForwardRequest forwardRequest = info.getForwardRequestException(); // ForwardRequest may be null if the forwarded IOR is set internal // to the ClientRequestDispatcher rather than explicitly through Portable // Interceptors. In this case, we need not update the client // delegate ForwardRequest object. if( forwardRequest != null ) { org.omg.CORBA.Object object = forwardRequest.forward; // Convert the forward object into an IOR: IOR ior = ORBUtility.getIOR( object ) ; info.setLocatedIOR( ior ); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -