Java Code Examples for com.sun.corba.se.impl.util.Utility#stubNameForCompiler()

The following examples show how to use com.sun.corba.se.impl.util.Utility#stubNameForCompiler() . 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
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 2
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 3
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 4
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 5
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 6
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 7
String getStubNameFor(Type type, boolean qualified) {
    String stubName;
    String className;
    if (qualified) {
        className = type.getQualifiedName();
    } else {
        className = type.getName();
    }
    if (((CompoundType)type).isCORBAObject()) {
        stubName = Utility.idlStubName(className);
    } else {
        stubName = Utility.stubNameForCompiler(className);
    }
    return stubName;
}
 
Example 8
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 9
void setStandardClassesInUse(CompoundType type,
                             boolean stub) throws IOException {

    // Reset our state...

    currentPackage = type.getPackageName();
    imports.clear();
    classesInUse.clear();
    namesInUse.clear();
    importCount = 0;
    castArray = false;

    // Add the top-level type...

    addClassInUse(type);

    // Set current class name...

    if (stub) {
        currentClass = Utility.stubNameForCompiler(type.getName());
    } else {
        currentClass = Utility.tieNameForCompiler(type.getName());
    }

    // Add current class...

    if (currentPackage == null) {
        addClassInUse(currentClass,currentClass,currentPackage);
    } else {
        addClassInUse(currentClass,(currentPackage+"."+currentClass),currentPackage);
    }

    // Add standard classes...

    addClassInUse("javax.rmi.CORBA.Util");
    addClassInUse(idRemote.toString());
    addClassInUse(idRemoteException.toString());
    addClassInUse(idOutputStream.toString());
    addClassInUse(idInputStream.toString());
    addClassInUse(idSystemException.toString());
    addClassInUse(idJavaIoSerializable.toString());
    addClassInUse(idCorbaORB.toString());
    addClassInUse(idReplyHandler.toString());

    // Add stub/tie specific imports...

    if (stub) {
        addClassInUse(stubBaseClass);
        addClassInUse("java.rmi.UnexpectedException");
        addClassInUse(idRemarshalException.toString());
        addClassInUse(idApplicationException.toString());
        if (localStubs) {
            addClassInUse("org.omg.CORBA.portable.ServantObject");
        }
    } else {
        addClassInUse(type);
        addClassInUse(tieBaseClass);
        addClassInUse(idTieInterface.toString());
        addClassInUse(idBadMethodException.toString());
        addClassInUse(idPortableUnknownException.toString());
        addClassInUse(idJavaLangThrowable.toString());
    }
}
 
Example 10
void setStandardClassesInUse(CompoundType type,
                             boolean stub) throws IOException {

    // Reset our state...

    currentPackage = type.getPackageName();
    imports.clear();
    classesInUse.clear();
    namesInUse.clear();
    importCount = 0;
    castArray = false;

    // Add the top-level type...

    addClassInUse(type);

    // Set current class name...

    if (stub) {
        currentClass = Utility.stubNameForCompiler(type.getName());
    } else {
        currentClass = Utility.tieNameForCompiler(type.getName());
    }

    // Add current class...

    if (currentPackage == null) {
        addClassInUse(currentClass,currentClass,currentPackage);
    } else {
        addClassInUse(currentClass,(currentPackage+"."+currentClass),currentPackage);
    }

    // Add standard classes...

    addClassInUse("javax.rmi.CORBA.Util");
    addClassInUse(idRemote.toString());
    addClassInUse(idRemoteException.toString());
    addClassInUse(idOutputStream.toString());
    addClassInUse(idInputStream.toString());
    addClassInUse(idSystemException.toString());
    addClassInUse(idJavaIoSerializable.toString());
    addClassInUse(idCorbaORB.toString());
    addClassInUse(idReplyHandler.toString());

    // Add stub/tie specific imports...

    if (stub) {
        addClassInUse(stubBaseClass);
        addClassInUse("java.rmi.UnexpectedException");
        addClassInUse(idRemarshalException.toString());
        addClassInUse(idApplicationException.toString());
        if (localStubs) {
            addClassInUse("org.omg.CORBA.portable.ServantObject");
        }
    } else {
        addClassInUse(type);
        addClassInUse(tieBaseClass);
        addClassInUse(idTieInterface.toString());
        addClassInUse(idBadMethodException.toString());
        addClassInUse(idPortableUnknownException.toString());
        addClassInUse(idJavaLangThrowable.toString());
    }
}
 
Example 11
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
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 13
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 14
void setStandardClassesInUse(CompoundType type,
                             boolean stub) throws IOException {

    // Reset our state...

    currentPackage = type.getPackageName();
    imports.clear();
    classesInUse.clear();
    namesInUse.clear();
    importCount = 0;
    castArray = false;

    // Add the top-level type...

    addClassInUse(type);

    // Set current class name...

    if (stub) {
        currentClass = Utility.stubNameForCompiler(type.getName());
    } else {
        currentClass = Utility.tieNameForCompiler(type.getName());
    }

    // Add current class...

    if (currentPackage == null) {
        addClassInUse(currentClass,currentClass,currentPackage);
    } else {
        addClassInUse(currentClass,(currentPackage+"."+currentClass),currentPackage);
    }

    // Add standard classes...

    addClassInUse("javax.rmi.CORBA.Util");
    addClassInUse(idRemote.toString());
    addClassInUse(idRemoteException.toString());
    addClassInUse(idOutputStream.toString());
    addClassInUse(idInputStream.toString());
    addClassInUse(idSystemException.toString());
    addClassInUse(idJavaIoSerializable.toString());
    addClassInUse(idCorbaORB.toString());
    addClassInUse(idReplyHandler.toString());

    // Add stub/tie specific imports...

    if (stub) {
        addClassInUse(stubBaseClass);
        addClassInUse("java.rmi.UnexpectedException");
        addClassInUse(idRemarshalException.toString());
        addClassInUse(idApplicationException.toString());
        if (localStubs) {
            addClassInUse("org.omg.CORBA.portable.ServantObject");
        }
    } else {
        addClassInUse(type);
        addClassInUse(tieBaseClass);
        addClassInUse(idTieInterface.toString());
        addClassInUse(idBadMethodException.toString());
        addClassInUse(idPortableUnknownException.toString());
        addClassInUse(idJavaLangThrowable.toString());
    }
}
 
Example 15
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
void setStandardClassesInUse(CompoundType type,
                             boolean stub) throws IOException {

    // Reset our state...

    currentPackage = type.getPackageName();
    imports.clear();
    classesInUse.clear();
    namesInUse.clear();
    importCount = 0;
    castArray = false;

    // Add the top-level type...

    addClassInUse(type);

    // Set current class name...

    if (stub) {
        currentClass = Utility.stubNameForCompiler(type.getName());
    } else {
        currentClass = Utility.tieNameForCompiler(type.getName());
    }

    // Add current class...

    if (currentPackage == null) {
        addClassInUse(currentClass,currentClass,currentPackage);
    } else {
        addClassInUse(currentClass,(currentPackage+"."+currentClass),currentPackage);
    }

    // Add standard classes...

    addClassInUse("javax.rmi.CORBA.Util");
    addClassInUse(idRemote.toString());
    addClassInUse(idRemoteException.toString());
    addClassInUse(idOutputStream.toString());
    addClassInUse(idInputStream.toString());
    addClassInUse(idSystemException.toString());
    addClassInUse(idJavaIoSerializable.toString());
    addClassInUse(idCorbaORB.toString());
    addClassInUse(idReplyHandler.toString());

    // Add stub/tie specific imports...

    if (stub) {
        addClassInUse(stubBaseClass);
        addClassInUse("java.rmi.UnexpectedException");
        addClassInUse(idRemarshalException.toString());
        addClassInUse(idApplicationException.toString());
        if (localStubs) {
            addClassInUse("org.omg.CORBA.portable.ServantObject");
        }
    } else {
        addClassInUse(type);
        addClassInUse(tieBaseClass);
        addClassInUse(idTieInterface.toString());
        addClassInUse(idBadMethodException.toString());
        addClassInUse(idPortableUnknownException.toString());
        addClassInUse(idJavaLangThrowable.toString());
    }
}
 
Example 17
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 18
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 19
void setStandardClassesInUse(CompoundType type,
                             boolean stub) throws IOException {

    // Reset our state...

    currentPackage = type.getPackageName();
    imports.clear();
    classesInUse.clear();
    namesInUse.clear();
    importCount = 0;
    castArray = false;

    // Add the top-level type...

    addClassInUse(type);

    // Set current class name...

    if (stub) {
        currentClass = Utility.stubNameForCompiler(type.getName());
    } else {
        currentClass = Utility.tieNameForCompiler(type.getName());
    }

    // Add current class...

    if (currentPackage == null) {
        addClassInUse(currentClass,currentClass,currentPackage);
    } else {
        addClassInUse(currentClass,(currentPackage+"."+currentClass),currentPackage);
    }

    // Add standard classes...

    addClassInUse("javax.rmi.CORBA.Util");
    addClassInUse(idRemote.toString());
    addClassInUse(idRemoteException.toString());
    addClassInUse(idOutputStream.toString());
    addClassInUse(idInputStream.toString());
    addClassInUse(idSystemException.toString());
    addClassInUse(idJavaIoSerializable.toString());
    addClassInUse(idCorbaORB.toString());
    addClassInUse(idReplyHandler.toString());

    // Add stub/tie specific imports...

    if (stub) {
        addClassInUse(stubBaseClass);
        addClassInUse("java.rmi.UnexpectedException");
        addClassInUse(idRemarshalException.toString());
        addClassInUse(idApplicationException.toString());
        if (localStubs) {
            addClassInUse("org.omg.CORBA.portable.ServantObject");
        }
    } else {
        addClassInUse(type);
        addClassInUse(tieBaseClass);
        addClassInUse(idTieInterface.toString());
        addClassInUse(idBadMethodException.toString());
        addClassInUse(idPortableUnknownException.toString());
        addClassInUse(idJavaLangThrowable.toString());
    }
}
 
Example 20
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 ) ;
}