Java Code Examples for com.sun.corba.se.spi.presentation.rmi.PresentationManager#StubFactory

The following examples show how to use com.sun.corba.se.spi.presentation.rmi.PresentationManager#StubFactory . 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: StubFactoryFactoryDynamicBase.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
 
Example 2
Source File: StubFactoryFactoryDynamicBase.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
 
Example 3
Source File: StubFactoryFactoryProxyImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public PresentationManager.StubFactory makeDynamicStubFactory(
    PresentationManager pm, final PresentationManager.ClassData classData,
    final ClassLoader classLoader )
{
    return AccessController
            .doPrivileged(new PrivilegedAction<StubFactoryProxyImpl>() {
                @Override
                public StubFactoryProxyImpl run() {
                    return new StubFactoryProxyImpl(classData, classLoader);
                }
            });
}
 
Example 4
Source File: StubFactoryFactoryDynamicBase.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
 
Example 5
Source File: StubFactoryFactoryProxyImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public PresentationManager.StubFactory makeDynamicStubFactory(
    PresentationManager pm, final PresentationManager.ClassData classData,
    final ClassLoader classLoader )
{
    return AccessController
            .doPrivileged(new PrivilegedAction<StubFactoryProxyImpl>() {
                @Override
                public StubFactoryProxyImpl run() {
                    return new StubFactoryProxyImpl(classData, classLoader);
                }
            });
}
 
Example 6
Source File: StubFactoryFactoryDynamicBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase,
    Class expectedClass, ClassLoader classLoader)
{
    Class cls = null ;

    try {
        cls = Util.loadClass( className, remoteCodeBase, classLoader ) ;
    } catch (ClassNotFoundException exc) {
        throw wrapper.classNotFound3(
            CompletionStatus.COMPLETED_MAYBE, exc, className ) ;
    }

    PresentationManager pm = ORB.getPresentationManager() ;

    if (IDLEntity.class.isAssignableFrom( cls ) &&
        !Remote.class.isAssignableFrom( cls )) {
        // IDL stubs must always use static factories.
        PresentationManager.StubFactoryFactory sff =
            pm.getStubFactoryFactory( false ) ;
        PresentationManager.StubFactory sf =
            sff.createStubFactory( className, true, remoteCodeBase,
                expectedClass, classLoader ) ;
        return sf ;
    } else {
        PresentationManager.ClassData classData = pm.getClassData( cls ) ;
        return makeDynamicStubFactory( pm, classData, classLoader ) ;
    }
}
 
Example 7
Source File: StubFactoryFactoryProxyImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public PresentationManager.StubFactory makeDynamicStubFactory(
    PresentationManager pm, final PresentationManager.ClassData classData,
    final ClassLoader classLoader )
{
    return AccessController
            .doPrivileged(new PrivilegedAction<StubFactoryProxyImpl>() {
                @Override
                public StubFactoryProxyImpl run() {
                    return new StubFactoryProxyImpl(classData, classLoader);
                }
            });
}
 
Example 8
Source File: CDRInputStream_1_0.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public org.omg.CORBA.Object read_Object(Class clz)
{
    // In any case, we must first read the IOR.
    IOR ior = IORFactories.makeIOR(parent) ;
    if (ior.isNil()) {
        return null ;
    }

    PresentationManager.StubFactoryFactory sff = ORB.getStubFactoryFactory() ;
    String codeBase = ior.getProfile().getCodebase() ;
    PresentationManager.StubFactory stubFactory = null ;

    if (clz == null) {
        RepositoryId rid = RepositoryId.cache.getId( ior.getTypeId() ) ;
        String className = rid.getClassName() ;
        orb.validateIORClass(className);
        boolean isIDLInterface = rid.isIDLType() ;

        if (className == null || className.equals( "" ))
            stubFactory = null ;
        else
            try {
                stubFactory = sff.createStubFactory( className,
                    isIDLInterface, codeBase, (Class)null,
                    (ClassLoader)null );
            } catch (Exception exc) {
                // Could not create stubFactory, so use null.
                // XXX stubFactory handling is still too complex:
                // Can we resolve the stubFactory question once in
                // a single place?
                stubFactory = null ;
            }
    } else if (StubAdapter.isStubClass( clz )) {
        stubFactory = PresentationDefaults.makeStaticStubFactory(
            clz ) ;
    } else {
        // clz is an interface class
        boolean isIDL = IDLEntity.class.isAssignableFrom( clz ) ;
        stubFactory = sff.createStubFactory( clz.getName(),
            isIDL, codeBase, clz, clz.getClassLoader() ) ;
    }
    return internalIORToObject( ior, stubFactory, orb ) ;
}
 
Example 9
Source File: PresentationDefaults.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public static PresentationManager.StubFactory makeStaticStubFactory(
    Class stubClass )
{
    return new StubFactoryStaticImpl( stubClass ) ;
}
 
Example 10
Source File: PresentationDefaults.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public static PresentationManager.StubFactory makeStaticStubFactory(
    Class stubClass )
{
    return new StubFactoryStaticImpl( stubClass ) ;
}
 
Example 11
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example 12
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 13
Source File: IDLJavaSerializationInputStream.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public org.omg.CORBA.Object read_Object(java.lang.Class clz) {

        // In any case, we must first read the IOR.
        IOR ior = IORFactories.makeIOR(parent) ;
        if (ior.isNil()) {
            return null;
        }

        PresentationManager.StubFactoryFactory sff =
            ORB.getStubFactoryFactory();
        String codeBase = ior.getProfile().getCodebase();
        PresentationManager.StubFactory stubFactory = null;

        if (clz == null) {
            RepositoryId rid = RepositoryId.cache.getId(ior.getTypeId() );
            String className = rid.getClassName();
            boolean isIDLInterface = rid.isIDLType();

            if (className == null || className.equals( "" )) {
                stubFactory = null;
            } else {
                try {
                    stubFactory = sff.createStubFactory(className,
                        isIDLInterface, codeBase, (Class) null,
                        (ClassLoader) null);
                } catch (Exception exc) {
                    // Could not create stubFactory, so use null.
                    // XXX stubFactory handling is still too complex:
                    // Can we resolve the stubFactory question once in
                    // a single place?
                    stubFactory = null ;
                }
            }
        } else if (StubAdapter.isStubClass(clz)) {
            stubFactory = PresentationDefaults.makeStaticStubFactory(clz);
        } else {
            // clz is an interface class
            boolean isIDL = IDLEntity.class.isAssignableFrom(clz);

            stubFactory = sff.createStubFactory(
                 clz.getName(), isIDL, codeBase, clz, clz.getClassLoader());
        }

        return CDRInputStream_1_0.internalIORToObject(ior, stubFactory, orb);
    }
 
Example 14
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 15
Source File: StubFactoryFactoryStaticImpl.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example 16
Source File: StubFactoryFactoryStaticImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public PresentationManager.StubFactory createStubFactory(
    String className, boolean isIDLStub, String remoteCodeBase, Class
    expectedClass, ClassLoader classLoader)
{
    String stubName = null ;

    if (isIDLStub)
        stubName = Utility.idlStubName( className ) ;
    else
        stubName = Utility.stubNameForCompiler( className ) ;

    ClassLoader expectedTypeClassLoader =
        (expectedClass == null ? classLoader :
        expectedClass.getClassLoader());

    // The old code was optimized to try to guess which way to load classes
    // first.  The real stub class name could either be className or
    // "org.omg.stub." + className.  We will compute this as follows:
    // If stubName starts with a "forbidden" package, try the prefixed
    // version first, otherwise try the non-prefixed version first.
    // In any case, try both forms if necessary.

    String firstStubName = stubName ;
    String secondStubName = stubName ;

    if (PackagePrefixChecker.hasOffendingPrefix(stubName))
        firstStubName = PackagePrefixChecker.packagePrefix() + stubName ;
    else
        secondStubName = PackagePrefixChecker.packagePrefix() + stubName ;

    Class clz = null;

    try {
        clz = Util.loadClass( firstStubName, remoteCodeBase,
            expectedTypeClassLoader ) ;
    } catch (ClassNotFoundException e1) {
        // log only at FINE level
        wrapper.classNotFound1( CompletionStatus.COMPLETED_MAYBE,
            e1, firstStubName ) ;
        try {
            clz = Util.loadClass( secondStubName, remoteCodeBase,
                expectedTypeClassLoader ) ;
        } catch (ClassNotFoundException e2) {
            throw wrapper.classNotFound2(
                CompletionStatus.COMPLETED_MAYBE, e2, secondStubName ) ;
        }
    }

    // XXX Is this step necessary, or should the Util.loadClass
    // algorithm always produce a valid class if the setup is correct?
    // Does the OMG standard algorithm need to be changed to include
    // this step?
    if ((clz == null) ||
        ((expectedClass != null) && !expectedClass.isAssignableFrom(clz))) {
        try {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl == null)
                cl = ClassLoader.getSystemClassLoader();

            clz = cl.loadClass(className);
        } catch (Exception exc) {
            // XXX make this a system exception
            IllegalStateException ise = new IllegalStateException(
                "Could not load class " + stubName ) ;
            ise.initCause( exc ) ;
            throw ise ;
        }
    }

    return new StubFactoryStaticImpl( clz ) ;
}
 
Example 17
Source File: Utility.java    From jdk1.8-source-analysis with 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 18
Source File: CDRInputStream_1_0.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public org.omg.CORBA.Object read_Object(Class clz)
{
    // In any case, we must first read the IOR.
    IOR ior = IORFactories.makeIOR(parent) ;
    if (ior.isNil())
        return null ;

    PresentationManager.StubFactoryFactory sff = ORB.getStubFactoryFactory() ;
    String codeBase = ior.getProfile().getCodebase() ;
    PresentationManager.StubFactory stubFactory = null ;

    if (clz == null) {
        RepositoryId rid = RepositoryId.cache.getId( ior.getTypeId() ) ;
        String className = rid.getClassName() ;
        boolean isIDLInterface = rid.isIDLType() ;

        if (className == null || className.equals( "" ))
            stubFactory = null ;
        else
            try {
                stubFactory = sff.createStubFactory( className,
                    isIDLInterface, codeBase, (Class)null,
                    (ClassLoader)null );
            } catch (Exception exc) {
                // Could not create stubFactory, so use null.
                // XXX stubFactory handling is still too complex:
                // Can we resolve the stubFactory question once in
                // a single place?
                stubFactory = null ;
            }
    } else if (StubAdapter.isStubClass( clz )) {
        stubFactory = PresentationDefaults.makeStaticStubFactory(
            clz ) ;
    } else {
        // clz is an interface class
        boolean isIDL = IDLEntity.class.isAssignableFrom( clz ) ;

        stubFactory = sff.createStubFactory( clz.getName(),
            isIDL, codeBase, clz, clz.getClassLoader() ) ;
    }

    return internalIORToObject( ior, stubFactory, orb ) ;
}
 
Example 19
Source File: CDRInputStream_1_0.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public org.omg.CORBA.Object read_Object(Class clz)
{
    // In any case, we must first read the IOR.
    IOR ior = IORFactories.makeIOR(parent) ;
    if (ior.isNil()) {
        return null ;
    }

    PresentationManager.StubFactoryFactory sff = ORB.getStubFactoryFactory() ;
    String codeBase = ior.getProfile().getCodebase() ;
    PresentationManager.StubFactory stubFactory = null ;

    if (clz == null) {
        RepositoryId rid = RepositoryId.cache.getId( ior.getTypeId() ) ;
        String className = rid.getClassName() ;
        orb.validateIORClass(className);
        boolean isIDLInterface = rid.isIDLType() ;

        if (className == null || className.equals( "" ))
            stubFactory = null ;
        else
            try {
                stubFactory = sff.createStubFactory( className,
                    isIDLInterface, codeBase, (Class)null,
                    (ClassLoader)null );
            } catch (Exception exc) {
                // Could not create stubFactory, so use null.
                // XXX stubFactory handling is still too complex:
                // Can we resolve the stubFactory question once in
                // a single place?
                stubFactory = null ;
            }
    } else if (StubAdapter.isStubClass( clz )) {
        stubFactory = PresentationDefaults.makeStaticStubFactory(
            clz ) ;
    } else {
        // clz is an interface class
        boolean isIDL = IDLEntity.class.isAssignableFrom( clz ) ;
        stubFactory = sff.createStubFactory( clz.getName(),
            isIDL, codeBase, clz, clz.getClassLoader() ) ;
    }
    return internalIORToObject( ior, stubFactory, orb ) ;
}
 
Example 20
Source File: IDLJavaSerializationInputStream.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public org.omg.CORBA.Object read_Object(java.lang.Class clz) {

        // In any case, we must first read the IOR.
        IOR ior = IORFactories.makeIOR(parent) ;
        if (ior.isNil()) {
            return null;
        }

        PresentationManager.StubFactoryFactory sff =
            ORB.getStubFactoryFactory();
        String codeBase = ior.getProfile().getCodebase();
        PresentationManager.StubFactory stubFactory = null;

        if (clz == null) {
            RepositoryId rid = RepositoryId.cache.getId(ior.getTypeId() );
            String className = rid.getClassName();
            boolean isIDLInterface = rid.isIDLType();

            if (className == null || className.equals( "" )) {
                stubFactory = null;
            } else {
                try {
                    stubFactory = sff.createStubFactory(className,
                        isIDLInterface, codeBase, (Class) null,
                        (ClassLoader) null);
                } catch (Exception exc) {
                    // Could not create stubFactory, so use null.
                    // XXX stubFactory handling is still too complex:
                    // Can we resolve the stubFactory question once in
                    // a single place?
                    stubFactory = null ;
                }
            }
        } else if (StubAdapter.isStubClass(clz)) {
            stubFactory = PresentationDefaults.makeStaticStubFactory(clz);
        } else {
            // clz is an interface class
            boolean isIDL = IDLEntity.class.isAssignableFrom(clz);

            stubFactory = sff.createStubFactory(
                 clz.getName(), isIDL, codeBase, clz, clz.getClassLoader());
        }

        return CDRInputStream_1_0.internalIORToObject(ior, stubFactory, orb);
    }