Java Code Examples for org.omg.CORBA.Any#insert_Streamable()

The following examples show how to use org.omg.CORBA.Any#insert_Streamable() . 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
Source Project: cxf   File: CorbaServerConduit.java    License: Apache License 2.0 5 votes vote down vote up
public void buildRequestResult(CorbaMessage msg) {
    Exchange exg = msg.getExchange();
    ServerRequest request = exg.get(ServerRequest.class);
    try {
        if (!exg.isOneWay()) {
            CorbaMessage inMsg = (CorbaMessage)msg.getExchange().getInMessage();
            NVList list = inMsg.getList();

            if (msg.getStreamableException() != null) {
                Any exAny = CorbaAnyHelper.createAny(orb);
                CorbaStreamable exception = msg.getStreamableException();
                exAny.insert_Streamable(exception);
                request.set_exception(exAny);
                if (msg.getExchange() != null) {
                    msg.getExchange().setOutFaultMessage(msg);
                }
            } else {
                CorbaStreamable[] arguments = msg.getStreamableArguments();
                if (arguments != null) {
                    for (int i = 0; i < arguments.length; ++i) {
                        if (list.item(i).flags() != org.omg.CORBA.ARG_IN.value) {
                            arguments[i].getObject().setIntoAny(list.item(i).value(),
                                                                arguments[i], true);
                        }
                    }
                }

                CorbaStreamable resultValue = msg.getStreamableReturn();
                if (resultValue != null) {
                    Any resultAny = CorbaAnyHelper.createAny(orb);
                    resultValue.getObject().setIntoAny(resultAny, resultValue, true);
                    request.set_result(resultAny);
                }
            }
        }

    } catch (java.lang.Exception ex) {
        throw new CorbaBindingException("Exception during buildRequestResult", ex);
    }
}
 
Example 2
Source Project: cxf   File: CorbaUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static NVList nvListFromStreamables(ORB orb, CorbaStreamable[] streamables) {
    NVList list = null;
    if (streamables != null && streamables.length > 0) {
        list = orb.create_list(streamables.length);
        for (int i = 0; i < streamables.length; ++i) {
            Any value = orb.create_any();
            value.insert_Streamable(streamables[i]);
            list.add_value(streamables[i].getName(), value, streamables[i].getMode());
        }
    } else {
        list = orb.create_list(0);
    }
    return list;
}
 
Example 3
Source Project: cxf   File: CorbaObjectHandler.java    License: Apache License 2.0 4 votes vote down vote up
public void setIntoAny(Any value, CorbaStreamable stream, boolean output) {
    value.insert_Streamable(stream);
}
 
Example 4
Source Project: cxf   File: CorbaPrimitiveHandler.java    License: Apache License 2.0 4 votes vote down vote up
public void setIntoAny(Any val, CorbaStreamable stream, boolean output) {
    any = val;
    if (stream != null) {
        val.insert_Streamable(stream);
    }
    if (output && value != null) {
        switch (this.typeCode.kind().value()) {
        case TCKind._tk_boolean:
            any.insert_boolean((Boolean)value);
            break;
        case TCKind._tk_char:
            any.insert_char(((Character)value).charValue());
            break;
        case TCKind._tk_wchar:
            any.insert_wchar(((Character)value).charValue());
            break;
        case TCKind._tk_octet:
            any.insert_octet(((Byte)value).byteValue());
            break;
        case TCKind._tk_short:
            any.insert_short(((Short)value).shortValue());
            break;
        case TCKind._tk_ushort:
            any.insert_ushort((short)((Integer)value).intValue());
            break;
        case TCKind._tk_long:
            any.insert_long(((Integer)value).intValue());
            break;
        case TCKind._tk_longlong:
            any.insert_longlong(((Long)value).longValue());
            break;
        case TCKind._tk_ulong:
            any.insert_ulong((int)((Long)value).longValue());
            break;
        case TCKind._tk_ulonglong:
            any.insert_ulonglong(((java.math.BigInteger)value).longValue());
            break;
        case TCKind._tk_float:
            any.insert_float((Float)value);
            break;
        case TCKind._tk_double:
            any.insert_double((Double)value);
            break;
        case TCKind._tk_string:
            any.insert_string((String)value);
            break;
        case TCKind._tk_wstring:
            any.insert_wstring((String)value);
            break;
        default:
            // Default: assume that whatever stored the data will also know how to convert it into what
            // it needs.
        }
    }
}
 
Example 5
Source Project: cxf   File: SystemExceptionHelper.java    License: Apache License 2.0 4 votes vote down vote up
public static void insert(Any any, SystemException val) {
    any.insert_Streamable(new SystemExceptionHelper(val));
}
 
Example 6
Source Project: cxf   File: CorbaMessageTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void testGetCorbaMessageAttributes() {
    CorbaMessage msg = new CorbaMessage(message);

    QName param1Name = new QName("param1");
    QName param1IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param1TypeCode = orb.get_primitive_tc(TCKind.tk_long);
    CorbaPrimitiveHandler param1 = new CorbaPrimitiveHandler(param1Name,
                                                             param1IdlType,
                                                             param1TypeCode,
                                                             null);
    CorbaStreamable p1 = msg.createStreamableObject(param1, param1Name);

    QName param2Name = new QName("param2");
    QName param2IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param2TypeCode = orb.get_primitive_tc(TCKind.tk_string);
    CorbaPrimitiveHandler param2 = new CorbaPrimitiveHandler(param2Name,
                                                             param2IdlType,
                                                             param2TypeCode,
                                                             null);
    CorbaStreamable p2 = msg.createStreamableObject(param2, param2Name);

    msg.addStreamableArgument(p1);
    msg.addStreamableArgument(p2);

    CorbaStreamable[] arguments = msg.getStreamableArguments();
    assertTrue(arguments.length == 2);
    assertNotNull(arguments[0]);
    assertNotNull(arguments[1]);

    QName param3Name = new QName("param3");
    QName param3IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param3TypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler param3 = new CorbaPrimitiveHandler(param3Name,
                                                             param3IdlType,
                                                             param3TypeCode,
                                                             null);
    CorbaStreamable p3 = msg.createStreamableObject(param3, param3Name);

    QName param4Name = new QName("param4");
    QName param4IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "float", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param4TypeCode = orb.get_primitive_tc(TCKind.tk_float);
    CorbaPrimitiveHandler param4 = new CorbaPrimitiveHandler(param4Name,
                                                             param4IdlType,
                                                             param4TypeCode,
                                                             null);
    CorbaStreamable p4 = msg.createStreamableObject(param4, param4Name);

    CorbaStreamable[] args = new CorbaStreamable[2];
    args[0] =  p3;
    args[1] = p4;
    msg.setStreamableArguments(args);

    arguments = msg.getStreamableArguments();
    assertTrue(arguments.length == 4);
    assertNotNull(arguments[0]);
    assertNotNull(arguments[1]);
    assertNotNull(arguments[2]);
    assertNotNull(arguments[3]);

    NVList list = orb.create_list(2);
    Any value = orb.create_any();
    value.insert_Streamable(p1);
    list.add_value(p1.getName(), value, p1.getMode());
    value.insert_Streamable(p2);
    list.add_value(p2.getName(), value, p2.getMode());

    msg.setList(list);
    NVList resultList = msg.getList();
    assertTrue(resultList.count() == 2);

    QName returnName = new QName("param2");
    QName returnIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean",
                                    CorbaConstants.NP_WSDL_CORBA);
    TypeCode returnTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
    CorbaPrimitiveHandler returnValue = new CorbaPrimitiveHandler(returnName,
                                                                  returnIdlType,
                                                                  returnTypeCode, null);
    CorbaStreamable ret = msg.createStreamableObject(returnValue, returnName);

    msg.setStreamableReturn(ret);
    CorbaStreamable retVal = msg.getStreamableReturn();
    assertNotNull(retVal);

    // NEED TO DO TEST FOR EXCEPTIONS
    /*Exception ex = new CorbaBindingException("TestException");
    msg.s.setException(ex);
    Exception msgEx = msg.getException();
    assertNotNull(msgEx);
    assertEquals(msgEx.getMessage(), ex.getMessage());*/
}