Java Code Examples for javax.rmi.CORBA.Util#getCodebase()

The following examples show how to use javax.rmi.CORBA.Util#getCodebase() . 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: FVDCodeBaseImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public String implementation (String x){
    try{
        // default to using the current ORB version in case the
        // vhandler is not set
        if (vhandler == null) {
            vhandler = ValueHandlerImpl.getInstance(false);
        }

        // Util.getCodebase may return null which would
        // cause a BAD_PARAM exception.
        String result = Util.getCodebase(vhandler.getClassFromType(x));
        if (result == null)
            return "";
        else
            return result;
    } catch(ClassNotFoundException cnfe){
        throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE,
            cnfe ) ;
    }
}
 
Example 2
Source File: FVDCodeBaseImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public String implementation (String x){
    try{
        // default to using the current ORB version in case the
        // vhandler is not set
        if (vhandler == null) {
            vhandler = ValueHandlerImpl.getInstance(false);
        }

        // Util.getCodebase may return null which would
        // cause a BAD_PARAM exception.
        String result = Util.getCodebase(vhandler.getClassFromType(x));
        if (result == null)
            return "";
        else
            return result;
    } catch(ClassNotFoundException cnfe){
        throw wrapper.missingLocalValueImpl( CompletionStatus.COMPLETED_MAYBE,
            cnfe ) ;
    }
}
 
Example 3
Source File: Utility.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the helper for an IDLValue
 *
 * Throws MARSHAL exception if no helper found.
 */
public static BoxedValueHelper getHelper(Class clazz, String codebase,
    String repId)
{
    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw wrapper.unableLocateValueHelper(
                CompletionStatus.COMPLETED_MAYBE);
    }

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class helperClass =
            loadClassForClass(className+"Helper", codebase, clazzLoader,
            clazz, clazzLoader);
        return (BoxedValueHelper)helperClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cnfe );
    } catch (IllegalAccessException iae) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            iae );
    } catch (InstantiationException ie) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            ie );
    } catch (ClassCastException cce) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cce );
    }
}
 
Example 4
Source File: Utility.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the helper for an IDLValue
 *
 * Throws MARSHAL exception if no helper found.
 */
public static BoxedValueHelper getHelper(Class clazz, String codebase,
    String repId)
{
    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw wrapper.unableLocateValueHelper(
                CompletionStatus.COMPLETED_MAYBE);
    }

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class helperClass =
            loadClassForClass(className+"Helper", codebase, clazzLoader,
            clazz, clazzLoader);
        return (BoxedValueHelper)helperClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cnfe );
    } catch (IllegalAccessException iae) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            iae );
    } catch (InstantiationException ie) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            ie );
    } catch (ClassCastException cce) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cce );
    }
}
 
Example 5
Source File: Utility.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the helper for an IDLValue
 *
 * Throws MARSHAL exception if no helper found.
 */
public static BoxedValueHelper getHelper(Class clazz, String codebase,
    String repId)
{
    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw wrapper.unableLocateValueHelper(
                CompletionStatus.COMPLETED_MAYBE);
    }

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class helperClass =
            loadClassForClass(className+"Helper", codebase, clazzLoader,
            clazz, clazzLoader);
        return (BoxedValueHelper)helperClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cnfe );
    } catch (IllegalAccessException iae) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            iae );
    } catch (InstantiationException ie) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            ie );
    } catch (ClassCastException cce) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cce );
    }
}
 
Example 6
Source File: Utility.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the helper for an IDLValue
 *
 * Throws MARSHAL exception if no helper found.
 */
public static BoxedValueHelper getHelper(Class clazz, String codebase,
    String repId)
{
    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw wrapper.unableLocateValueHelper(
                CompletionStatus.COMPLETED_MAYBE);
    }

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class helperClass =
            loadClassForClass(className+"Helper", codebase, clazzLoader,
            clazz, clazzLoader);
        return (BoxedValueHelper)helperClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cnfe );
    } catch (IllegalAccessException iae) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            iae );
    } catch (InstantiationException ie) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            ie );
    } catch (ClassCastException cce) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cce );
    }
}
 
Example 7
Source File: Utility.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the helper for an IDLValue
 *
 * Throws MARSHAL exception if no helper found.
 */
public static BoxedValueHelper getHelper(Class clazz, String codebase,
    String repId)
{
    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw wrapper.unableLocateValueHelper(
                CompletionStatus.COMPLETED_MAYBE);
    }

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class helperClass =
            loadClassForClass(className+"Helper", codebase, clazzLoader,
            clazz, clazzLoader);
        return (BoxedValueHelper)helperClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cnfe );
    } catch (IllegalAccessException iae) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            iae );
    } catch (InstantiationException ie) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            ie );
    } catch (ClassCastException cce) {
        throw wrapper.unableLocateValueHelper( CompletionStatus.COMPLETED_MAYBE,
            cce );
    }
}
 
Example 8
Source File: IIOPInputStream.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 9
Source File: IIOPInputStream.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 10
Source File: Utility.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the factory for an IDLValue
 *
 * Throws MARSHAL exception if no factory found.
 */
public static ValueFactory getFactory(Class clazz, String codebase,
                           ORB orb, String repId)
{
    ValueFactory factory = null;
    if ((orb != null) && (repId != null)) {
        try {
            factory = ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(
                repId);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            // Try other way
        }
    }

    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw omgWrapper.unableLocateValueFactory(
                CompletionStatus.COMPLETED_MAYBE);
    }

    // if earlier search found a non-default factory, or the same default
    // factory that loadClassForClass would return, bale out now...
    if (factory != null &&
        (!factory.getClass().getName().equals(className+"DefaultFactory") ||
         (clazz == null && codebase == null)))
        return factory;

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class factoryClass =
            loadClassForClass(className+"DefaultFactory", codebase,
            clazzLoader, clazz, clazzLoader);
        return (ValueFactory)factoryClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cnfe);
    } catch (IllegalAccessException iae) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, iae);
    } catch (InstantiationException ie) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, ie);
    } catch (ClassCastException cce) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cce);
    }
}
 
Example 11
Source File: Utility.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the factory for an IDLValue
 *
 * Throws MARSHAL exception if no factory found.
 */
public static ValueFactory getFactory(Class clazz, String codebase,
                           ORB orb, String repId)
{
    ValueFactory factory = null;
    if ((orb != null) && (repId != null)) {
        try {
            factory = ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(
                repId);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            // Try other way
        }
    }

    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw omgWrapper.unableLocateValueFactory(
                CompletionStatus.COMPLETED_MAYBE);
    }

    // if earlier search found a non-default factory, or the same default
    // factory that loadClassForClass would return, bale out now...
    if (factory != null &&
        (!factory.getClass().getName().equals(className+"DefaultFactory") ||
         (clazz == null && codebase == null)))
        return factory;

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class factoryClass =
            loadClassForClass(className+"DefaultFactory", codebase,
            clazzLoader, clazz, clazzLoader);
        return (ValueFactory)factoryClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cnfe);
    } catch (IllegalAccessException iae) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, iae);
    } catch (InstantiationException ie) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, ie);
    } catch (ClassCastException cce) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cce);
    }
}
 
Example 12
Source File: IIOPInputStream.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 13
Source File: Utility.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the factory for an IDLValue
 *
 * Throws MARSHAL exception if no factory found.
 */
public static ValueFactory getFactory(Class clazz, String codebase,
                           ORB orb, String repId)
{
    ValueFactory factory = null;
    if ((orb != null) && (repId != null)) {
        try {
            factory = ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(
                repId);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            // Try other way
        }
    }

    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw omgWrapper.unableLocateValueFactory(
                CompletionStatus.COMPLETED_MAYBE);
    }

    // if earlier search found a non-default factory, or the same default
    // factory that loadClassForClass would return, bale out now...
    if (factory != null &&
        (!factory.getClass().getName().equals(className+"DefaultFactory") ||
         (clazz == null && codebase == null)))
        return factory;

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class factoryClass =
            loadClassForClass(className+"DefaultFactory", codebase,
            clazzLoader, clazz, clazzLoader);
        return (ValueFactory)factoryClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cnfe);
    } catch (IllegalAccessException iae) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, iae);
    } catch (InstantiationException ie) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, ie);
    } catch (ClassCastException cce) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cce);
    }
}
 
Example 14
Source File: IIOPInputStream.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 15
Source File: IIOPInputStream.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 16
Source File: IIOPInputStream.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 17
Source File: Utility.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the factory for an IDLValue
 *
 * Throws MARSHAL exception if no factory found.
 */
public static ValueFactory getFactory(Class clazz, String codebase,
                           ORB orb, String repId)
{
    ValueFactory factory = null;
    if ((orb != null) && (repId != null)) {
        try {
            factory = ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(
                repId);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            // Try other way
        }
    }

    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw omgWrapper.unableLocateValueFactory(
                CompletionStatus.COMPLETED_MAYBE);
    }

    // if earlier search found a non-default factory, or the same default
    // factory that loadClassForClass would return, bale out now...
    if (factory != null &&
        (!factory.getClass().getName().equals(className+"DefaultFactory") ||
         (clazz == null && codebase == null)))
        return factory;

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class factoryClass =
            loadClassForClass(className+"DefaultFactory", codebase,
            clazzLoader, clazz, clazzLoader);
        return (ValueFactory)factoryClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cnfe);
    } catch (IllegalAccessException iae) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, iae);
    } catch (InstantiationException ie) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, ie);
    } catch (ClassCastException cce) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cce);
    }
}
 
Example 18
Source File: IIOPInputStream.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}
 
Example 19
Source File: Utility.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the factory for an IDLValue
 *
 * Throws MARSHAL exception if no factory found.
 */
public static ValueFactory getFactory(Class clazz, String codebase,
                           ORB orb, String repId)
{
    ValueFactory factory = null;
    if ((orb != null) && (repId != null)) {
        try {
            factory = ((org.omg.CORBA_2_3.ORB)orb).lookup_value_factory(
                repId);
        } catch (org.omg.CORBA.BAD_PARAM ex) {
            // Try other way
        }
    }

    String className = null;
    if (clazz != null) {
        className = clazz.getName();
        if (codebase == null)
            codebase = Util.getCodebase(clazz);
    } else {
        if (repId != null)
            className = RepositoryId.cache.getId(repId).getClassName();
        if (className == null) // no repId or unrecognized repId
            throw omgWrapper.unableLocateValueFactory(
                CompletionStatus.COMPLETED_MAYBE);
    }

    // if earlier search found a non-default factory, or the same default
    // factory that loadClassForClass would return, bale out now...
    if (factory != null &&
        (!factory.getClass().getName().equals(className+"DefaultFactory") ||
         (clazz == null && codebase == null)))
        return factory;

    try {
        ClassLoader clazzLoader =
            (clazz == null ? null : clazz.getClassLoader());
        Class factoryClass =
            loadClassForClass(className+"DefaultFactory", codebase,
            clazzLoader, clazz, clazzLoader);
        return (ValueFactory)factoryClass.newInstance();

    } catch (ClassNotFoundException cnfe) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cnfe);
    } catch (IllegalAccessException iae) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, iae);
    } catch (InstantiationException ie) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, ie);
    } catch (ClassCastException cce) {
        throw omgWrapper.unableLocateValueFactory(
            CompletionStatus.COMPLETED_MAYBE, cce);
    }
}
 
Example 20
Source File: IIOPInputStream.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Factored out of inputClassFields and reused in
 * inputCurrentClassFieldsForReadFields.
 *
 * Reads the field (which of an Object type as opposed to a primitive)
 * described by ObjectStreamField field and returns it.
 */
private Object inputObjectField(ObjectStreamField field)
    throws InvalidClassException, StreamCorruptedException,
           ClassNotFoundException, IndirectionException, IOException {

    if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
        return javax.rmi.CORBA.Util.readAny(orbStream);
    }

    Object objectValue = null;

    // fields have an API to provide the actual class
    // corresponding to the data type
    // Class type = osc.forClass();
    Class fieldType = field.getType();
    Class actualType = fieldType; // This may change if stub loaded.

    // Decide what method call to make based on the fieldType. If
    // it is a type for which we need to load a stub, convert
    // the type to the correct stub type.

    int callType = ValueHandlerImpl.kValueType;
    boolean narrow = false;

    if (fieldType.isInterface()) {
        boolean loadStubClass = false;

        if (java.rmi.Remote.class.isAssignableFrom(fieldType)) {

            // RMI Object reference...
            callType = ValueHandlerImpl.kRemoteType;

        } else if (org.omg.CORBA.Object.class.isAssignableFrom(fieldType)){

            // IDL Object reference...
            callType = ValueHandlerImpl.kRemoteType;
            loadStubClass = true;

        } else if (vhandler.isAbstractBase(fieldType)) {
            // IDL Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
            loadStubClass = true;
        } else if (ObjectStreamClassCorbaExt.isAbstractInterface(fieldType)) {
            // RMI Abstract Object reference...

            callType = ValueHandlerImpl.kAbstractType;
        }

        if (loadStubClass) {
            try {
                String codebase = Util.getCodebase(fieldType);
                String repID = vhandler.createForAnyType(fieldType);
                Class stubType =
                    Utility.loadStubClass(repID, codebase, fieldType);
                actualType = stubType;
            } catch (ClassNotFoundException e) {
                narrow = true;
            }
        } else {
            narrow = true;
        }
    }

    switch (callType) {
        case ValueHandlerImpl.kRemoteType:
            if (!narrow)
                objectValue = (Object)orbStream.read_Object(actualType);
            else
                objectValue = Utility.readObjectAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kAbstractType:
            if (!narrow)
                objectValue = (Object)orbStream.read_abstract_interface(actualType);
            else
                objectValue = Utility.readAbstractAndNarrow(orbStream, actualType);
            break;
        case ValueHandlerImpl.kValueType:
            objectValue = (Object)orbStream.read_value(actualType);
            break;
        default:
            // XXX I18N, logging needed.
            throw new StreamCorruptedException("Unknown callType: " + callType);
    }

    return objectValue;
}