org.omg.CORBA.portable.InputStream Java Examples

The following examples show how to use org.omg.CORBA.portable.InputStream. 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: AnyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * returns an input stream that an Any value can be marshaled out of.
 *
 * @result          the InputStream to marshal value of Any out of.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
    //
    // We create a new InputStream so that multiple threads can call here
    // and read the streams in parallel without thread safety problems.
    //
    //debug.log ("create_input_stream");
    if (AnyImpl.isStreamed[realType().kind().value()]) {
        return stream.dup();
    } else {
        OutputStream os = (OutputStream)orb.create_output_stream();
        TCUtility.marshalIn(os, realType(), value, object);

        return os.create_input_stream();
    }
}
 
Example #2
Source File: AnyImpl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * returns an input stream that an Any value can be marshaled out of.
 *
 * @result          the InputStream to marshal value of Any out of.
 */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
    //
    // We create a new InputStream so that multiple threads can call here
    // and read the streams in parallel without thread safety problems.
    //
    //debug.log ("create_input_stream");
    if (AnyImpl.isStreamed[realType().kind().value()]) {
        return stream.dup();
    } else {
        OutputStream os = (OutputStream)orb.create_output_stream();
        TCUtility.marshalIn(os, realType(), value, object);

        return os.create_input_stream();
    }
}
 
Example #3
Source File: BootstrapResolverImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public org.omg.CORBA.Object resolve( String identifier )
{
    InputStream inStream = null ;
    org.omg.CORBA.Object result = null ;

    try {
        inStream = invoke( "get", identifier ) ;

        result = inStream.read_Object();

        // NOTE: do note trap and ignore errors.
        // Let them flow out.
    } finally {
        bootstrapDelegate.releaseReply( null, inStream ) ;
    }

    return result ;
}
 
Example #4
Source File: BootstrapResolverImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public java.util.Set list()
{
    InputStream inStream = null ;
    java.util.Set result = new java.util.HashSet() ;

    try {
        inStream = invoke( "list", null ) ;

        int count = inStream.read_long();
        for (int i=0; i < count; i++)
            result.add( inStream.read_string() ) ;

        // NOTE: do note trap and ignore errors.
        // Let them flow out.
    } finally {
        bootstrapDelegate.releaseReply( null, inStream ) ;
    }

    return result ;
}
 
Example #5
Source File: CorbaAnyEventProducer.java    From cxf with Apache License 2.0 6 votes vote down vote up
private CorbaObjectHandler getAnyContainedType(Any a) {
    CorbaObjectHandler result = null;

    TypeCode tc = a.type();
    QName containedName = new QName("AnyContainedType");
    QName idlType = null;
    if (CorbaUtils.isPrimitiveTypeCode(tc)) {
        idlType = CorbaAnyHelper.getPrimitiveIdlTypeFromTypeCode(tc);
        result = new CorbaPrimitiveHandler(containedName, idlType, tc, null);
    } else if (tc.kind().value() == TCKind._tk_any) {
        idlType = CorbaConstants.NT_CORBA_ANY;
        result = new CorbaAnyHandler(containedName, idlType, tc, null);
        ((CorbaAnyHandler)result).setTypeMap(handler.getTypeMap());
    } else {
        idlType = handler.getTypeMap().getIdlType(tc);
        result = CorbaHandlerUtils.initializeObjectHandler(orb, containedName, idlType,
                                                           handler.getTypeMap(), serviceInfo);
    }

    InputStream is = a.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(is);
    reader.read(result);

    return result;
}
 
Example #6
Source File: BootstrapResolverImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public java.util.Set list()
{
    InputStream inStream = null ;
    java.util.Set result = new java.util.HashSet() ;

    try {
        inStream = invoke( "list", null ) ;

        int count = inStream.read_long();
        for (int i=0; i < count; i++)
            result.add( inStream.read_string() ) ;

        // NOTE: do note trap and ignore errors.
        // Let them flow out.
    } finally {
        bootstrapDelegate.releaseReply( null, inStream ) ;
    }

    return result ;
}
 
Example #7
Source File: BootstrapResolverImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public org.omg.CORBA.Object resolve( String identifier )
{
    InputStream inStream = null ;
    org.omg.CORBA.Object result = null ;

    try {
        inStream = invoke( "get", identifier ) ;

        result = inStream.read_Object();

        // NOTE: do note trap and ignore errors.
        // Let them flow out.
    } finally {
        bootstrapDelegate.releaseReply( null, inStream ) ;
    }

    return result ;
}
 
Example #8
Source File: Util.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads a java.lang.Object as a CORBA any.
 * @param in the stream from which to read the any.
 * @return the object read from the stream.
 */
public Object readAny(InputStream in)
{
    Any any = in.read_any();
    if ( any.type().kind().value() == TCKind._tk_objref )
        return any.extract_Object ();
    else
        return any.extract_Value();
}
 
Example #9
Source File: AnyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Any extractAny(TypeCode memberType, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy((InputStream)stream, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}
 
Example #10
Source File: AnyImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static public Any extractAnyFromStream(TypeCode memberType, InputStream input, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy(input, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}
 
Example #11
Source File: AnyImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Any extractAny(TypeCode memberType, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy((InputStream)stream, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}
 
Example #12
Source File: RequestImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void unmarshalReply(InputStream is)
{
    // First unmarshal the return value if it is not void
    if ( _result != null ) {
        Any returnAny = _result.value();
        TypeCode returnType = returnAny.type();
        if ( returnType.kind().value() != TCKind._tk_void )
            returnAny.read_value(is, returnType);
    }

    // Now unmarshal the out/inout args
    try {
        for ( int i=0; i<_arguments.count() ; i++) {
            NamedValue nv = _arguments.item(i);
            switch( nv.flags() ) {
            case ARG_IN.value:
                break;
            case ARG_OUT.value:
            case ARG_INOUT.value:
                Any any = nv.value();
                any.read_value(is, any.type());
                break;
            }
        }
    }
    catch ( org.omg.CORBA.Bounds ex ) {
        // Cannot happen since we only iterate till _arguments.count()
    }
}
 
Example #13
Source File: AnyImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
static public Any extractAnyFromStream(TypeCode memberType, InputStream input, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy(input, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}
 
Example #14
Source File: RequestImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void unmarshalReply(InputStream is)
{
    // First unmarshal the return value if it is not void
    if ( _result != null ) {
        Any returnAny = _result.value();
        TypeCode returnType = returnAny.type();
        if ( returnType.kind().value() != TCKind._tk_void )
            returnAny.read_value(is, returnType);
    }

    // Now unmarshal the out/inout args
    try {
        for ( int i=0; i<_arguments.count() ; i++) {
            NamedValue nv = _arguments.item(i);
            switch( nv.flags() ) {
            case ARG_IN.value:
                break;
            case ARG_OUT.value:
            case ARG_INOUT.value:
                Any any = nv.value();
                any.read_value(is, any.type());
                break;
            }
        }
    }
    catch ( org.omg.CORBA.Bounds ex ) {
        // Cannot happen since we only iterate till _arguments.count()
    }
}
 
Example #15
Source File: CorbaObjectWriterTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriteULongLong() {
    OutputStream oStream = orb.create_output_stream();

    CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
    BigInteger ulonglongValue = new BigInteger("12345678900");
    writer.writeULongLong(ulonglongValue);

    InputStream iStream = oStream.create_input_stream();
    long ul = iStream.read_ulonglong();
    assertTrue(ul == ulonglongValue.longValue());
}
 
Example #16
Source File: Utility.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Read an abstract interface type from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readAbstractAndNarrow(
    org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_abstract_interface();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #17
Source File: SpecialMethod.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public CorbaMessageMediator invoke(java.lang.Object servant,
                                   CorbaMessageMediator request,
                                   byte[] objectId,
                                   ObjectAdapter objectAdapter)
{
    if ((servant == null) || (servant instanceof NullServant)) {
        ORB orb = (ORB)request.getBroker() ;
        ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.OA_INVOCATION ) ;

        return request.getProtocolHandler().createSystemExceptionResponse(
            request, wrapper.badSkeleton(), null);
    }

    String[] ids = objectAdapter.getInterfaces( servant, objectId );
    String clientId =
        ((InputStream)request.getInputObject()).read_string();
    boolean answer = false;
    for(int i = 0; i < ids.length; i++)
        if (ids[i].equals(clientId)) {
            answer = true;
            break;
        }

    CorbaMessageMediator response =
        request.getProtocolHandler().createResponse(request, null);
    ((OutputStream)response.getOutputObject()).write_boolean(answer);
    return response;
}
 
Example #18
Source File: SpecialMethod.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public CorbaMessageMediator invoke(java.lang.Object servant,
                                   CorbaMessageMediator request,
                                   byte[] objectId,
                                   ObjectAdapter objectAdapter)
{
    if ((servant == null) || (servant instanceof NullServant)) {
        ORB orb = (ORB)request.getBroker() ;
        ORBUtilSystemException wrapper = ORBUtilSystemException.get( orb,
            CORBALogDomains.OA_INVOCATION ) ;

        return request.getProtocolHandler().createSystemExceptionResponse(
            request, wrapper.badSkeleton(), null);
    }

    String[] ids = objectAdapter.getInterfaces( servant, objectId );
    String clientId =
        ((InputStream)request.getInputObject()).read_string();
    boolean answer = false;
    for(int i = 0; i < ids.length; i++)
        if (ids[i].equals(clientId)) {
            answer = true;
            break;
        }

    CorbaMessageMediator response =
        request.getProtocolHandler().createResponse(request, null);
    ((OutputStream)response.getOutputObject()).write_boolean(answer);
    return response;
}
 
Example #19
Source File: AnyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public org.omg.CORBA.portable.InputStream create_input_stream() {
    final org.omg.CORBA.portable.InputStream is = super
            .create_input_stream();
    AnyInputStream aIS = AccessController
            .doPrivileged(new PrivilegedAction<AnyInputStream>() {
                @Override
                public AnyInputStream run() {
                    return new AnyInputStream(
                            (com.sun.corba.se.impl.encoding.EncapsInputStream) is);
                }
            });
    return aIS;
}
 
Example #20
Source File: CorbaClientDelegateImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
 
Example #21
Source File: CorbaObjectReaderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadULongLong() {
    OutputStream oStream = orb.create_output_stream();
    oStream.write_ulonglong(-1000000000L);

    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);

    BigInteger ulonglongValue = reader.readULongLong();
    assertEquals(1, ulonglongValue.signum());
}
 
Example #22
Source File: DynArrayImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_array.
    TypeCode typeCode = any.type();
    int length = getBound();
    TypeCode contentType = getContentType();
    InputStream input;

    try {
        input = any.create_input_stream();
    } catch (BAD_OPERATION e) {
        return false;
    }

    components = new DynAny[length];
    anys = new Any[length];

    for (int i=0; i<length; i++) {
        // _REVISIT_ Could use read_xxx_array() methods on InputStream for efficiency
        // but only for primitive types
        anys[i] = DynAnyUtil.extractAnyFromStream(contentType, input, orb);
        try {
            // Creates the appropriate subtype without copying the Any
            components[i] = DynAnyUtil.createMostDerivedDynAny(anys[i], orb, false);
        } catch (InconsistentTypeCode itc) { // impossible
        }
    }
    return true;
}
 
Example #23
Source File: RequestImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void unmarshalReply(InputStream is)
{
    // First unmarshal the return value if it is not void
    if ( _result != null ) {
        Any returnAny = _result.value();
        TypeCode returnType = returnAny.type();
        if ( returnType.kind().value() != TCKind._tk_void )
            returnAny.read_value(is, returnType);
    }

    // Now unmarshal the out/inout args
    try {
        for ( int i=0; i<_arguments.count() ; i++) {
            NamedValue nv = _arguments.item(i);
            switch( nv.flags() ) {
            case ARG_IN.value:
                break;
            case ARG_OUT.value:
            case ARG_INOUT.value:
                Any any = nv.value();
                any.read_value(is, any.type());
                break;
            }
        }
    }
    catch ( org.omg.CORBA.Bounds ex ) {
        // Cannot happen since we only iterate till _arguments.count()
    }
}
 
Example #24
Source File: CorbaObjectReaderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadULong() {
    OutputStream oStream = orb.create_output_stream();
    oStream.write_ulong(100000);

    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);

    long ulongValue = reader.readULong();
    assertTrue(ulongValue == 100000);
}
 
Example #25
Source File: Utility.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read an abstract interface type from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readAbstractAndNarrow(
    org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_abstract_interface();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #26
Source File: ObjectReferenceTemplateImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/** Read the data into a (presumably) empty ORTImpl.  This sets the
* orb to the ORB of the InputStream.
*/
public void _read( InputStream is )
{
    org.omg.CORBA_2_3.portable.InputStream istr =
        (org.omg.CORBA_2_3.portable.InputStream)is ;
    iorTemplate = IORFactories.makeIORTemplate( istr ) ;
    orb = (ORB)(istr.orb()) ;
}
 
Example #27
Source File: Utility.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Read an object reference from the input stream and narrow
 * it to the desired type.
 * @param in the stream to read from.
 * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
 */
public static Object readObjectAndNarrow(InputStream in,
                                         Class narrowTo)
    throws ClassCastException
{
    Object result = in.read_Object();
    if (result != null)
        return PortableRemoteObject.narrow(result, narrowTo);
    else
        return null;
}
 
Example #28
Source File: AnyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Any extractAny(TypeCode memberType, ORB orb) {
    Any returnValue = orb.create_any();
    OutputStream out = returnValue.create_output_stream();
    TypeCodeImpl.convertToNative(orb, memberType).copy((InputStream)stream, out);
    returnValue.read_value(out.create_input_stream(), memberType);
    return returnValue;
}
 
Example #29
Source File: RequestImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void unmarshalReply(InputStream is)
{
    // First unmarshal the return value if it is not void
    if ( _result != null ) {
        Any returnAny = _result.value();
        TypeCode returnType = returnAny.type();
        if ( returnType.kind().value() != TCKind._tk_void )
            returnAny.read_value(is, returnType);
    }

    // Now unmarshal the out/inout args
    try {
        for ( int i=0; i<_arguments.count() ; i++) {
            NamedValue nv = _arguments.item(i);
            switch( nv.flags() ) {
            case ARG_IN.value:
                break;
            case ARG_OUT.value:
            case ARG_INOUT.value:
                Any any = nv.value();
                any.read_value(is, any.type());
                break;
            }
        }
    }
    catch ( org.omg.CORBA.Bounds ex ) {
        // Cannot happen since we only iterate till _arguments.count()
    }
}
 
Example #30
Source File: ORBUtility.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static SystemException extractSystemException(Any any) {
    InputStream in = any.create_input_stream();
    ORB orb = (ORB)(in.orb());
    if ( ! isSystemExceptionTypeCode(any.type(), orb)) {
        throw wrapper.unknownDsiSysex(CompletionStatus.COMPLETED_MAYBE);
    }
    return ORBUtility.readSystemException(in);
}