FileDocCategorySizeDatePackage
BufferManagerWriteStream.javaAPI DocJava SE 5 API3008Fri Aug 26 14:54:20 BST 2005com.sun.corba.se.impl.encoding

BufferManagerWriteStream

public class BufferManagerWriteStream extends BufferManagerWrite
Streaming buffer manager.

Fields Summary
private int
fragmentCount
Constructors Summary
BufferManagerWriteStream(ORB orb)


       
    
	super(orb) ;
    
Methods Summary
public voidclose()
Close the BufferManagerWrite and do any outstanding cleanup. No work to do for a BufferManagerWriteStream

public intgetBufferSize()
Returns the correct buffer size for this type of buffer manager as set in the ORB.

        return orb.getORBData().getGIOPFragmentSize();
    
public voidoverflow(com.sun.corba.se.impl.encoding.ByteBufferWithInfo bbwi)

        // Set the fragment's moreFragments field to true
        MessageBase.setFlag(bbwi.byteBuffer, Message.MORE_FRAGMENTS_BIT);

        sendFragment(false);

        // Reuse the old buffer

        // REVISIT - need to account for case when needed > available
        // even after fragmenting.  This is the large array case, so
        // the caller should retry when it runs out of space.
        bbwi.position(0);
        bbwi.buflen = bbwi.byteBuffer.limit();
        bbwi.fragmented = true;

        // Now we must marshal in the fragment header/GIOP header

        // REVISIT - we can optimize this by not creating the fragment message
        // each time.  

        FragmentMessage header = ((CDROutputObject)outputObject).getMessageHeader().createFragmentMessage();

        header.write(((CDROutputObject)outputObject));
    
private voidsendFragment(boolean isLastFragment)

        Connection conn = ((OutputObject)outputObject).getMessageMediator().getConnection();

	// REVISIT: need an ORB
	//System.out.println("sendFragment: last?: " + isLastFragment);
        conn.writeLock();

        try {
            // Send the fragment
            conn.sendWithoutLock(((OutputObject)outputObject));

            fragmentCount++;

        } finally {

            conn.writeUnlock();
        }

    
public voidsendMessage()

        sendFragment(true);

        sentFullMessage = true;
    
public booleansentFragment()

        return fragmentCount > 0;