Java 类org.omg.CORBA.portable.InputStream 实例源码

项目:OpenJSharp    文件:AnyImpl.java   
/**
 * 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();
    }
}
项目:OpenJSharp    文件:BootstrapResolverImpl.java   
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 ;
}
项目:OpenJSharp    文件:BootstrapResolverImpl.java   
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 ;
}
项目:OpenJSharp    文件:StubIORImpl.java   
public StubIORImpl( org.omg.CORBA.Object obj )
{
    // write the IOR to an OutputStream and get an InputStream
    OutputStream ostr = StubAdapter.getORB( obj ).create_output_stream();
    ostr.write_Object(obj);
    InputStream istr = ostr.create_input_stream();

    // read the IOR components back from the stream
    int typeLength = istr.read_long();
    typeData = new byte[typeLength];
    istr.read_octet_array(typeData, 0, typeLength);
    int numProfiles = istr.read_long();
    profileTags = new int[numProfiles];
    profileData = new byte[numProfiles][];
    for (int i = 0; i < numProfiles; i++) {
        profileTags[i] = istr.read_long();
        profileData[i] = new byte[istr.read_long()];
        istr.read_octet_array(profileData[i], 0, profileData[i].length);
    }
}
项目:OpenJSharp    文件:StubIORImpl.java   
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
项目:openjdk-jdk10    文件:AnyImpl.java   
/**
 * returns an input stream that an Any value can be marshaled out of.
 *
 * @return          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();
    }
}
项目:openjdk-jdk10    文件:BootstrapResolverImpl.java   
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 ;
}
项目:openjdk-jdk10    文件:BootstrapResolverImpl.java   
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 ;
}
项目:openjdk-jdk10    文件:StubIORImpl.java   
public StubIORImpl( org.omg.CORBA.Object obj )
{
    // write the IOR to an OutputStream and get an InputStream
    OutputStream ostr = StubAdapter.getORB( obj ).create_output_stream();
    ostr.write_Object(obj);
    InputStream istr = ostr.create_input_stream();

    // read the IOR components back from the stream
    int typeLength = istr.read_long();
    typeData = new byte[typeLength];
    istr.read_octet_array(typeData, 0, typeLength);
    int numProfiles = istr.read_long();
    profileTags = new int[numProfiles];
    profileData = new byte[numProfiles][];
    for (int i = 0; i < numProfiles; i++) {
        profileTags[i] = istr.read_long();
        profileData[i] = new byte[istr.read_long()];
        istr.read_octet_array(profileData[i], 0, profileData[i].length);
    }
}
项目:openjdk-jdk10    文件:StubIORImpl.java   
public Delegate getDelegate( ORB orb )
{
    // write the IOR components to an org.omg.CORBA.portable.OutputStream
    OutputStream ostr = orb.create_output_stream();
    ostr.write_long(typeData.length);
    ostr.write_octet_array(typeData, 0, typeData.length);
    ostr.write_long(profileTags.length);
    for (int i = 0; i < profileTags.length; i++) {
        ostr.write_long(profileTags[i]);
        ostr.write_long(profileData[i].length);
        ostr.write_octet_array(profileData[i], 0, profileData[i].length);
    }

    InputStream istr = ostr.create_input_stream() ;

    // read the IOR back from the stream
    org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object();
    return StubAdapter.getDelegate( obj ) ;
}
项目:OpenJSharp    文件:RequestImpl.java   
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()
    }
}
项目:OpenJSharp    文件:AnyImpl.java   
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;
}
项目:OpenJSharp    文件:AnyImpl.java   
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;
}
项目:OpenJSharp    文件:AnyImpl.java   
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;
}
项目:OpenJSharp    文件:ServerRequestImpl.java   
public ServerRequestImpl (CorbaMessageMediator req, ORB orb) {
    _opName = req.getOperationName();
    _ins    = (InputStream)req.getInputObject();
    _ctx    = null;         // if we support contexts, this would
                            // presumably also  be available on
                            // the server invocation
    _orb = orb;
    _wrapper = ORBUtilSystemException.get( orb,
        CORBALogDomains.OA_INVOCATION ) ;
}
项目:OpenJSharp    文件:SpecialMethod.java   
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;
}
项目:OpenJSharp    文件:CorbaClientDelegateImpl.java   
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
项目:OpenJSharp    文件:CorbaClientDelegateImpl.java   
public void releaseReply(org.omg.CORBA.Object self, InputStream input)
{
    // NOTE: InputStream may be null (e.g., exception request from PI).
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    subcontract.endRequest(orb, self, (InputObject)input);
    orb.releaseOrDecrementInvocationInfo();
}
项目:OpenJSharp    文件:DynArrayImpl.java   
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;
}
项目:OpenJSharp    文件:DynUnionImpl.java   
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
项目:OpenJSharp    文件:DynSequenceImpl.java   
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

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

    length = input.read_long();
    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;
}
项目:OpenJSharp    文件:Util.java   
/**
 * 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();
}
项目:OpenJSharp    文件:CDROutputObject.java   
/** overrides create_input_stream from CDROutputStream */
public org.omg.CORBA.portable.InputStream create_input_stream()
{
    // XREVISIT
    return null;
    //return new XIIOPInputStream(orb(), getByteBuffer(), getIndex(),
        //isLittleEndian(), getMessageHeader(), conn);
}
项目:OpenJSharp    文件:ORBUtility.java   
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);
}
项目:OpenJSharp    文件:Utility.java   
/**
 * 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;
}
项目:OpenJSharp    文件:Utility.java   
/**
 * 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;
}
项目:OpenJSharp    文件:ObjectReferenceTemplateImpl.java   
/** 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()) ;
}
项目:OpenJSharp    文件:ObjectReferenceFactoryImpl.java   
/** Read the data into a (presumably) empty ObjectReferenceFactoryImpl.
* 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 ;

    iorTemplates = IORFactories.makeIORTemplateList( istr ) ;
}
项目:OpenJSharp    文件:Util.java   
/**
 * 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 static Object readAny(InputStream in) {

    if (utilDelegate != null) {
        return utilDelegate.readAny(in);
    }
    return null;
}
项目:openjdk-jdk10    文件:RequestImpl.java   
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()
    }
}
项目:openjdk-jdk10    文件:AnyImpl.java   
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;
}
项目:openjdk-jdk10    文件:AnyImpl.java   
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;
}
项目:openjdk-jdk10    文件:AnyImpl.java   
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;
}
项目:openjdk-jdk10    文件:ServerRequestImpl.java   
public ServerRequestImpl (CorbaMessageMediator req, ORB orb) {
    _opName = req.getOperationName();
    _ins    = (InputStream)req.getInputObject();
    _ctx    = null;         // if we support contexts, this would
                            // presumably also  be available on
                            // the server invocation
    _orb = orb;
    _wrapper = ORBUtilSystemException.get( orb,
        CORBALogDomains.OA_INVOCATION ) ;
}
项目:openjdk-jdk10    文件:SpecialMethod.java   
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;
}
项目:openjdk-jdk10    文件:CorbaClientDelegateImpl.java   
public InputStream invoke(org.omg.CORBA.Object self, OutputStream output)
    throws
        ApplicationException,
        RemarshalException
{
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    return (InputStream)
        subcontract.marshalingComplete((Object)self, (OutputObject)output);
}
项目:openjdk-jdk10    文件:CorbaClientDelegateImpl.java   
public void releaseReply(org.omg.CORBA.Object self, InputStream input)
{
    // NOTE: InputStream may be null (e.g., exception request from PI).
    ClientRequestDispatcher subcontract = getClientRequestDispatcher();
    subcontract.endRequest(orb, self, (InputObject)input);
    orb.releaseOrDecrementInvocationInfo();
}
项目:openjdk-jdk10    文件:DynArrayImpl.java   
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;
}
项目:openjdk-jdk10    文件:DynUnionImpl.java   
protected boolean initializeComponentsFromAny() {
    try {
        InputStream input = any.create_input_stream();
        Any discriminatorAny = DynAnyUtil.extractAnyFromStream(discriminatorType(), input, orb);
        discriminator = DynAnyUtil.createMostDerivedDynAny(discriminatorAny, orb, false);
        currentMemberIndex = currentUnionMemberIndex(discriminatorAny);
        Any memberAny = DynAnyUtil.extractAnyFromStream(memberType(currentMemberIndex), input, orb);
        currentMember = DynAnyUtil.createMostDerivedDynAny(memberAny, orb, false);
        components = new DynAny[] {discriminator, currentMember};
    } catch (InconsistentTypeCode ictc) { // impossible
    }
    return true;
}
项目:openjdk-jdk10    文件:DynSequenceImpl.java   
protected boolean initializeComponentsFromAny() {
    // This typeCode is of kind tk_sequence.
    TypeCode typeCode = any.type();
    int length;
    TypeCode contentType = getContentType();
    InputStream input;

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

    length = input.read_long();
    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;
}