piorb.java

来自「java jdk 1.4的源码」· Java 代码 · 共 1,284 行 · 第 1/4 页

JAVA
1,284
字号
     * time.     */    final protected void cleanupClientPIRequest() {	if( !hasClientInterceptors ) return;        if( !isClientPIEnabledForThisThread() ) return;        ClientRequestInfoImpl info = peekClientRequestInfoImplStack();                // If the replyStatus has not yet been set, this is an indication        // that the ORB threw an exception before we had a chance to        // invoke the client interceptor ending points.        //        // _REVISIT_ We cannot handle any exceptions or ForwardRequests        // flagged by the ending points here because there is no way        // to gracefully handle this in any of the calling code.          // This is a rare corner case, so we will ignore this for now.        short replyStatus = info.getReplyStatus();        if( replyStatus == info.UNINITIALIZED ) {            invokeClientPIEndingPoint(                 ReplyMessage.SYSTEM_EXCEPTION,                new UNKNOWN( "Problem between _request and _invoke.",			     MinorCodes.UNKNOWN_REQUEST_INVOKE, 			     CompletionStatus.COMPLETED_MAYBE ) );        }                // Decrement entry count, and if it is zero, pop it from the stack.        info.decrementEntryCount();        if( info.getEntryCount() == 0 ) {	    RequestInfoStack infoStack = 		(RequestInfoStack)threadLocalClientRequestInfoStack.get();            infoStack.pop();        }    }        /**     * Overridden from corba.ORB.     * Notifies PI of the information for client-side interceptors.       * PI will use this information as a source of information for the      * ClientRequestInfo object.     */    final protected void setClientPIInfo( Connection connection,				    ClientDelegate delegate,                                     IOR effectiveTarget,                                    IIOPProfile profile,                                     int requestId,                                    String opName,                                    boolean isOneWay,                                    ServiceContexts svc )     {	if( !hasClientInterceptors ) return;        if( !isClientPIEnabledForThisThread() ) return;                peekClientRequestInfoImplStack().setInfo(            connection, delegate, effectiveTarget, profile,	    requestId, opName, isOneWay, svc );    }        /**     * Overridden from corba.ORB.     * Notifies PI of additional information for client-side interceptors.     * PI will use this information as a source of information for the     * ClientRequestInfo object.     */    final protected void setClientPIInfo( ClientResponse response ) {	if( !hasClientInterceptors ) return;        if( !isClientPIEnabledForThisThread() ) return;                peekClientRequestInfoImplStack().setInfo( response );    }    /**     * Overridden from corba.ORB.     * Notifies PI of additional information for client-side      * interceptors.  PI will use this information as a source of information      * for the ClientRequestInfo object.     */    final protected void setClientPIInfo( RequestImpl requestImpl ) {	if( !hasClientInterceptors ) return;        if( !isClientPIEnabledForThisThread() ) return;                peekClientRequestInfoImplStack().setDIIRequest( requestImpl );    }    final protected void sendCancelRequestIfFinalFragmentNotSent()    {	// The stack only has something in it if interceptors are registered.	if( !hasClientInterceptors ) return;        if( !isClientPIEnabledForThisThread() ) return;        ClientRequestInfoImpl info = peekClientRequestInfoImplStack();	int requestID = info.request_id();	IIOPConnection connection = (IIOPConnection) info.connection();	IIOPOutputStream existingOutputStream = null;	if (connection != null) {	    // If it is a colocated request the connection will be null.	    // We do not (and cannot) fragment on colocated requests.	    existingOutputStream =		connection.getIdToFragmentedOutputStreamEntry(requestID);	    if (existingOutputStream != null) {		try {		    connection.sendCancelRequestWithLock(	                existingOutputStream.getMessage().getGIOPVersion(),			requestID);		} catch (IOException e) {		    // REVISIT: put in logging here.		    // REVISIT: we could attempt to send a final incomplete		    // fragment in this case.		    throw new COMM_FAILURE(                        e.getClass().getName(),                        MinorCodes.IOEXCEPTION_DURING_CANCEL_REQUEST,			CompletionStatus.COMPLETED_MAYBE);		} finally {		    connection			.removeIdToFragmentedOutputStreamEntry(requestID);		    // Since we canceled the request we remove the out		    // call descriptor too, since the client thread will never		    // be waiting for a reply.		    connection.removeOutCallDescriptor(requestID);		}	    }	}    }        /*     *****************     * Server PI hooks     *****************/        /**     * Overridden from corba.ORB.     * Called when the appropriate server starting interception point is     * to be invoked for all appropriate server-side request interceptors.     */    final protected void invokeServerPIStartingPoint()         throws InternalRuntimeForwardRequest    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        interceptorInvoker.invokeServerInterceptorStartingPoint( info );	// Handle SystemException or ForwardRequest:	serverPIHandleExceptions( info );    }        /**     * Overridden from corba.ORB.     * Called when the appropriate server intermediate interception point is     * to be invoked for all appropriate server-side request interceptors.     */    final protected void invokeServerPIIntermediatePoint()         throws InternalRuntimeForwardRequest    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        interceptorInvoker.invokeServerInterceptorIntermediatePoint( info );                // Clear servant from info object so that the user has control over        // its lifetime:        info.releaseServant();	// Handle SystemException or ForwardRequest:	serverPIHandleExceptions( info );    }        /**     * Overridden from corba.ORB.     * Called when the appropriate server ending interception point is     * to be invoked for all appropriate server-side request interceptors.     */    final protected void invokeServerPIEndingPoint( ReplyMessage replyMessage ) 	throws InternalRuntimeForwardRequest    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();	// REVISIT: This needs to be done "early" for the following workaround.	info.setReplyMessage( replyMessage );	// REVISIT: This was done inside of invokeServerInterceptorEndingPoint	// but needs to be here for now.  See comment in that method for why.	info.setCurrentExecutionPoint( info.EXECUTION_POINT_ENDING );        // It is possible we might have entered this method more than        // once (e.g. if an ending point threw a SystemException, then        // a new ServerResponseImpl is created).        if( !info.getAlreadyExecuted() ) {	    int replyStatus = replyMessage.getReplyStatus();            // Translate ReplyMessage.replyStatus into PI replyStatus:            // Note: this is also an assertion to make sure a valid             // replyStatus is passed in (IndexOutOfBoundsException will be             // thrown otherwise)            short piReplyStatus =                 REPLY_MESSAGE_TO_PI_REPLY_STATUS[replyStatus];	    // Make forwarded IOR available to interceptors, if applicable:	    if( ( piReplyStatus == LOCATION_FORWARD.value ) ||		( piReplyStatus == TRANSPORT_RETRY.value ) ) 	    {		info.setForwardRequest( replyMessage.getIOR() );	    }	    // REVISIT: Do early above for now.	    // Make reply message available to interceptors:	    //info.setReplyMessage( replyMessage );            // Remember exception so we can tell if an interceptor changed it.            Exception prevException = info.getException();	    // _REVISIT_ We do not have access to the User Exception at	    // this point, so treat it as an UNKNOWN for now.	    // Note that if this is a DSI call, we do have the user exception.	    if( !info.isDynamic() && 		(piReplyStatus == USER_EXCEPTION.value) ) 	    {		info.setException( 		    new UNKNOWN( "Cannot access user exception",			     MinorCodes.UNKNOWN_USER_EXCEPTION, 			     CompletionStatus.COMPLETED_MAYBE ) );	    }                        // Invoke the ending interception points:            info.setReplyStatus( piReplyStatus );            interceptorInvoker.invokeServerInterceptorEndingPoint( info );            short newPIReplyStatus = info.getReplyStatus();            Exception newException = info.getException();                        // Check reply status.  If an interceptor threw a SystemException            // and it is different than the one that we came in with,            // rethrow it so the proper response can be constructed:            if( ( newPIReplyStatus == SYSTEM_EXCEPTION.value ) &&                ( newException != prevException ) )             {                throw (SystemException)newException;            }	    // If we are to forward the location:	    if( newPIReplyStatus == LOCATION_FORWARD.value ) {	        if( piReplyStatus != LOCATION_FORWARD.value ) {	            // Treat a ForwardRequest as an 		    // InternalRuntimeForwardRequest.                    ForwardRequest newForwardRequest = 			info.getForwardRequestException();		    throw new InternalRuntimeForwardRequest( 			newForwardRequest.forward );		}		else if( info.isForwardRequestRaisedInEnding() ) {	            // Treat a ForwardRequest by changing the IOR.                    replyMessage.setIOR( info.getForwardRequestIOR() );		}	    }        }    }        /**     * Overridden from corba.ORB.     * Notifies PI of additional information required for ServerRequestInfo.     */    final protected void setServerPIInfo( Exception exception ) {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setException( exception );    }    /**     * Overridden from corba.ORB.     * Notifies PI of additional information required for ServerRequestInfo.     */    final protected void setServerPIInfo( NVList arguments )    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setDSIArguments( arguments );    }    /**     * Overridden from corba.ORB.     * Notifies PI of additional information required for ServerRequestInfo.     */    final protected void setServerPIExceptionInfo( Any exception )    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setDSIException( exception );    }    /**     * Overridden from corba.ORB.     * Notifies PI of additional information required for ServerRequestInfo.     */    final protected void setServerPIInfo( Any result )    {	if( !hasServerInterceptors ) return;        ServerRequestInfoImpl info = peekServerRequestInfoImplStack();        info.setDSIResult( result );    }    /**     * Overridden from corba.ORB.     * Notifies PI to start a new server request and set initial     * information for server-side interceptors.     * PI will use this information as a source of information for the     * ServerRequestInfo object.     */    final protected void initializeServerPIInfo( ServerRequest request,	java.lang.Object poaimpl, byte[] objectId, byte[] adapterId )     {	if( !hasServerInterceptors ) return;        RequestInfoStack infoStack =             (RequestInfoStack)threadLocalServerRequestInfoStack.get();        ServerRequestInfoImpl info = new ServerRequestInfoImpl( this );	infoStack.push( info );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?