FileDocCategorySizeDatePackage
CorbaClientDelegateImpl.javaAPI DocJava SE 5 API12959Fri Aug 26 14:54:30 BST 2005com.sun.corba.se.impl.protocol

CorbaClientDelegateImpl

public class CorbaClientDelegateImpl extends CorbaClientDelegate
author
Harold Carr

Fields Summary
private ORB
orb
private ORBUtilSystemException
wrapper
private CorbaContactInfoList
contactInfoList
Constructors Summary
public CorbaClientDelegateImpl(ORB orb, CorbaContactInfoList contactInfoList)

	this.orb = orb;
	this.wrapper = ORBUtilSystemException.get( orb,
	    CORBALogDomains.RPC_PROTOCOL ) ;
	this.contactInfoList = contactInfoList;
    
Methods Summary
public org.omg.CORBA.Requestcreate_request(org.omg.CORBA.Object obj, org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result)

	return new RequestImpl(orb, obj, ctx, operation, arg_list,
			       result, null, null);
    
public org.omg.CORBA.Requestcreate_request(org.omg.CORBA.Object obj, org.omg.CORBA.Context ctx, java.lang.String operation, org.omg.CORBA.NVList arg_list, org.omg.CORBA.NamedValue result, org.omg.CORBA.ExceptionList exclist, org.omg.CORBA.ContextList ctxlist)

	return new RequestImpl(orb, obj, ctx, operation, arg_list, result,
			       exclist, ctxlist);
    
public org.omg.CORBA.Objectduplicate(org.omg.CORBA.Object obj)

	return obj;
    
public booleanequals(org.omg.CORBA.Object self, java.lang.Object other)
This method overrides the org.omg.CORBA.portable.Delegate.equals method, and does the equality check based on IOR equality.

	if (other == null)
	    return false ;

        if (!StubAdapter.isStub(other)) {
            return false;   
        }
        
	Delegate delegate = StubAdapter.getDelegate( other ) ;
	if (delegate == null)
	    return false ;

        if (delegate instanceof CorbaClientDelegateImpl) {
            CorbaClientDelegateImpl otherDel = (CorbaClientDelegateImpl)
		delegate ;
            IOR otherIor = otherDel.contactInfoList.getTargetIOR();
            return this.contactInfoList.getTargetIOR().equals(otherIor);
        } 

	// Come here if other is not implemented by our ORB.
        return false;
    
public com.sun.corba.se.pept.broker.BrokergetBroker()

	return orb;
    
private com.sun.corba.se.pept.protocol.ClientRequestDispatchergetClientRequestDispatcher()

        return (ClientRequestDispatcher)
            ((CorbaInvocationInfo)orb.getInvocationInfo())
	    .getClientRequestDispatcher();
    
public com.sun.corba.se.pept.transport.ContactInfoListgetContactInfoList()

	return contactInfoList;
    
public java.lang.Stringget_codebase(org.omg.CORBA.Object self)

	if (contactInfoList.getTargetIOR() != null) {
	    return contactInfoList.getTargetIOR().getProfile().getCodebase();
	}
	return null;
    
public org.omg.CORBA.Objectget_interface_def(org.omg.CORBA.Object obj)

	InputStream is = null;
	// instantiate the stub
	org.omg.CORBA.Object stub = null ;

        try {
	    OutputStream os = request(null, "_interface", true);
	    is = (InputStream) invoke((org.omg.CORBA.Object)null, os);

	    org.omg.CORBA.Object objimpl = 
		(org.omg.CORBA.Object) is.read_Object();

	    // check if returned object is of correct type
	    if ( !objimpl._is_a("IDL:omg.org/CORBA/InterfaceDef:1.0") )
		throw wrapper.wrongInterfaceDef(CompletionStatus.COMPLETED_MAYBE);

	    try {
                stub = (org.omg.CORBA.Object)
                    JDKBridge.loadClass("org.omg.CORBA._InterfaceDefStub").
		        newInstance();
	    } catch (Exception ex) {
		throw wrapper.noInterfaceDefStub( ex ) ;
	    }

	    org.omg.CORBA.portable.Delegate del = 
		StubAdapter.getDelegate( objimpl ) ;
	    StubAdapter.setDelegate( stub, del ) ;
	} catch (ApplicationException e) {
	    // This cannot happen.
	    throw wrapper.applicationExceptionInSpecialMethod( e ) ;
	} catch (RemarshalException e) {
	    return get_interface_def(obj);
	} finally {
	    releaseReply((org.omg.CORBA.Object)null, (InputStream)is);
        }

	return stub;
    
public inthash(org.omg.CORBA.Object obj, int maximum)

	int h = this.hashCode();
	if ( h > maximum )
	    return 0;
	return h;
    
public inthashCode(org.omg.CORBA.Object obj)

	return this.hashCode() ;
    
public inthashCode()

	return this.contactInfoList.hashCode();
    
public org.omg.CORBA.portable.InputStreaminvoke(org.omg.CORBA.Object self, org.omg.CORBA.portable.OutputStream output)

	ClientRequestDispatcher subcontract = getClientRequestDispatcher();
	return (InputStream)
	    subcontract.marshalingComplete((Object)self, (OutputObject)output);
    
public booleanis_a(org.omg.CORBA.Object obj, java.lang.String dest)

        // dest is the typeId of the interface to compare against.
        // repositoryIds is the list of typeIds that the stub knows about.

        // First we look for an answer using local information.

        String [] repositoryIds = StubAdapter.getTypeIds( obj ) ;
        String myid = contactInfoList.getTargetIOR().getTypeId();
        if ( dest.equals(myid) ) {
            return true;
	}
        for ( int i=0; i<repositoryIds.length; i++ ) {
            if ( dest.equals(repositoryIds[i]) ) {
		return true;
	    }
	}

        // But repositoryIds may not be complete, so it may be necessary to
        // go to server.

	InputStream is = null;
        try {
            OutputStream os = request(null, "_is_a", true);
            os.write_string(dest);
            is = (InputStream) invoke((org.omg.CORBA.Object) null, os);

	    return is.read_boolean();

        } catch (ApplicationException e) {
	    // This cannot happen.
	    throw wrapper.applicationExceptionInSpecialMethod( e ) ;
	} catch (RemarshalException e) {
	    return is_a(obj, dest);
	} finally {
	    releaseReply((org.omg.CORBA.Object)null, (InputStream)is);
        }
    
public booleanis_equivalent(org.omg.CORBA.Object obj, org.omg.CORBA.Object ref)

	if ( ref == null )
	    return false;

	// If ref is a local object, it is not a Stub!
	if (!StubAdapter.isStub(ref))
	    return false ;

	Delegate del = StubAdapter.getDelegate(ref) ;
	if (del == null)
	    return false ;

	// Optimize the x.is_equivalent( x ) case
	if (del == this)
	    return true;

	// If delegate was created by a different ORB, return false
	if (!(del instanceof CorbaClientDelegateImpl))
	    return false ;

	CorbaClientDelegateImpl corbaDelegate = (CorbaClientDelegateImpl)del ;
	CorbaContactInfoList ccil = 
	    (CorbaContactInfoList)corbaDelegate.getContactInfoList() ;
	return this.contactInfoList.getTargetIOR().isEquivalent( 
	    ccil.getTargetIOR() );
    
public booleanis_local(org.omg.CORBA.Object self)
Returns true if this object is implemented by a local servant. REVISIT: locatedIOR should be replaced with a method call that returns the current IOR for this request (e.g. ContactInfoChooser).

param
self The object reference which delegated to this delegate.
return
true only if the servant incarnating this object is located in this ORB.

	// XXX this need to check isNextCallValid
        return contactInfoList.getEffectiveTargetIOR().getProfile().
	    isLocal();
    
public booleannon_existent(org.omg.CORBA.Object obj)

	InputStream is = null;
        try {
            OutputStream os = request(null, "_non_existent", true);
            is = (InputStream) invoke((org.omg.CORBA.Object)null, os);

	    return is.read_boolean();

	} catch (ApplicationException e) {
	    // This cannot happen.
	    throw wrapper.applicationExceptionInSpecialMethod( e ) ;
	} catch (RemarshalException e) {
	    return non_existent(obj);
	} finally {
	    releaseReply((org.omg.CORBA.Object)null, (InputStream)is);
        }
    
public org.omg.CORBA.ORBorb(org.omg.CORBA.Object obj)

	return this.orb;
    
public voidrelease(org.omg.CORBA.Object obj)

	// DO NOT clear out internal variables to release memory
	// This delegate may be pointed-to by other objrefs.
    
public voidreleaseReply(org.omg.CORBA.Object self, org.omg.CORBA.portable.InputStream input)

	// NOTE: InputStream may be null (e.g., exception request from PI).
	ClientRequestDispatcher subcontract = getClientRequestDispatcher();
        subcontract.endRequest(orb, self, (InputObject)input);
	orb.releaseOrDecrementInvocationInfo();
    
public org.omg.CORBA.Requestrequest(org.omg.CORBA.Object obj, java.lang.String operation)

	return new RequestImpl(orb, obj, null, operation, null, null, null,
			       null);
    
public org.omg.CORBA.portable.OutputStreamrequest(org.omg.CORBA.Object self, java.lang.String operation, boolean responseExpected)

	ClientInvocationInfo invocationInfo = 
	    orb.createOrIncrementInvocationInfo();
	Iterator contactInfoListIterator = 
	    invocationInfo.getContactInfoListIterator();
	if (contactInfoListIterator == null) {
	    contactInfoListIterator = contactInfoList.iterator();
	    invocationInfo.setContactInfoListIterator(contactInfoListIterator);
	}
	if (! contactInfoListIterator.hasNext()) {
	    throw ((CorbaContactInfoListIterator)contactInfoListIterator)
		.getFailureException();
	}
	CorbaContactInfo contactInfo = (CorbaContactInfo) contactInfoListIterator.next();
	ClientRequestDispatcher subcontract = contactInfo.getClientRequestDispatcher();
	// Remember chosen subcontract for invoke and releaseReply.
	// NOTE: This is necessary since a stream is not available in
	// releaseReply if there is a client marshaling error or an
	// error in _invoke.
	invocationInfo.setClientRequestDispatcher(subcontract);
	return (OutputStream)
	    subcontract.beginRequest(self, operation,
				     !responseExpected, contactInfo);
    
public voidservant_postinvoke(org.omg.CORBA.Object self, org.omg.CORBA.portable.ServantObject servant)

	contactInfoList.getLocalClientRequestDispatcher()
	    .servant_postinvoke(self, servant);
    
public org.omg.CORBA.portable.ServantObjectservant_preinvoke(org.omg.CORBA.Object self, java.lang.String operation, java.lang.Class expectedType)

	return
	    contactInfoList.getLocalClientRequestDispatcher()
	    .servant_preinvoke(self, operation, expectedType);
    
public java.lang.StringtoString(org.omg.CORBA.Object self)

	return contactInfoList.getTargetIOR().stringify();