Java Code Examples for com.sun.corba.se.spi.presentation.rmi.StubAdapter#getDelegate()

The following examples show how to use com.sun.corba.se.spi.presentation.rmi.StubAdapter#getDelegate() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private boolean isLocal()
{
    boolean result = false ;
    Delegate delegate = StubAdapter.getDelegate( stub ) ;

    if (delegate instanceof CorbaClientDelegate) {
        CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ;
        ContactInfoList cil = cdel.getContactInfoList() ;
        if (cil instanceof CorbaContactInfoList) {
            CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
            LocalClientRequestDispatcher lcrd =
                ccil.getLocalClientRequestDispatcher() ;
            result = lcrd.useLocalInvocation( null ) ;
        }
    }

    return result ;
}
 
Example 2
private boolean isLocal()
{
    boolean result = false ;
    Delegate delegate = StubAdapter.getDelegate( stub ) ;

    if (delegate instanceof CorbaClientDelegate) {
        CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ;
        ContactInfoList cil = cdel.getContactInfoList() ;
        if (cil instanceof CorbaContactInfoList) {
            CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
            LocalClientRequestDispatcher lcrd =
                ccil.getLocalClientRequestDispatcher() ;
            result = lcrd.useLocalInvocation( null ) ;
        }
    }

    return result ;
}
 
Example 3
Source Project: hottub   File: StubIORImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
 
Example 4
/**
 * This method overrides the org.omg.CORBA.portable.Delegate.equals method,
 * and does the equality check based on IOR equality.
 */
public boolean equals(org.omg.CORBA.Object self, java.lang.Object other)
{
    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;
}
 
Example 5
/**
 * This method overrides the org.omg.CORBA.portable.Delegate.equals method,
 * and does the equality check based on IOR equality.
 */
public boolean equals(org.omg.CORBA.Object self, java.lang.Object other)
{
    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;
}
 
Example 6
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
 
Example 7
private boolean isLocal()
{
    boolean result = false ;
    Delegate delegate = StubAdapter.getDelegate( stub ) ;

    if (delegate instanceof CorbaClientDelegate) {
        CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ;
        ContactInfoList cil = cdel.getContactInfoList() ;
        if (cil instanceof CorbaContactInfoList) {
            CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
            LocalClientRequestDispatcher lcrd =
                ccil.getLocalClientRequestDispatcher() ;
            result = lcrd.useLocalInvocation( null ) ;
        }
    }

    return result ;
}
 
Example 8
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
 
Example 9
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
 
Example 10
public boolean is_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() );
}
 
Example 11
Source Project: jdk1.8-source-analysis   File: TOAImpl.java    License: Apache License 2.0 5 votes vote down vote up
public void connect( org.omg.CORBA.Object objref)
{
    // Store the objref and get a userkey allocated by the transient
    // object manager.
    byte[] key = servants.storeServant(objref, null);

    // Find out the repository ID for this objref.
    String id = StubAdapter.getTypeIds( objref )[0] ;

    // Create the new objref
    ObjectReferenceFactory orf = getCurrentFactory() ;
    org.omg.CORBA.Object obj = orf.make_object( id, key ) ;

    // Copy the delegate from the new objref to the argument
    // XXX handle the case of an attempt to connect a local object.

    org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
        obj ) ;
    CorbaContactInfoList ccil = (CorbaContactInfoList)
        ((ClientDelegate)delegate).getContactInfoList() ;
    LocalClientRequestDispatcher lcs =
        ccil.getLocalClientRequestDispatcher() ;

    if (lcs instanceof JIDLLocalCRDImpl) {
        JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
        jlcs.setServant( objref ) ;
    } else {
        throw new RuntimeException(
            "TOAImpl.connect can not be called on " + lcs ) ;
    }

    StubAdapter.setDelegate( objref, delegate ) ;
}
 
Example 12
public void connect( org.omg.CORBA.Object objref)
{
    // Store the objref and get a userkey allocated by the transient
    // object manager.
    byte[] key = servants.storeServant(objref, null);

    // Find out the repository ID for this objref.
    String id = StubAdapter.getTypeIds( objref )[0] ;

    // Create the new objref
    ObjectReferenceFactory orf = getCurrentFactory() ;
    org.omg.CORBA.Object obj = orf.make_object( id, key ) ;

    // Copy the delegate from the new objref to the argument
    // XXX handle the case of an attempt to connect a local object.

    org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
        obj ) ;
    CorbaContactInfoList ccil = (CorbaContactInfoList)
        ((ClientDelegate)delegate).getContactInfoList() ;
    LocalClientRequestDispatcher lcs =
        ccil.getLocalClientRequestDispatcher() ;

    if (lcs instanceof JIDLLocalCRDImpl) {
        JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
        jlcs.setServant( objref ) ;
    } else {
        throw new RuntimeException(
            "TOAImpl.connect can not be called on " + lcs ) ;
    }

    StubAdapter.setDelegate( objref, delegate ) ;
}
 
Example 13
public void connect( org.omg.CORBA.Object objref)
{
    // Store the objref and get a userkey allocated by the transient
    // object manager.
    byte[] key = servants.storeServant(objref, null);

    // Find out the repository ID for this objref.
    String id = StubAdapter.getTypeIds( objref )[0] ;

    // Create the new objref
    ObjectReferenceFactory orf = getCurrentFactory() ;
    org.omg.CORBA.Object obj = orf.make_object( id, key ) ;

    // Copy the delegate from the new objref to the argument
    // XXX handle the case of an attempt to connect a local object.

    org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
        obj ) ;
    CorbaContactInfoList ccil = (CorbaContactInfoList)
        ((ClientDelegate)delegate).getContactInfoList() ;
    LocalClientRequestDispatcher lcs =
        ccil.getLocalClientRequestDispatcher() ;

    if (lcs instanceof JIDLLocalCRDImpl) {
        JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
        jlcs.setServant( objref ) ;
    } else {
        throw new RuntimeException(
            "TOAImpl.connect can not be called on " + lcs ) ;
    }

    StubAdapter.setDelegate( objref, delegate ) ;
}
 
Example 14
public void connect( org.omg.CORBA.Object objref)
{
    // Store the objref and get a userkey allocated by the transient
    // object manager.
    byte[] key = servants.storeServant(objref, null);

    // Find out the repository ID for this objref.
    String id = StubAdapter.getTypeIds( objref )[0] ;

    // Create the new objref
    ObjectReferenceFactory orf = getCurrentFactory() ;
    org.omg.CORBA.Object obj = orf.make_object( id, key ) ;

    // Copy the delegate from the new objref to the argument
    // XXX handle the case of an attempt to connect a local object.

    org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate(
        obj ) ;
    CorbaContactInfoList ccil = (CorbaContactInfoList)
        ((ClientDelegate)delegate).getContactInfoList() ;
    LocalClientRequestDispatcher lcs =
        ccil.getLocalClientRequestDispatcher() ;

    if (lcs instanceof JIDLLocalCRDImpl) {
        JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
        jlcs.setServant( objref ) ;
    } else {
        throw new RuntimeException(
            "TOAImpl.connect can not be called on " + lcs ) ;
    }

    StubAdapter.setDelegate( objref, delegate ) ;
}
 
Example 15
/** This method obtains an IOR from a CORBA object reference.
* It will return null if obj is a local object, a null object,
* or an object implemented by a different ORB.  It will
* throw BAD_OPERATION if obj is an unconnected RMI-IIOP object.
* @return IOR the IOR that represents this objref.  This will
* never be null.
* @exception BAD_OPERATION (from oi._get_delegate) if obj is a
* normal objref, but does not have a delegate set.
* @exception BAD_PARAM if obj is a local object, or else was
* created by a foreign ORB.
*/
public static IOR getIOR( org.omg.CORBA.Object obj )
{
    if (obj == null)
        throw wrapper.nullObjectReference() ;

    IOR ior = null ;
    if (StubAdapter.isStub(obj)) {
        org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate(
            obj ) ;

        if (del instanceof CorbaClientDelegate) {
            CorbaClientDelegate cdel = (CorbaClientDelegate)del ;
            ContactInfoList cil = cdel.getContactInfoList() ;

            if (cil instanceof CorbaContactInfoList) {
                CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
                ior = ccil.getTargetIOR() ;
                if (ior == null)
                    throw wrapper.nullIor() ;

                return ior ;
            } else {
                // This is our code, but the ContactInfoList is not a
                // CorbaContactInfoList.  This should not happen, because
                // we are in the CORBA application of the DCSA framework.
                // This is a coding error, and thus an INTERNAL exception
                // should be thrown.
                // XXX needs minor code
                throw new INTERNAL() ;
            }
        }

        // obj is implemented by a foreign ORB, because the Delegate is not a
        // ClientDelegate.
        // XXX this case could be handled by marshalling and
        // unmarshalling.  However, object_to_string cannot be used
        // here, as it is implemented with getIOR.  Note that this
        // will require access to an ORB, so that we can create streams
        // as needed.  The ORB is available simply as io._orb().
        throw wrapper.objrefFromForeignOrb() ;
    } else
        throw wrapper.localObjectNotAllowed() ;
}
 
Example 16
Source Project: jdk1.8-source-analysis   File: Utility.java    License: Apache License 2.0 4 votes vote down vote up
public static Remote loadStub(Tie tie,
                              PresentationManager.StubFactory stubFactory,
                              String remoteCodebase,
                              boolean onlyMostDerived)
{
    StubEntry entry = null;

    // Do we already have it cached?
    synchronized (tieToStubCache) {
        Object cached = tieToStubCache.get(tie);
        if (cached == null) {
            // No, so go try to load it...
            entry = loadStubAndUpdateCache(
                    tie, stubFactory, remoteCodebase, onlyMostDerived);
        } else {
            // Yes, is it a stub?  If not, it was a miss last
            // time, so return null again...
            if (cached != CACHE_MISS) {
                // It's a stub.
                entry = (StubEntry) cached;

                // Does the cached stub meet the requirements
                // of the caller? If the caller does not require
                // the most derived stub and does not require
                // a specific stub type, we don't have to check
                // any further because the cached type is good
                // enough...
                if (!entry.mostDerived && onlyMostDerived) {
                    // We must reload because we do not have
                    // the most derived cached already...
                    // The stubFactory arg must be null here
                    // to force onlyMostDerived=true to work
                    // correctly.
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);
                } else if (stubFactory != null &&
                    !StubAdapter.getTypeIds(entry.stub)[0].equals(
                        stubFactory.getTypeIds()[0]) )
                {
                    // We do not have exactly the right stub. First, try to
                    // upgrade the cached stub by forcing it to the most
                    // derived stub...
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);

                    // If that failed, try again with the exact type
                    // we need...
                    if (entry == null) {
                        entry = loadStubAndUpdateCache(tie,stubFactory,
                                remoteCodebase,onlyMostDerived);
                    }
                } else {
                    // Use the cached stub. Is the delegate set?
                    try {
                        Delegate stubDel = StubAdapter.getDelegate(
                            entry.stub ) ;
                    } catch (Exception e2) {
                        // No, so set it if we can...
                        try {
                            Delegate del = StubAdapter.getDelegate(
                                tie ) ;
                            StubAdapter.setDelegate( entry.stub,
                                del ) ;
                        } catch (Exception e) {}
                    }
                }
            }
        }
    }

    if (entry != null) {
        return (Remote)entry.stub;
    } else {
        return null;
    }
}
 
Example 17
public static Remote loadStub(Tie tie,
                              PresentationManager.StubFactory stubFactory,
                              String remoteCodebase,
                              boolean onlyMostDerived)
{
    StubEntry entry = null;

    // Do we already have it cached?
    synchronized (tieToStubCache) {
        Object cached = tieToStubCache.get(tie);
        if (cached == null) {
            // No, so go try to load it...
            entry = loadStubAndUpdateCache(
                    tie, stubFactory, remoteCodebase, onlyMostDerived);
        } else {
            // Yes, is it a stub?  If not, it was a miss last
            // time, so return null again...
            if (cached != CACHE_MISS) {
                // It's a stub.
                entry = (StubEntry) cached;

                // Does the cached stub meet the requirements
                // of the caller? If the caller does not require
                // the most derived stub and does not require
                // a specific stub type, we don't have to check
                // any further because the cached type is good
                // enough...
                if (!entry.mostDerived && onlyMostDerived) {
                    // We must reload because we do not have
                    // the most derived cached already...
                    // The stubFactory arg must be null here
                    // to force onlyMostDerived=true to work
                    // correctly.
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);
                } else if (stubFactory != null &&
                    !StubAdapter.getTypeIds(entry.stub)[0].equals(
                        stubFactory.getTypeIds()[0]) )
                {
                    // We do not have exactly the right stub. First, try to
                    // upgrade the cached stub by forcing it to the most
                    // derived stub...
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);

                    // If that failed, try again with the exact type
                    // we need...
                    if (entry == null) {
                        entry = loadStubAndUpdateCache(tie,stubFactory,
                                remoteCodebase,onlyMostDerived);
                    }
                } else {
                    // Use the cached stub. Is the delegate set?
                    try {
                        Delegate stubDel = StubAdapter.getDelegate(
                            entry.stub ) ;
                    } catch (Exception e2) {
                        // No, so set it if we can...
                        try {
                            Delegate del = StubAdapter.getDelegate(
                                tie ) ;
                            StubAdapter.setDelegate( entry.stub,
                                del ) ;
                        } catch (Exception e) {}
                    }
                }
            }
        }
    }

    if (entry != null) {
        return (Remote)entry.stub;
    } else {
        return null;
    }
}
 
Example 18
Source Project: jdk8u60   File: Utility.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static Remote loadStub(Tie tie,
                              PresentationManager.StubFactory stubFactory,
                              String remoteCodebase,
                              boolean onlyMostDerived)
{
    StubEntry entry = null;

    // Do we already have it cached?
    synchronized (tieToStubCache) {
        Object cached = tieToStubCache.get(tie);
        if (cached == null) {
            // No, so go try to load it...
            entry = loadStubAndUpdateCache(
                    tie, stubFactory, remoteCodebase, onlyMostDerived);
        } else {
            // Yes, is it a stub?  If not, it was a miss last
            // time, so return null again...
            if (cached != CACHE_MISS) {
                // It's a stub.
                entry = (StubEntry) cached;

                // Does the cached stub meet the requirements
                // of the caller? If the caller does not require
                // the most derived stub and does not require
                // a specific stub type, we don't have to check
                // any further because the cached type is good
                // enough...
                if (!entry.mostDerived && onlyMostDerived) {
                    // We must reload because we do not have
                    // the most derived cached already...
                    // The stubFactory arg must be null here
                    // to force onlyMostDerived=true to work
                    // correctly.
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);
                } else if (stubFactory != null &&
                    !StubAdapter.getTypeIds(entry.stub)[0].equals(
                        stubFactory.getTypeIds()[0]) )
                {
                    // We do not have exactly the right stub. First, try to
                    // upgrade the cached stub by forcing it to the most
                    // derived stub...
                    entry = loadStubAndUpdateCache(tie,null,
                        remoteCodebase,true);

                    // If that failed, try again with the exact type
                    // we need...
                    if (entry == null) {
                        entry = loadStubAndUpdateCache(tie,stubFactory,
                                remoteCodebase,onlyMostDerived);
                    }
                } else {
                    // Use the cached stub. Is the delegate set?
                    try {
                        Delegate stubDel = StubAdapter.getDelegate(
                            entry.stub ) ;
                    } catch (Exception e2) {
                        // No, so set it if we can...
                        try {
                            Delegate del = StubAdapter.getDelegate(
                                tie ) ;
                            StubAdapter.setDelegate( entry.stub,
                                del ) ;
                        } catch (Exception e) {}
                    }
                }
            }
        }
    }

    if (entry != null) {
        return (Remote)entry.stub;
    } else {
        return null;
    }
}
 
Example 19
Source Project: jdk8u60   File: ORBUtility.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** This method obtains an IOR from a CORBA object reference.
* It will return null if obj is a local object, a null object,
* or an object implemented by a different ORB.  It will
* throw BAD_OPERATION if obj is an unconnected RMI-IIOP object.
* @return IOR the IOR that represents this objref.  This will
* never be null.
* @exception BAD_OPERATION (from oi._get_delegate) if obj is a
* normal objref, but does not have a delegate set.
* @exception BAD_PARAM if obj is a local object, or else was
* created by a foreign ORB.
*/
public static IOR getIOR( org.omg.CORBA.Object obj )
{
    if (obj == null)
        throw wrapper.nullObjectReference() ;

    IOR ior = null ;
    if (StubAdapter.isStub(obj)) {
        org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate(
            obj ) ;

        if (del instanceof CorbaClientDelegate) {
            CorbaClientDelegate cdel = (CorbaClientDelegate)del ;
            ContactInfoList cil = cdel.getContactInfoList() ;

            if (cil instanceof CorbaContactInfoList) {
                CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
                ior = ccil.getTargetIOR() ;
                if (ior == null)
                    throw wrapper.nullIor() ;

                return ior ;
            } else {
                // This is our code, but the ContactInfoList is not a
                // CorbaContactInfoList.  This should not happen, because
                // we are in the CORBA application of the DCSA framework.
                // This is a coding error, and thus an INTERNAL exception
                // should be thrown.
                // XXX needs minor code
                throw new INTERNAL() ;
            }
        }

        // obj is implemented by a foreign ORB, because the Delegate is not a
        // ClientDelegate.
        // XXX this case could be handled by marshalling and
        // unmarshalling.  However, object_to_string cannot be used
        // here, as it is implemented with getIOR.  Note that this
        // will require access to an ORB, so that we can create streams
        // as needed.  The ORB is available simply as io._orb().
        throw wrapper.objrefFromForeignOrb() ;
    } else
        throw wrapper.localObjectNotAllowed() ;
}
 
Example 20
/** This method obtains an IOR from a CORBA object reference.
* It will return null if obj is a local object, a null object,
* or an object implemented by a different ORB.  It will
* throw BAD_OPERATION if obj is an unconnected RMI-IIOP object.
* @return IOR the IOR that represents this objref.  This will
* never be null.
* @exception BAD_OPERATION (from oi._get_delegate) if obj is a
* normal objref, but does not have a delegate set.
* @exception BAD_PARAM if obj is a local object, or else was
* created by a foreign ORB.
*/
public static IOR getIOR( org.omg.CORBA.Object obj )
{
    if (obj == null)
        throw wrapper.nullObjectReference() ;

    IOR ior = null ;
    if (StubAdapter.isStub(obj)) {
        org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate(
            obj ) ;

        if (del instanceof CorbaClientDelegate) {
            CorbaClientDelegate cdel = (CorbaClientDelegate)del ;
            ContactInfoList cil = cdel.getContactInfoList() ;

            if (cil instanceof CorbaContactInfoList) {
                CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;
                ior = ccil.getTargetIOR() ;
                if (ior == null)
                    throw wrapper.nullIor() ;

                return ior ;
            } else {
                // This is our code, but the ContactInfoList is not a
                // CorbaContactInfoList.  This should not happen, because
                // we are in the CORBA application of the DCSA framework.
                // This is a coding error, and thus an INTERNAL exception
                // should be thrown.
                // XXX needs minor code
                throw new INTERNAL() ;
            }
        }

        // obj is implemented by a foreign ORB, because the Delegate is not a
        // ClientDelegate.
        // XXX this case could be handled by marshalling and
        // unmarshalling.  However, object_to_string cannot be used
        // here, as it is implemented with getIOR.  Note that this
        // will require access to an ORB, so that we can create streams
        // as needed.  The ORB is available simply as io._orb().
        throw wrapper.objrefFromForeignOrb() ;
    } else
        throw wrapper.localObjectNotAllowed() ;
}