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

The following examples show how to use javax.rmi.CORBA.Util#getCodebase() . 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
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
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 Project: jdk1.8-source-analysis   File: Utility.java    License: 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 4
/**
 * 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
/**
 * 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 Project: jdk8u60   File: Utility.java    License: 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
/**
 * 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
/**
 * 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
/**
 * 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 10
/**
 * 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 11
Source Project: jdk8u60   File: Utility.java    License: 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
/**
 * 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
/**
 * 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 14
/**
 * 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
/**
 * 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 16
Source Project: JDKSourceCode1.8   File: IIOPInputStream.java    License: 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 17
Source Project: openjdk-8   File: Utility.java    License: 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
/**
 * 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 19
/**
 * 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 20
/**
 * 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;
}