Package org.jacorb.orb

Examples of org.jacorb.orb.CDROutputStream


        checkDestroyed ();
        org.jacorb.orb.Any out_any =
            (org.jacorb.orb.Any)orb.create_any();
        out_any.type( type());

        CDROutputStream out = new CDROutputStream();

        if( type().kind().value() == org.omg.CORBA.TCKind._tk_except )
        {
            out.write_string( exceptionMsg );
        }

        for( int i = 0; i < members.length; i++)
        {
            out.write_value( members[i].value.type(),
                             members[i].value.create_input_stream());
        }

        CDRInputStream is = new CDRInputStream(orb, out.getBufferCopy());
        out_any.read_value( is, type());
        return out_any;
    }
View Full Code Here


    }

    public byte[] encode(Any data)
        throws InvalidTypeForEncoding
    {
        CDROutputStream out = new CDROutputStream(orb);

        out.beginEncapsulatedArray();
        out.write_any(data);

        /*
          closing must not be done, since it will patch the
          array with a size!
        try
        {
            out.endEncapsulation();
        }
        catch (java.io.IOException e)
        {
        }
        */

        /*
         * We have to copy anyway since we need an exact-sized array.
         * Closing afterwards, to return buffer to BufferManager.
         */
        byte[] result = out.getBufferCopy();
        out.close();

        return result;
    }
View Full Code Here

    public byte[] encode_value(Any data)
        throws InvalidTypeForEncoding
    {

        CDROutputStream out = new CDROutputStream(orb);

        out.beginEncapsulatedArray();
        data.write_value(out);

        /*
          closing must not be done, since it will patch the
          array with a size!

        try
        {
            out.endEncapsulation();
        }
        catch (java.io.IOException e)
        {
        }
        */

        /*
         * We have to copy anyway since we need an exact-sized array.
         * Closing afterwards, to return buffer to BufferManager.
         */
        byte[] result = out.getBufferCopy();
        out.close();

        return result;
    }
View Full Code Here

    protected void setUp() throws Exception
    {
        super.setUp();
       
        orb = ORB.init(new String[0], null);
        objectUnderTest = new CDROutputStream(orb);
    }
View Full Code Here

                CompoundSecMechList compoundSecMechList =
                    new CompoundSecMechList(useStateful, compoundSecMech);

                // export to tagged component
                CDROutputStream sasDataStream = new CDROutputStream( orb );
                sasDataStream.beginEncapsulatedArray();
                CompoundSecMechListHelper.write( sasDataStream , compoundSecMechList );
                tc = new TaggedComponent( TAG_CSI_SEC_MECH_LIST.value,
                                          sasDataStream.getBufferCopy() );

                sasDataStream.close ();
                sasDataStream = null;
            }

            info.add_ior_component_to_profile (tc, TAG_INTERNET_IOP.value);
        }
View Full Code Here

            propname =
                "jacorb.security.ssl.corbaloc_ssliop.required_options";
            ssl.target_requires = get_ssl_options(propname);

            //create the tagged component containing the ssl struct
            CDROutputStream out = new CDROutputStream();
            out.beginEncapsulatedArray();
            SSLHelper.write( out, ssl );

            // TAG_SSL_SEC_TRANS must be disambiguated in case OpenORB-generated
            // OMG classes are in the classpath.
            components.addComponent
                (new TaggedComponent( org.omg.SSLIOP.TAG_SSL_SEC_TRANS.value,
                                      out.getBufferCopy() )
                 );
        }
    }
View Full Code Here

            // The CDROutputStream only does big endian currently.
            throw new Error("We can only marshal big endian stylee profiles !!");
        }
       
        // Start a CDR encapsulation for the profile_data
        CDROutputStream profileDataStream = new CDROutputStream();
        profileDataStream.beginEncapsulatedArray();
       
        // Write the opaque AddressProfile bytes for this profile...
        writeAddressProfile(profileDataStream);
       
        // ... then the object key
        profileDataStream.write_long(objectKey.length);
        profileDataStream.write_octet_array(objectKey,0,objectKey.length);
       
        switch( version.minor )
        {
            case 0 :
                // For GIOP 1.0 there were no tagged components
                break;
            default :
                // Assume minor != 0 means 1.1 onwards and encode the TaggedComponents
                if (components == null)
                {
                    components = new TaggedComponentSeqHolder (new TaggedComponent[0]);
                }
                // Write the length of the TaggedProfile sequence.
                profileDataStream.write_long(this.components.size() + components.value.length);
               
                // Write the TaggedProfiles (ours first, then the ORB's)
                for (int i = 0; i < this.components.asArray().length; i++)
                {
                    TaggedComponentHelper.write(profileDataStream, this.components.asArray()[i]);
                }
                for (int i = 0; i < components.value.length; i++)
                {
                    TaggedComponentHelper.write(profileDataStream, components.value[i]);
                }       
        }
       
        // Populate the TaggedProfile for return.
        tagged_profile.value = new TaggedProfile
        (
            this.tag(),
            profileDataStream.getBufferCopy()
        );
    }
View Full Code Here

    public abstract void write (CDROutputStream s);

    public byte [] toCDR ()
    {
      CDROutputStream out = new CDROutputStream();
      out.beginEncapsulatedArray();
      this.write(out);
      return out.getBufferCopy();
    }
View Full Code Here

    }

    public void write_to( GIOPConnection conn )
        throws IOException
    {
        CDROutputStream ctx_out = null;

        if( contexts == null || contexts.size() == 0 )
        {
            //no additional service contexts present, so buffer can be
            //sent as a whole
            insertMsgSize();
            write( conn, 0, size() );
        }
        else
        {
            switch( giop_minor )
            {
                case 0 :
                {
                    // GIOP 1.0 (== GIOP 1.1, fall through)
                }
                case 1 :
                {
                    //GIOP 1.1

                    //First of all, we need to know the the length of
                    //the service context array

                    //For GIOP 1.1, we have to add a padding context
                    contexts.addElement( padding_ctx );

                    ctx_out = createContextStream();

                    //difference to next 8 byte border

                    // Need to calculate whether the service context needs any
                    // padding. This is the difference. To calculate this need
                    // to add the new CDRStream and the header size - this
                    // should end on an 8 byte boundary.
                    int difference =
                        (8 - ((Messages.MSG_HEADER_SIZE + ctx_out.size ()) % 8));
                    difference = (difference == 8)? 0 : difference;

                    if( difference > 0 )
                    {
                        //the last padding context has a 0 length data
                        //part. Therefore, the last data is a ulong
                        //with value 0 (the length of the array). To
                        //increase the data part, we have to increase
                        //the size and add the actual data.

                        //"unwrite" the last ulong
                        ctx_out.reduceSize( 4 );

                        //write new length
                        ctx_out.write_ulong( difference );

                        //add "new" data (by just increasing the size
                        //of the stream and not actually writing
                        //anything).
                        ctx_out.increaseSize( difference );
                    }

                    //Then, we have to update the message size in the GIOP
                    //message header. The new size is the size of the
                    //"original" message minus the length ulong (4 bytes) of
                    //the original empty ServiceContext array plus the length
                    //of the new service context array
                    insertMsgSize( size()
                                   - Messages.MSG_HEADER_SIZE
                                   - 4
                                   + ctx_out.size() );


                    //The ServiceContexts are the first attribute in
                    //the RequestHeader struct. Therefore firstly, we
                    //have to write the GIOP message header...
                    write( conn, 0, Messages.MSG_HEADER_SIZE );

                    //... then add the contexts ...
                    ctx_out.write( conn, 0, ctx_out.size() );

                    //... and finally the rest of the message
                    //(omitting the empty original context array).

                    write( conn,
                           Messages.MSG_HEADER_SIZE + 4,
                           size() -
                           (Messages.MSG_HEADER_SIZE + 4) );
                    break;
                }
                case 2 :
                {
                    //GIOP 1.2

                    //First of all, we need to know the the length of
                    //the service context array

                    //For GIOP 1.2, the header is padded per spec, so
                    //no additional context is needed

                    ctx_out = createContextStream();

                    //the new header end is the old header end minus
                    //the length ulong of the context array plus the
                    //length of the context array (wich contains its
                    //own length ulong)
                    int new_header_end = getHeaderEnd() - 4 + ctx_out.size();

                    //difference to next 8 byte border
                    int difference =  8 - (new_header_end % 8);
                    difference = (difference == 8)? 0 : difference;

                    if( difference > && hasBody() )
                    {
                        //add padding bytes (by just increasing the
                        //size of the stream and not actually writing
                        //anything). If no body is present, no padding
                        //has to be inserted
                        ctx_out.increaseSize( difference );
                    }

                    //Then, we have to update the message size in the
                    //GIOP message header. The new size is the size of
                    //the "original" message minus the length ulong (4
                    //bytes) of the original empty ServiceContext
                    //array minus the "original" header padding plus
                    //the length of the new service context array
                    //(containing the new padding)
                    insertMsgSize( size()
                                   - Messages.MSG_HEADER_SIZE
                                   - 4
                                   - getHeaderPadding()
                                   + ctx_out.size() );

                    //The GIOP message and request header (up until
                    //the ServiceContexts) stay unmanipulated. We also
                    //have to remove the length ulong of the
                    //"original" empty service context array, because
                    //the new one has its own length attribute
                    write( conn,
                           0,
                           getHeaderEnd() - 4 );

                    //... then add the contexts ...

                    ctx_out.write( conn, 0, ctx_out.size());

                    //... and finally the rest of the message
                    //(omitting the empty original context array).

                    write( conn,
                           getBodyBegin(),
                           size() - getBodyBegin() );

                    break;
                }
                default :
                {
                    throw new MARSHAL( "Unknown GIOP minor: " + giop_minor );
                }
            }
        }
        close();
        if ( ctx_out != null )
        {
            ctx_out.close();
            ctx_out = null;
        }
    }
View Full Code Here

    }


    private CDROutputStream createContextStream()
    {
        CDROutputStream out = new CDROutputStream( (org.omg.CORBA.ORB) null );

        //write the length of the service context array.
        out.write_ulong( contexts.size() );

        for( int i = 0; i < contexts.size(); i++ )
        {
            ServiceContextHelper.write( out,
                                        (ServiceContext) contexts.elementAt( i ));
View Full Code Here

TOP

Related Classes of org.jacorb.orb.CDROutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.