1 7 package com.sun.corba.se.impl.encoding; 8 9 import java.nio.ByteBuffer ; 10 11 import com.sun.corba.se.impl.orbutil.ORBConstants; 12 import com.sun.corba.se.impl.protocol.giopmsgheaders.Message; 13 import com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase; 14 import com.sun.corba.se.impl.protocol.giopmsgheaders.FragmentMessage; 15 import com.sun.corba.se.impl.encoding.BufferManagerWrite; 16 import com.sun.corba.se.impl.encoding.ByteBufferWithInfo; 17 import com.sun.corba.se.impl.encoding.CDROutputObject; 18 import com.sun.corba.se.spi.orb.ORB; 19 import com.sun.corba.se.pept.transport.Connection; 20 import com.sun.corba.se.pept.encoding.OutputObject; 21 22 25 public class BufferManagerWriteStream extends BufferManagerWrite 26 { 27 private int fragmentCount = 0; 28 29 BufferManagerWriteStream( ORB orb ) 30 { 31 super(orb) ; 32 } 33 34 public boolean sentFragment() { 35 return fragmentCount > 0; 36 } 37 38 42 public int getBufferSize() { 43 return orb.getORBData().getGIOPFragmentSize(); 44 } 45 46 public void overflow (ByteBufferWithInfo bbwi) 47 { 48 MessageBase.setFlag(bbwi.byteBuffer, Message.MORE_FRAGMENTS_BIT); 50 51 sendFragment(false); 52 53 55 bbwi.position(0); 59 bbwi.buflen = bbwi.byteBuffer.limit(); 60 bbwi.fragmented = true; 61 62 64 67 FragmentMessage header = ((CDROutputObject)outputObject).getMessageHeader().createFragmentMessage(); 68 69 header.write(((CDROutputObject)outputObject)); 70 } 71 72 private void sendFragment(boolean isLastFragment) 73 { 74 Connection conn = ((OutputObject)outputObject).getMessageMediator().getConnection(); 75 76 conn.writeLock(); 79 80 try { 81 conn.sendWithoutLock(((OutputObject)outputObject)); 83 84 fragmentCount++; 85 86 } finally { 87 88 conn.writeUnlock(); 89 } 90 91 } 92 93 public void sendMessage () 95 { 96 sendFragment(true); 97 98 sentFullMessage = true; 99 } 100 101 106 public void close(){}; 107 108 } 109 | Popular Tags |