Class NGOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable

    class NGOutputStream
    extends java.io.DataOutputStream
    Wraps an OutputStream to send writes in NailGun chunks. Because multiple NGOutputStreams wrap the same OutputStream (that is, the OutputStream obtained from the Socket connection with the client), writes are synchronized on the underlying OutputStream. If this were not the case, write interleaving could completely break the NailGun protocol.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Object lock  
      private byte streamCode  
      • Fields inherited from class java.io.DataOutputStream

        written
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      NGOutputStream​(java.io.OutputStream out, byte streamCode)
      Creates a new NGOutputStream wrapping the specified OutputStream and using the specified Nailgun chunk code.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void write​(byte[] b)  
      void write​(byte[] b, int offset, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.DataOutputStream

        flush, size, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
      • Methods inherited from class java.io.FilterOutputStream

        close
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lock

        private final java.lang.Object lock
      • streamCode

        private byte streamCode
    • Constructor Detail

      • NGOutputStream

        public NGOutputStream​(java.io.OutputStream out,
                              byte streamCode)
        Creates a new NGOutputStream wrapping the specified OutputStream and using the specified Nailgun chunk code.
        Parameters:
        out - the OutputStream to wrap
        streamCode - the NailGun chunk code associated with this stream (i.e., '1' for stdout, '2' for stderr).
    • Method Detail

      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Specified by:
        write in interface java.io.DataOutput
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in interface java.io.DataOutput
        Overrides:
        write in class java.io.DataOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int offset,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in interface java.io.DataOutput
        Overrides:
        write in class java.io.DataOutputStream
        Throws:
        java.io.IOException