genericpoaclientsc.java
来自「java jdk 1.4的源码」· Java 代码 · 共 481 行 · 第 1/2 页
JAVA
481 行
continueOrThrowSystemOrRemarshal( exception ); } throw (ApplicationException)exception; } else if (response.isLocationForward()) { if (orb.subcontractDebugFlag) dprint( "invoke: response is location forward" ) ; // In this case the exception is not handed to JTS sender. // Need to check spec on this! // FIX(Ram J) (04/28/2000) added setting locatedIOR. Also the // above assertion "exception is not handled to JTS sender.." // is not true anymore. The JTS sender hook is called for // every location forwarded ior if the ior is transactional. locatedIOR = response.getForwardedIOR(); // Invoke Portable Interceptors with receive_other: Exception newException = orb.invokeClientPIEndingPoint( ReplyMessage.LOCATION_FORWARD, null ); // Even if no interceptors are registered, // invokeClientPIEndingPoint will return RemarshalException // because LOCATION_FORWARD was passed in. We want to // preserve the state of the "exception" variable to be // null in this case so that the finally block works the // way it did before we introduced PI. In the case of a // SystemException, however, we do want the "exception" // variable set. if( !(newException instanceof RemarshalException) ) { exception = newException; } // If PI did not raise exception, throw Remarshal, else // throw the exception PI wants thrown. continueOrThrowSystemOrRemarshal( exception ); throw new RemarshalException(); } else if (response.isDifferentAddrDispositionRequested()) { if (orb.subcontractDebugFlag) dprint( "invoke: response is NEEDS_ADDRESSING_MODE" ) ; // set the desired target addressing disposition. addressingDisposition = response.getAddrDisposition(); // Invoke Portable Interceptors with receive_other: Exception newException = orb.invokeClientPIEndingPoint( ReplyMessage.NEEDS_ADDRESSING_MODE, null ); // Even if no interceptors are registered, // invokeClientPIEndingPoint will return RemarshalException // because NEEDS_ADDRESSING_MODE was passed in. We want to // preserve the state of the "exception" variable to be // null in this case so that the finally block works the // way it did before we introduced PI. In the case of a // SystemException, however, we do want the "exception" // variable set. if( !(newException instanceof RemarshalException) ) { exception = newException; } // If PI did not raise exception, throw Remarshal, else // throw the exception PI wants thrown. continueOrThrowSystemOrRemarshal( exception ); throw new RemarshalException(); } else /* normal response */ { if (orb.subcontractDebugFlag) dprint( "invoke: response is normal" ) ; // Invoke Portable Interceptors with receive_reply: exception = orb.invokeClientPIEndingPoint( ReplyMessage.NO_EXCEPTION, null ); // Remember: not thrown if exception is null. continueOrThrowSystemOrRemarshal( exception ); return (InputStream) response; } } 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. try { //Call JTS sender's received_reply this.releaseReply( response, request.getOperationName(), exception); } catch ( WrongTransaction ex ) { // XXX return this for deferred sends throw new NO_IMPLEMENT( com.sun.corba.se.internal.orbutil.MinorCodes.SEND_DEFERRED_NOTIMPLEMENTED, CompletionStatus.COMPLETED_MAYBE); } catch ( SystemException ex ) { throw ex; } } } // Filters the given exception into a SystemException or a // RemarshalException and throws it. Assumes the given exception is // of one of these two types. This is a utility method for // the above invoke code which must do this numerous times. // If the exception is null, no exception is thrown. // // Note that this code is duplicated in ClientDelegate.java private void continueOrThrowSystemOrRemarshal( Exception exception ) throws SystemException, RemarshalException { if( exception == null ) { // do nothing. } else if( exception instanceof RemarshalException ) { throw (RemarshalException)exception; } else { throw (SystemException)exception; } } public ServiceContexts getServiceContexts( Connection c, int requestId, String opName, boolean isOneWay, GIOPVersion gv ) { ServiceContexts scs = super.getServiceContexts( c, requestId, opName, isOneWay, gv ) ; ServiceContext txsc = null ; if (locatedIOR.isTransactional() && !isSpecialMethod(opName) && !locatedIOR.isLocal()) txsc = ((POAORB)(orb)).getTxServiceContext( requestId ) ; if (txsc != null) try { scs.put( txsc ) ; } catch (DuplicateServiceContext dsc) { // This should never happen throw new INTERNAL() ; } // call interceptor hooks if any are defined ((POAORB)orb).sendingRequestServiceContexts( scs ) ; return scs ; } // Invoked by DII layer (from RequestImpl.doInvocation()) // after unmarshaling reply and exceptions. public void releaseReply(ClientResponse resp, String method, Exception exception) throws WrongTransaction, SystemException { receivedReply(resp, method, exception); } private final boolean isTransient(int subcontractId) { // 2nd bit in subcontract id is 0 for transient case. return ((subcontractId & 2)==0); } protected IOR locate() { if ( isTransient(scid) ) // don't locate for transient objects return ior; else { ClientGIOP giop = orb.getClientGIOP(); return giop.locate(ior); } } public ServantObject servant_preinvoke(org.omg.CORBA.Object self, String operation, Class expectedType) { ServantObject servantObject = serversc.preinvoke(ior, operation, expectedType); // This is to make sure that local invocation does not result // in an infinite loop, in case servant_preinvoke cannot find // the servant Object. // To understand how this works, see the comments in // ClientDelegate.servant_preinvoke if( servantObject == null ) { isNextIsLocalValid.set( Boolean.FALSE ); } return servantObject; } public void servant_postinvoke(org.omg.CORBA.Object self, ServantObject servantobj) { serversc.postinvoke(ior, servantobj); } /** Deliver the reply transaction context and any exception to JTS. */ protected void receivedReply(ClientResponse resp, String method, Exception exception) throws WrongTransaction, SystemException { if (resp != null) { // do processing for two way calls, since // response is not null in that case // The Interceptor writer should take care // of invoking hooks in oneway case // consume any others that may be defined POAORB myorb = (POAORB) orb; ServiceContexts svcCtxList = resp.getServiceContexts(); // If handleTxServiceContext throws an exception, // old interceptor hooks are not called. This is // the way this used to work, but is probably not // optimal. if (locatedIOR.isTransactional() && !isSpecialMethod(method) && !locatedIOR.isLocal()) ((POAORB)(orb)).handleTxServiceContext( svcCtxList, exception, resp.getRequestId() ) ; // call any hooks that are defined try { myorb.receivedReplyServiceContexts(svcCtxList); } catch (Throwable ex) { ; //Do not let hook errors escape. } } } protected boolean isSpecialMethod(String method) { if (method.startsWith("_") && !method.startsWith("_get_") && !method.startsWith("_set_")) return true; else return false; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?