requestimpl.java
来自「java jdk 1.4的源码」· Java 代码 · 共 649 行 · 第 1/2 页
JAVA
649 行
// substitute this exception for original exception _env.exception(ex2); throw ex2; } throw ex; } OutputStream os = (OutputStream)req; // Marshal args try { for (int i=0; i<_arguments.count() ; i++) { NamedValue nv = _arguments.item(i); switch (nv.flags()) { case ARG_IN.value: nv.value().write_value(os); break; case ARG_OUT.value: break; case ARG_INOUT.value: nv.value().write_value(os); break; } } } catch ( org.omg.CORBA.Bounds ex ) { // Cannot happen since we only iterate till _arguments.count() } try { // this outer try block ensures we do a req.completeRequest. // Invoke try { resp = delegate.invoke(req); } catch (SystemException ex) { // Pass SystemException through Portable Interceptors' // ending points, and then // set the SystemException in the env and rethrow it. exception = _orb.invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, ex ); continueOrThrowSystemOrRemarshal( exception ); // Note: We should never need to execute this line, // but we should assert in case exception was set to null // somehow. throw new INTERNAL( "Assertion failed: exception should not be null ." ); } if (_isOneWay) { // Invoke Portable Interceptors with receive_other exception = _orb.invokeClientPIEndingPoint( ReplyMessage.NO_EXCEPTION, exception ); continueOrThrowSystemOrRemarshal( exception ); return; } // Process reply InputStream is = (InputStream) resp; if (resp.isSystemException()) { // Unmarshal the SystemException, set it in the env and throw it. SystemException se = resp.getSystemException(); boolean doRemarshal = false; // FIX(Ram J) (05/01/2000) added locatedIOR = ior // and retry the request from root ior, // if system exception is COMM_FAILURE. // WARNING: There is a risk of infinite loopback // if the requests on location forwarded ior result in // system exception (COMM_FAILURE) if (se instanceof org.omg.CORBA.COMM_FAILURE && se.completed == CompletionStatus.COMPLETED_NO) { if (delegate.locatedIOR != delegate.ior) { delegate.locatedIOR = delegate.ior; // retry from root ior doRemarshal = true; } } if (se.minor == MinorCodes.CONN_CLOSE_REBIND && (se instanceof org.omg.CORBA.COMM_FAILURE)) { doRemarshal = true; } if (doRemarshal) { // Invoke Portable Interceptors with receive_exception: exception = _orb.invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, se ); // If PI did not change the exception, handle // COMM_FAILURE by recursively calling doInvocation. // Otherwise, throw the exception PI wants thrown. if( se == exception ) { doInvocation(); } else { continueOrThrowSystemOrRemarshal( exception ); throw new INTERNAL( "Assertion failed in RequestImpl. " + "exception should not be null." ); } return; } // Invoke Portable Interceptors with receive_exception. exception = _orb.invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, se ); continueOrThrowSystemOrRemarshal( exception ); // Note: We should never need to execute this line, but // we should assert in case exception was set to null somehow throw new INTERNAL( "Assertion failed in RequestImpl: " + "exception should not be null." ); } else if (resp.isUserException()) { // Peek exception's repository id String exid = resp.peekUserExceptionId(); try { // Find the typecode for the exception for (int i=0; i<_exceptions.count() ; i++) { TypeCode tc = _exceptions.item(i); if ( tc.id().equals(exid) ) { // Since we dont have the actual user exception // class, the spec says we have to create an // UnknownUserException and put it in the // environment. Any eany = _orb.create_any(); eany.read_value(is, (TypeCode)tc); exception = new UnknownUserException(eany); // _REVISIT_ Understand why this is // UnknownUserException. // Invoke Portable Interceptors with // receive_exception (user exception) Exception newException = _orb.invokeClientPIEndingPoint( ReplyMessage.USER_EXCEPTION, exception ); // Note that continueOrThrowSystemOrRemarshal // will not call _env.exception in the case of // a UserException. We must do so explicitly here. _env.exception(newException); if( exception != newException ) { exception = newException; continueOrThrowSystemOrRemarshal( exception ); } return; } } } catch (Exception b) { // Only exceptions to be caught are Bounds and BadKind. // Both cannot happen here. } // must be a truly unknown exception SystemException u = new UNKNOWN(MinorCodes.UNKNOWN_CORBA_EXC, CompletionStatus.COMPLETED_MAYBE); // Invoke Portable Interceptors with receive_exception: exception = _orb.invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION, u ); continueOrThrowSystemOrRemarshal( exception ); // Note: We should never need to execute this line, but // we should assert in case exception was set to null somehow. throw new INTERNAL( "Assertion failed in RequestImpl : " + "exception should not be null." ); } else if (resp.isLocationForward()) { // FIXED(Ram J) (05/01/2000) added setting delegate.locatedIOR // and reinvoking. delegate.locatedIOR = resp.getForwardedIOR(); // Invoke Portable Interceptors with receive_other: exception = _orb.invokeClientPIEndingPoint( ReplyMessage.LOCATION_FORWARD, null ); // If PI did not raise exception, invoke again. Otherwise // throw the exception PI wants thrown. if( exception == null ) { doInvocation(); // invoke again. } else { continueOrThrowSystemOrRemarshal( exception ); } return; /* // Location forwards are handled internally in the subcontract. throw new INTERNAL(MinorCodes.LOCATIONFORWARD_ERROR, CompletionStatus.COMPLETED_NO); */ } else if (resp.isDifferentAddrDispositionRequested()) { // set the desired target addressing disposition. delegate.addressingDisposition = resp.getAddrDisposition(); // Invoke Portable Interceptors with receive_other: exception = _orb.invokeClientPIEndingPoint( ReplyMessage.NEEDS_ADDRESSING_MODE, null); // If PI did not raise exception, invoke again. Otherwise // throw the exception PI wants thrown. if( exception == null ) { doInvocation(); // invoke again. } else { continueOrThrowSystemOrRemarshal( exception ); } return; } else { // normal return // Unmarshal return args unmarshalParams(is); // Invoke Portable Interceptors with receive_reply: exception = _orb.invokeClientPIEndingPoint( ReplyMessage.NO_EXCEPTION, null ); // Remember: not thrown if exception is null. continueOrThrowSystemOrRemarshal( exception ); } } finally { // _REVISIT_ PI Note: Any exceptions in the following try // block happen after PI endpoint has already run so they are not // reported to interceptors. // Note that changes to this try block should be synchronized with // the identical try block above. try { _orb.sendCancelRequestIfFinalFragmentNotSent(); // REVISIT: Talk to sanjeevk and verify if this signature of // is releaseReply is important to DII. Can we just use one // releaseReply in ClientDelegate, instead of two? // _REVISIT_ See above revisit for same // cleanupClientPIRequest call. // Invoke Portable Interceptors cleanup. This is done to // handle exceptions during stream marshalling. _orb.cleanupClientPIRequest(); delegate.releaseReply(resp, _opName, exception); } catch ( WrongTransaction ex ) { // XXX return this for deferred sends throw new NO_IMPLEMENT(MinorCodes.SEND_DEFERRED_NOTIMPLEMENTED, CompletionStatus.COMPLETED_MAYBE); } catch ( SystemException ex ) { // substitute this exception for original exception _env.exception(ex); throw ex; } } } // Filters the given exception into a SystemException and throws it. // If this is a RemarshalException, handle it by recursively calling // doInvocation(). This method assumes the given exception is a // SystemException or a RemarhsalException. // // If this is a SystemException, call _env.exception( exception ) so that // it is set in the environment. // // This is a utility method for the above doInvocation() code which must // do this numerous times. If the exception is null, no exception is // thrown. // // Note that this code is essentially the same as in ClientDelegate.java // or GenericPOAClientSC.java // private void continueOrThrowSystemOrRemarshal( Exception exception ) throws SystemException { if( exception == null ) { // do nothing. } else if( exception instanceof RemarshalException ) { // invoke again: doInvocation(); } else { _env.exception( exception ); throw (SystemException)exception; } } protected void unmarshalParams(InputStream is) { // First unmarshal the return value if it is not void if ( _result != null ) { Any returnAny = _result.value(); TypeCode returnType = returnAny.type(); if ( returnType.kind().value() != TCKind._tk_void ) returnAny.read_value(is, returnType); } // Now unmarshal the out/inout args try { for ( int i=0; i<_arguments.count() ; i++) { NamedValue nv = _arguments.item(i); switch( nv.flags() ) { case ARG_IN.value: break; case ARG_OUT.value: case ARG_INOUT.value: Any any = nv.value(); any.read_value(is, any.type()); break; } } } catch ( org.omg.CORBA.Bounds ex ) { // Cannot happen since we only iterate till _arguments.count() } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?