org.omg.CORBA.TypeCode Java Examples

The following examples show how to use org.omg.CORBA.TypeCode. 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: ValueUtility.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public static TypeCode getPrimitiveTypeCodeForClass (ORB orb,
                                                     Class c,
                                                     ValueHandler vh) {

    if (c == Integer.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_long);
    } else if (c == Byte.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_octet);
    } else if (c == Long.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_longlong);
    } else if (c == Float.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_float);
    } else if (c == Double.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_double);
    } else if (c == Short.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_short);
    } else if (c == Character.TYPE) {
        return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind());
    } else if (c == Boolean.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_boolean);
    } else {
        // _REVISIT_ Not sure if this is right.
        return orb.get_primitive_tc (TCKind.tk_any);
    }
}
 
Example #2
Source File: ValueUtility.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public static TypeCode getPrimitiveTypeCodeForClass (ORB orb,
                                                     Class c,
                                                     ValueHandler vh) {

    if (c == Integer.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_long);
    } else if (c == Byte.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_octet);
    } else if (c == Long.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_longlong);
    } else if (c == Float.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_float);
    } else if (c == Double.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_double);
    } else if (c == Short.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_short);
    } else if (c == Character.TYPE) {
        return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind());
    } else if (c == Boolean.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_boolean);
    } else {
        // _REVISIT_ Not sure if this is right.
        return orb.get_primitive_tc (TCKind.tk_any);
    }
}
 
Example #3
Source File: TypeCodeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public TypeCode member_type(int index)
    throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds
{
    switch (_kind) {
    case tk_indirect:
        return indirectType().member_type(index);
    case TCKind._tk_except:
    case TCKind._tk_struct:
    case TCKind._tk_union:
    case TCKind._tk_value:
        try {
            return _memberTypes[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new org.omg.CORBA.TypeCodePackage.Bounds();
        }
    default:
        throw new BadKind();
    }
}
 
Example #4
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This is used to create the TypeCode for a null reference.
 * It also handles backwards compatibility with JDK 1.3.x.
 *
 * This method will not return null.
 */
private TypeCode createTypeCodeForNull(org.omg.CORBA.ORB orb)
{
    if (orb instanceof ORB) {

        ORB ourORB = (ORB)orb;

        // Preserve backwards compatibility with Kestrel and Ladybird
        // by not fully implementing interop issue resolution 3857,
        // and returning a null TypeCode with a tk_value TCKind.
        // If we're not talking to Kestrel or Ladybird, fall through
        // to the abstract interface case (also used for foreign ORBs).
        if (!ORBVersionFactory.getFOREIGN().equals(ourORB.getORBVersion()) &&
            ORBVersionFactory.getNEWER().compareTo(ourORB.getORBVersion()) > 0) {

            return orb.get_primitive_tc(TCKind.tk_value);
        }
    }

    // Use tk_abstract_interface as detailed in the resolution

    // REVISIT: Define this in IDL and get the ID in generated code
    String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0";

    return orb.create_abstract_interface_tc(abstractBaseID, "");
}
 
Example #5
Source File: ValueUtility.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private static TypeCode createTypeCodeForClassInternal (ORB orb,
                                                        java.lang.Class c,
                                                        ValueHandler vh,
                                                        IdentityKeyValueStack createdIDs)
{
    // This wrapper method is the protection against infinite recursion.
    TypeCode tc = null;
    String id = (String)createdIDs.get(c);
    if (id != null) {
        return orb.create_recursive_tc(id);
    } else {
        id = vh.getRMIRepositoryID(c);
        if (id == null) id = "";
        // cache the rep id BEFORE creating a new typecode.
        // so that recursive tc can look up the rep id.
        createdIDs.push(c, id);
        tc = createTypeCodeInternal(orb, c, vh, id, createdIDs);
        createdIDs.pop();
        return tc;
    }
}
 
Example #6
Source File: AnyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void insert_fixed(java.math.BigDecimal value, org.omg.CORBA.TypeCode type)
{
    try {
        if (TypeCodeImpl.digits(value) > type.fixed_digits() ||
            TypeCodeImpl.scale(value) > type.fixed_scale())
        {
            throw wrapper.fixedNotMatch() ;
        }
    } catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
        // type isn't even of kind fixed
        throw wrapper.fixedBadTypecode( bk ) ;
    }
    typeCode = TypeCodeImpl.convertToNative(orb, type);
    object = value;
    isInitialized = true;
}
 
Example #7
Source File: ValueUtility.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static TypeCode getPrimitiveTypeCodeForClass (ORB orb,
                                                     Class c,
                                                     ValueHandler vh) {

    if (c == Integer.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_long);
    } else if (c == Byte.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_octet);
    } else if (c == Long.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_longlong);
    } else if (c == Float.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_float);
    } else if (c == Double.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_double);
    } else if (c == Short.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_short);
    } else if (c == Character.TYPE) {
        return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind());
    } else if (c == Boolean.TYPE) {
        return orb.get_primitive_tc (TCKind.tk_boolean);
    } else {
        // _REVISIT_ Not sure if this is right.
        return orb.get_primitive_tc (TCKind.tk_any);
    }
}
 
Example #8
Source File: Util.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * This is used to create the TypeCode for a null reference.
 * It also handles backwards compatibility with JDK 1.3.x.
 *
 * This method will not return null.
 */
private TypeCode createTypeCodeForNull(org.omg.CORBA.ORB orb)
{
    if (orb instanceof ORB) {

        ORB ourORB = (ORB)orb;

        // Preserve backwards compatibility with Kestrel and Ladybird
        // by not fully implementing interop issue resolution 3857,
        // and returning a null TypeCode with a tk_value TCKind.
        // If we're not talking to Kestrel or Ladybird, fall through
        // to the abstract interface case (also used for foreign ORBs).
        if (!ORBVersionFactory.getFOREIGN().equals(ourORB.getORBVersion()) &&
            ORBVersionFactory.getNEWER().compareTo(ourORB.getORBVersion()) > 0) {

            return orb.get_primitive_tc(TCKind.tk_value);
        }
    }

    // Use tk_abstract_interface as detailed in the resolution

    // REVISIT: Define this in IDL and get the ID in generated code
    String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0";

    return orb.create_abstract_interface_tc(abstractBaseID, "");
}
 
Example #9
Source File: Util.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This is used to create the TypeCode for a null reference.
 * It also handles backwards compatibility with JDK 1.3.x.
 *
 * This method will not return null.
 */
private TypeCode createTypeCodeForNull(org.omg.CORBA.ORB orb)
{
    if (orb instanceof ORB) {

        ORB ourORB = (ORB)orb;

        // Preserve backwards compatibility with Kestrel and Ladybird
        // by not fully implementing interop issue resolution 3857,
        // and returning a null TypeCode with a tk_value TCKind.
        // If we're not talking to Kestrel or Ladybird, fall through
        // to the abstract interface case (also used for foreign ORBs).
        if (!ORBVersionFactory.getFOREIGN().equals(ourORB.getORBVersion()) &&
            ORBVersionFactory.getNEWER().compareTo(ourORB.getORBVersion()) > 0) {

            return orb.get_primitive_tc(TCKind.tk_value);
        }
    }

    // Use tk_abstract_interface as detailed in the resolution

    // REVISIT: Define this in IDL and get the ID in generated code
    String abstractBaseID = "IDL:omg.org/CORBA/AbstractBase:1.0";

    return orb.create_abstract_interface_tc(abstractBaseID, "");
}
 
Example #10
Source File: TypeCodeImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public TypeCode member_type(int index)
    throws BadKind, org.omg.CORBA.TypeCodePackage.Bounds
{
    switch (_kind) {
    case tk_indirect:
        return indirectType().member_type(index);
    case TCKind._tk_except:
    case TCKind._tk_struct:
    case TCKind._tk_union:
    case TCKind._tk_value:
        try {
            return _memberTypes[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new org.omg.CORBA.TypeCodePackage.Bounds();
        }
    default:
        throw new BadKind();
    }
}
 
Example #11
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * When using our own ORB and Any implementations, we need to get
 * the ORB version and create the type code appropriately.  This is
 * to overcome a bug in which the JDK 1.3.x ORBs used a tk_char
 * rather than a tk_wchar to describe a Java char field.
 *
 * This only works in RMI-IIOP with Util.writeAny since we actually
 * know what ORB and stream we're writing with when we insert
 * the value.
 *
 * Returns null if it wasn't possible to create the TypeCode (means
 * it wasn't our ORB or Any implementation).
 *
 * This does not handle null objs.
 */
private TypeCode createTypeCode(Serializable obj,
                                org.omg.CORBA.Any any,
                                org.omg.CORBA.ORB orb) {

    if (any instanceof com.sun.corba.se.impl.corba.AnyImpl &&
        orb instanceof ORB) {

        com.sun.corba.se.impl.corba.AnyImpl anyImpl
            = (com.sun.corba.se.impl.corba.AnyImpl)any;

        ORB ourORB = (ORB)orb;

        return anyImpl.createTypeCodeForClass(obj.getClass(), ourORB);

    } else
        return null;
}
 
Example #12
Source File: CorbaStreamableTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateStreamable() {
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable streamable = new CorbaStreamableImpl(obj, objName);

    assertNotNull(streamable);
}
 
Example #13
Source File: ORBSingleton.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public TypeCode create_union_tc(String id,
                                String name,
                                TypeCode discriminator_type,
                                UnionMember[] members)
{
    return new TypeCodeImpl(this,
                            TCKind._tk_union,
                            id,
                            name,
                            discriminator_type,
                            members);
}
 
Example #14
Source File: DynAnyConstructedImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public org.omg.CORBA.TypeCode get_typecode()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (index == NO_INDEX)
        throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
    DynAny currentComponent = current_component();
    if (DynAnyUtil.isConstructedDynAny(currentComponent))
        throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
    return currentComponent.get_typecode();
}
 
Example #15
Source File: DynAnyConstructedImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.CORBA.TypeCode get_typecode()
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (index == NO_INDEX)
        throw new org.omg.DynamicAny.DynAnyPackage.InvalidValue();
    DynAny currentComponent = current_component();
    if (DynAnyUtil.isConstructedDynAny(currentComponent))
        throw new org.omg.DynamicAny.DynAnyPackage.TypeMismatch();
    return currentComponent.get_typecode();
}
 
Example #16
Source File: ServerRequestInfoImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * See ServerRequestInfo for javadocs.
 */
public TypeCode[] exceptions (){
    checkAccess( MID_EXCEPTIONS );

    // _REVISIT_ PI RTF Issue: No exception list on server side.

    throw stdWrapper.piOperationNotSupported2() ;
}
 
Example #17
Source File: ExceptionListImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public TypeCode item(int index)
    throws Bounds
{
    try {
        return (TypeCode) _exceptions.elementAt(index);
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new Bounds();
    }
}
 
Example #18
Source File: ClientRequestInfoImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * See RequestInfoImpl for javadoc.
 */
public TypeCode[] exceptions (){
    checkAccess( MID_EXCEPTIONS );

    if( cachedExceptions == null ) {
        if( request == null ) {
           throw stdWrapper.piOperationNotSupported2() ;
        }

        // Get the list of exceptions from DII request data, If there are
        // no exceptions raised then this method will return null.
        ExceptionList excList = request.exceptions( );
        int count = excList.count();
        TypeCode[] excTCList = new TypeCode[count];
        try {
            for( int i = 0; i < count; i++ ) {
                excTCList[i] = excList.item( i );
            }
        } catch( Exception e ) {
            throw wrapper.exceptionInExceptions( e ) ;
        }

        cachedExceptions = excTCList;
    }

    // Good citizen: In the interest of efficiency, we assume
    // interceptors will be "good citizens" in that they will not
    // modify the contents of the TypeCode[] array.  We also assume
    // they will not change the values of the containing TypeCodes.

    return cachedExceptions;
}
 
Example #19
Source File: AnyImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_TypeCode(TypeCode tc)
{
    //debug.log ("insert_TypeCode");
    typeCode = orb.get_primitive_tc(TCKind._tk_TypeCode);
    object = tc;
    isInitialized = true;
}
 
Example #20
Source File: AnyImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * sets the type of the element to be contained in the Any.
 *
 * @param tc                the TypeCode for the element in the Any
 */
public void type(TypeCode tc)
{
    //debug.log ("type2");
    // set the typecode
    typeCode = TypeCodeImpl.convertToNative(orb, tc);

    stream = null;
    value = 0;
    object = null;
    // null is the only legal value this Any can have after resetting the type code
    isInitialized = (tc.kind().value() == TCKind._tk_null);
}
 
Example #21
Source File: ORBImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public synchronized org.omg.CORBA.TypeCode create_abstract_interface_tc(
                                                           String id,
                                                           String name)
{
    checkShutdownState();
    return new TypeCodeImpl(this, TCKind._tk_abstract_interface, id, name);
}
 
Example #22
Source File: DynAnyBasicImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void insert_typecode(org.omg.CORBA.TypeCode value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_TypeCode)
        throw new TypeMismatch();
    any.insert_TypeCode(value);
}
 
Example #23
Source File: ORBSingleton.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.CORBA.TypeCode create_value_tc(String id,
                                              String name,
                                              short type_modifier,
                                              TypeCode concrete_base,
                                              ValueMember[] members)
{
    return new TypeCodeImpl(this, TCKind._tk_value, id, name,
                            type_modifier, concrete_base, members);
}
 
Example #24
Source File: TypeCodeImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public TypeCode concrete_base_type() throws BadKind {
    switch (_kind) {
    case tk_indirect:
        return indirectType().concrete_base_type();
    case TCKind._tk_value:
        return _concrete_base;
    default:
        throw new BadKind();
    }
}
 
Example #25
Source File: AnyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * See the description of the <a href="#anyOps">general Any operations.</a>
 */
public void insert_TypeCode(TypeCode tc)
{
    //debug.log ("insert_TypeCode");
    typeCode = orb.get_primitive_tc(TCKind._tk_TypeCode);
    object = tc;
    isInitialized = true;
}
 
Example #26
Source File: DynAnyBasicImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void insert_typecode(org.omg.CORBA.TypeCode value)
    throws org.omg.DynamicAny.DynAnyPackage.TypeMismatch,
           org.omg.DynamicAny.DynAnyPackage.InvalidValue
{
    if (status == STATUS_DESTROYED) {
        throw wrapper.dynAnyDestroyed() ;
    }
    if (any.type().kind().value() != TCKind._tk_TypeCode)
        throw new TypeMismatch();
    any.insert_TypeCode(value);
}
 
Example #27
Source File: CorbaServerConduitTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildRequestResultException() {
    NVList list = orb.create_list(0);
    CorbaServerConduit conduit = setupCorbaServerConduit(false);
    CorbaMessage msg = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    ServerRequest request = control.createMock(ServerRequest.class);

    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);

    EasyMock.expect(exchange.isOneWay()).andReturn(false);
    CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);

    EasyMock.expect(inMsg.getList()).andReturn(list);
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable exception = new CorbaStreamableImpl(obj, objName);

    EasyMock.expect(msg.getStreamableException()).andReturn(exception);
    EasyMock.expect(msg.getStreamableException()).andReturn(exception);

    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
 
Example #28
Source File: TypeCodeImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public TypeCodeImpl(ORB orb,
                    int creationKind,
                    String id,
                    String name,
                    TypeCode discriminator_type,
                    UnionMember[] members)
                    // for unions
{
    this(orb) ;

    if (creationKind == TCKind._tk_union) {
        _kind               = creationKind;
        setId(id);
        _name               = name;
        _memberCount        = members.length;
        _discriminator      = convertToNative(_orb, discriminator_type);

        _memberNames = new String[_memberCount];
        _memberTypes = new TypeCodeImpl[_memberCount];
        _unionLabels = new AnyImpl[_memberCount];

        for (int i = 0 ; i < _memberCount ; i++) {
            _memberNames[i] = members[i].name;
            _memberTypes[i] = convertToNative(_orb, members[i].type);
            _memberTypes[i].setParent(this);
            _unionLabels[i] = new AnyImpl(_orb, members[i].label);
            // check whether this is the default branch.
            if (_unionLabels[i].type().kind() == TCKind.tk_octet) {
                if (_unionLabels[i].extract_octet() == (byte)0) {
                    _defaultIndex = i;
                }
            }
        }
    } // else initializes to null
}
 
Example #29
Source File: ServerRequestInfoImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * See ServerRequestInfo for javadocs.
 */
public TypeCode[] exceptions (){
    checkAccess( MID_EXCEPTIONS );

    // _REVISIT_ PI RTF Issue: No exception list on server side.

    throw stdWrapper.piOperationNotSupported2() ;
}
 
Example #30
Source File: DynStructImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected DynStructImpl(ORB orb, TypeCode typeCode) {
    // We can be sure that typeCode is of kind tk_struct
    super(orb, typeCode);
    // For DynStruct, the operation sets the current position to -1
    // for empty exceptions and to zero for all other TypeCodes.
    // The members (if any) are (recursively) initialized to their default values.
    index = 0;
}