Package com.martiansoftware.nailgun
Class NGOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
com.martiansoftware.nailgun.NGOutputStream
- All Implemented Interfaces:
Closeable
,DataOutput
,Flushable
,AutoCloseable
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
FieldsFields inherited from class java.io.DataOutputStream
written
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionNGOutputStream
(OutputStream out, byte streamCode) Creates a new NGOutputStream wrapping the specified OutputStream and using the specified Nailgun chunk code. -
Method Summary
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
-
Field Details
-
lock
-
streamCode
private byte streamCode
-
-
Constructor Details
-
NGOutputStream
Creates a new NGOutputStream wrapping the specified OutputStream and using the specified Nailgun chunk code.- Parameters:
out
- the OutputStream to wrapstreamCode
- the NailGun chunk code associated with this stream (i.e., '1' for stdout, '2' for stderr).
-
-
Method Details
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classDataOutputStream
- Throws:
IOException
-
write
- Specified by:
write
in interfaceDataOutput
- Overrides:
write
in classDataOutputStream
- Throws:
IOException
-