⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clientdelegate.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                }            }            ServiceContexts contexts =  response.getServiceContexts();            if (contexts != null) {                try {                    UEInfoServiceContext usc =			(UEInfoServiceContext)			contexts.get(UEInfoServiceContext.SERVICE_CONTEXT_ID);                    Throwable unknown = usc.getUE() ;                    UnknownException ue = new UnknownException(unknown);                    // Invoke Portable Interceptors with receive_exception:                    exception = orb.invokeClientPIEndingPoint(                        ReplyMessage.SYSTEM_EXCEPTION, ue );                    continueOrThrowSystemOrRemarshal( exception );		    throw new INTERNAL(			"Assertion failed.  exception should not be null." );                } catch (NoSuchServiceContext exc) {                    // NO-OP: handled by system exception below                }            }            // 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 is null somehow.            throw new INTERNAL(		"Assertion failed: exception should not be null." );        } else if (response.isUserException()) {            ApplicationException appException =                new ApplicationException(response.peekUserExceptionId(),                           (org.omg.CORBA.portable.InputStream)response);            // Invoke Portable Interceptors with receive_exception            // (user exception):            exception = orb.invokeClientPIEndingPoint(                ReplyMessage.USER_EXCEPTION, appException );            if( !(exception instanceof ApplicationException) ) {                continueOrThrowSystemOrRemarshal( exception );            }            throw (ApplicationException)exception;        } else if (response.isLocationForward()) {            // FIX(Ram J) (04/28/2000) added setting locatedIOR            locatedIOR = response.getForwardedIOR();            // Invoke Portable Interceptors with receive_other:	    Exception newException = orb.invokeClientPIEndingPoint(		ReplyMessage.LOCATION_FORWARD, null );            // For consistency with corresponding code in GenericPOAClientSC:	    if( !(newException instanceof RemarshalException) ) {		exception = newException;	    }            // If PI did not change exception, throw Remarshal, else            // throw the exception PI wants thrown.            if( exception != null ) {                continueOrThrowSystemOrRemarshal( exception );            }            throw new org.omg.CORBA.portable.RemarshalException();        } else if (response.isDifferentAddrDispositionRequested()) {            // set the desired target addressing disposition.            addressingDisposition = response.getAddrDisposition();            // Invoke Portable Interceptors with receive_other:	    Exception newException = orb.invokeClientPIEndingPoint(		ReplyMessage.NEEDS_ADDRESSING_MODE, null);            // For consistency with corresponding code in GenericPOAClientSC:	    if( !(newException instanceof RemarshalException) ) {		exception = newException;	    }            // If PI did not change exception, throw Remarshal, else            // throw the exception PI wants thrown.            if( exception != null ) {                continueOrThrowSystemOrRemarshal( exception );            }            throw new org.omg.CORBA.portable.RemarshalException();                    } else /* normal response */ {            // 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;        }    }    // 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 GenericPOAClientSC.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 giopVersion )    {	ServiceContexts contexts = new ServiceContexts( orb ) ;        addCodeSetServiceContext(c, contexts, giopVersion);	// ORBVersion servicecontext needs to be sent	ORBVersionServiceContext ovsc = new ORBVersionServiceContext(	                ORBVersionFactory.getORBVersion() ) ;	try {	    contexts.put( ovsc ) ;	} catch (DuplicateServiceContext dsc) {	    throw new INTERNAL() ;	}	// NOTE : We only want to send the runtime context the first time	if ((c != null) && !c.isPostInitialContexts()) {	    // Do not do c.setPostInitialContexts() here.	    // If a client interceptor send_request does a ForwardRequest	    // which ends up using the same connection then the service 	    // context would not be sent.	    SendingContextServiceContext scsc =		new SendingContextServiceContext( orb.getServantIOR() ) ; //d11638	    try {		contexts.put( scsc ) ;	    } catch (DuplicateServiceContext dsc) {		throw new INTERNAL() ;	    }	}	return contexts ;    }    public void consumeServiceContexts(ClientResponse response)    {	ServiceContexts ctxts = response.getServiceContexts();	ServiceContext sc ;        if (ctxts == null) {            return; // no service context available, return gracefully.        }	try {	    sc = ctxts.get( SendingContextServiceContext.SERVICE_CONTEXT_ID ) ;	    SendingContextServiceContext scsc =		(SendingContextServiceContext)sc ;	    IOR ior = scsc.getIOR() ;	    try {	        // set the codebase returned by the server	        if (response.getConnection() != null) {	            response.getConnection().setCodeBaseIOR(ior);	        }	    } catch (ThreadDeath td) {		throw td ;	    } catch (Throwable t) {		throw new DATA_CONVERSION( MinorCodes.BAD_STRINGIFIED_IOR,					   CompletionStatus.COMPLETED_NO);	    }	} catch (NoSuchServiceContext exc) {	    // ignore: this type not present	}	// see if the version subcontract is present, if yes, then set	// the ORBversion	try {	    sc = ctxts.get( ORBVersionServiceContext.SERVICE_CONTEXT_ID ) ;	    ORBVersionServiceContext ovsc =	       (ORBVersionServiceContext) sc;	    ORBVersion version = ovsc.getVersion();	    orb.setORBVersion( version ) ;	} catch (NoSuchServiceContext exc) {	    // ignore: this type not present            // If we were talking to Kestrel, we would have set the            // ORB version as such at invoke time after examining            // the IOR.	}    }    /*     * This is the method used by the rest of the system to     * create requests.  It is used both my streams-based stubs     * and by DII-based calls (i.e., from RequestImpl.doInvocation()     * before marshaling arguments.     */    public ClientRequest createRequest( String opName, boolean isOneWay )    {	// Create request object which is also the outputstream	ClientRequest request = null;	ClientGIOP giop = orb.getClientGIOP();	int id = giop.allocateRequestId() ;        // Initiate this request with Portable Interceptors.	// This is done here so if the following COMM_FAILURE occurs we will	// keep the PI ClientRequestInfo stack balanced.  The COMM_FAILURE	// happens before invoking starting points in getConnection so we	// don't need to invoke ending points.        orb.initiateClientPIRequest( false );	try {	    request = createRequest( locatedIOR, opName, isOneWay, id );	} catch (org.omg.CORBA.COMM_FAILURE ex) {	    if (locatedIOR == ior) {		throw ex;	    }	    // The COMM_FAILURE may have happened because the server died.	    // Try creating the request with the original IOR.	    request = createRequest(ior, opName, isOneWay, id);	}	return request;    }    /*     * This helper method actually creates the approprieate     * request object.     */    protected ClientRequest createRequest(IOR iorForThisRequest, String opName,					  boolean isOneWay, int requestId)    {	IIOPProfile iop = iorForThisRequest.getProfile();	ObjectKey  key = iop.getObjectKey();        	Connection conn = null ;	ServiceContexts svc = null ;	GIOPVersion giopVersion = 	    GIOPVersion.chooseRequestVersion(orb, iorForThisRequest);	if (iorForThisRequest.isLocal()) {	    svc = getServiceContexts( conn, requestId, opName, isOneWay, giopVersion ) ;            // Set the sources of info for the Portable Interceptors	    // ClientRequestInfo object, and invoke the client interceptor	    // starting points.  Note these 2 lines are duplicated below.	    // We explicitly pass in the effective target in	    // case it is different than the locatedIOR field.  For example,	    // in case of the COMM_FAILURE in the other createRequest().            orb.setClientPIInfo( null, this, iorForThisRequest, iop, requestId,				 opName, isOneWay, svc );            try {                orb.invokeClientPIStartingPoint();            }            catch( RemarshalException e ) {                // If this is a forward request, recursively call createRequest                // with the located IOR.                return createRequest( locatedIOR, opName, isOneWay, requestId);            }	    return new LocalClientRequestImpl(				GIOPVersion.V1_2,				(com.sun.corba.se.internal.iiop.ORB)orb, 				iorForThisRequest, this.addressingDisposition,                                 opName, isOneWay, svc, requestId);	} else {            conn = orb.getClientGIOP().getConnection(iorForThisRequest);            // Code set negotiation occurs on the first request            if (conn != null && conn.getCodeSetContext() == null)                performCodeSetNegotiation(conn, giopVersion);            	    svc = getServiceContexts( conn, requestId, opName, isOneWay, giopVersion ) ;            // Set Portable Interceptors info.  See above comment.            orb.setClientPIInfo( conn, this, iorForThisRequest, iop, requestId,				 opName, isOneWay, svc );            try {                orb.invokeClientPIStartingPoint();            }            catch( RemarshalException e ) {                // If this is a forward request, recursively call createRequest                // with the located IOR.                return createRequest( locatedIOR, opName, isOneWay, requestId);            }	    return new ClientRequestImpl(giopVersion, iorForThisRequest,                                          this.addressingDisposition,                                          opName, isOneWay, svc,					 requestId, conn);	}    }    // Invoked by DII layer (from RequestImpl.doInvocation())    // after unmarshaling reply and exceptions.    public void releaseReply(ClientResponse resp, String method,			     Exception exception)	throws WrongTransaction, SystemException    {    }    public void releaseReply(org.omg.CORBA.Object self, 			     InputStream input)    {	orb.sendCancelRequestIfFinalFragmentNotSent();        // Invoke Portable Interceptors cleanup.  This is done to handle        // exceptions during stream marshaling.  More generally, exceptions        // that occur in the ORB after send_request (which includes        // after returning from _request) before _invoke:        orb.cleanupClientPIRequest();    }    public boolean is_equivalent(org.omg.CORBA.Object obj,				 org.omg.CORBA.Object ref)    {	if ( ref == null )	    return false;	ObjectImpl oi = (ObjectImpl)ref;	ClientSubcontract del = (ClientSubcontract)oi._get_delegate();	if (del == this)	    return true;	if (!(del instanceof ClientDelegate))	    return false;	return ior.isEquivalent(del.marshal());    }    public int hash(org.omg.CORBA.Object obj, int maximum)    {	int h = this.hashCode();	if ( h > maximum )	    return 0;	return h;    }    public int hashCode()    {	// This is not synchronized since the returned value is constant	// so the overhead of synchronization is unnecessary.	if (! isCachedHashValue) {	    cachedHashValue = ior.stringify().hashCode();	    isCachedHashValue = true;	}

⌨️ 快捷键说明

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