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:
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
-
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)
-
-
-
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 wrapstreamCode
- 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 interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.DataOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int offset, int len) throws java.io.IOException
- Specified by:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classjava.io.DataOutputStream
- Throws:
java.io.IOException
-
-