@ Override public void encode ( final BsonWriter writer , final DBObject document , final EncoderContext encoderContext ) { BasicOutputBuffer buffer = new BasicOutputBuffer ( ) ; try { encoder . writeObject ( buffer , document ) ; BsonBinaryReader reader = new BsonBinaryReader ( new ByteBufferBsonInput ( new ByteBufNIO ( wrap ( buffer . toByteArray ( ) ) ) ) ) ; try { writer . pipe ( reader ) ; } finally { reader . close ( ) ; } } finally { buffer . close ( ) ; } }
over an array of ByteBuffer instances from a PooledByteBufferOutputBuffer