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

The following examples show how to use com.sun.corba.se.spi.presentation.rmi.StubAdapter#setDelegate() . 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
Source File: ORBUtility.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** This method is used to create untyped object references.
*/
public static org.omg.CORBA.Object makeObjectReference( IOR ior )
{
    CorbaClientDelegate del = makeClientDelegate( ior ) ;
    org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;
    StubAdapter.setDelegate( objectImpl, del ) ;
    return objectImpl ;
}
 
Example 2
Source File: ORBUtility.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** This method is used to create untyped object references.
*/
public static org.omg.CORBA.Object makeObjectReference( IOR ior )
{
    CorbaClientDelegate del = makeClientDelegate( ior ) ;
    org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;
    StubAdapter.setDelegate( objectImpl, del ) ;
    return objectImpl ;
}
 
Example 3
Source File: TOAImpl.java    From openjdk-jdk9 with GNU General Public License v2.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 4
Source File: TOAImpl.java    From openjdk-8 with GNU General Public License v2.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 5
Source File: ORBUtility.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** This method is used to create untyped object references.
*/
public static org.omg.CORBA.Object makeObjectReference( IOR ior )
{
    CorbaClientDelegate del = makeClientDelegate( ior ) ;
    org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;
    StubAdapter.setDelegate( objectImpl, del ) ;
    return objectImpl ;
}
 
Example 6
Source File: TOAImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.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 7
Source File: ORBUtility.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** This method is used to create untyped object references.
*/
public static org.omg.CORBA.Object makeObjectReference( IOR ior )
{
    CorbaClientDelegate del = makeClientDelegate( ior ) ;
    org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;
    StubAdapter.setDelegate( objectImpl, del ) ;
    return objectImpl ;
}
 
Example 8
Source File: TOAImpl.java    From openjdk-jdk8u with GNU General Public License v2.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 9
Source File: TOAImpl.java    From jdk1.8-source-analysis with 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 10
Source File: TOAImpl.java    From JDKSourceCode1.8 with MIT License 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 11
Source File: TOAImpl.java    From jdk8u60 with GNU General Public License v2.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
Source File: ORBUtility.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** This method is used to create untyped object references.
*/
public static org.omg.CORBA.Object makeObjectReference( IOR ior )
{
    CorbaClientDelegate del = makeClientDelegate( ior ) ;
    org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;
    StubAdapter.setDelegate( objectImpl, del ) ;
    return objectImpl ;
}
 
Example 13
Source File: TOAImpl.java    From TencentKona-8 with GNU General Public License v2.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 14
Source File: TOAImpl.java    From hottub with GNU General Public License v2.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 15
Source File: Utility.java    From jdk8u60 with 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 16
Source File: Utility.java    From JDKSourceCode1.8 with MIT License 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
Source File: Utility.java    From openjdk-8-source with 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 18
Source File: Utility.java    From openjdk-jdk8u with 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 File: Utility.java    From TencentKona-8 with 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 20
Source File: Utility.java    From hottub with 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;
    }
}