// Enqueue the last fragment
queue.enqueue(((CDROutputObject)outputObject).getByteBufferWithInfo());
Iterator bufs = iterator();
Connection conn =
((OutputObject)outputObject).getMessageMediator().
getConnection();
// With the collect strategy, we must lock the connection
// while fragments are being sent. This is so that there are
// no interleved fragments in GIOP 1.1.
//
// Note that this thread must not call writeLock again in any
// of its send methods!
conn.writeLock();
try {
// Get a reference to ByteBufferPool so that the ByteBufferWithInfo
// ByteBuffer can be released to the ByteBufferPool
ByteBufferPool byteBufferPool = orb.getByteBufferPool();
while (bufs.hasNext()) {
ByteBufferWithInfo bbwi = (ByteBufferWithInfo)bufs.next();
((CDROutputObject)outputObject).setByteBufferWithInfo(bbwi);
conn.sendWithoutLock(((CDROutputObject)outputObject));
sentFragment = true;
// Release ByteBufferWithInfo's ByteBuffer back to the pool
// of ByteBuffers.
if (debug)
{
// print address of ByteBuffer being released
int bbAddress = System.identityHashCode(bbwi.byteBuffer);
StringBuffer sb = new StringBuffer(80);
sb.append("sendMessage() - releasing ByteBuffer id (");
sb.append(bbAddress).append(") to ByteBufferPool.");
String msg = sb.toString();
dprint(msg);
}
byteBufferPool.releaseByteBuffer(bbwi.byteBuffer);
bbwi.byteBuffer = null;
bbwi = null;
}
sentFullMessage = true;
} finally {
conn.writeUnlock();
}
}