Class XThreadInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.manifoldcf.connectorcommon.common.XThreadInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class XThreadInputStream extends java.io.InputStreamCross-thread input stream. Use this class when you have a helper thread reading from a socket, and you need the ability to read safely from a ManifoldCF worker thread.
-
-
Constructor Summary
Constructors Constructor Description XThreadInputStream()Constructor, from another source.XThreadInputStream(java.io.InputStream sourceStream)Constructor, from a given input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Call this method to abort the stuffQueue() method.intavailable()Get available.voidclose()Close.voiddoneStuffingQueue()Call this method when there is no more data to write.voidmark(int readLimit)Mark.booleanmarkSupported()Check if mark is supported.intread()Read a byte.intread(byte[] b)Read lots of bytes.intread(byte[] b, int off, int len)Read lots of specific bytes.voidreset()Reset.longskip(long n)SkipvoidstuffQueue()This method is called from the helper thread side, to keep the queue stuffed from the input stream.voidstuffQueue(byte[] byteBuffer, int offset, int amount)This method is called from the helper thread side, to stuff bytes onto the queue when there is no input stream.
-
-
-
Method Detail
-
abort
public void abort()
Call this method to abort the stuffQueue() method.
-
stuffQueue
public void stuffQueue(byte[] byteBuffer, int offset, int amount) throws java.lang.InterruptedExceptionThis method is called from the helper thread side, to stuff bytes onto the queue when there is no input stream. It exits only when interrupted or done.- Throws:
java.lang.InterruptedException
-
doneStuffingQueue
public void doneStuffingQueue()
Call this method when there is no more data to write.
-
stuffQueue
public void stuffQueue() throws java.io.IOException, java.lang.InterruptedExceptionThis method is called from the helper thread side, to keep the queue stuffed from the input stream. It exits when the stream is empty, or when interrupted.- Throws:
java.io.IOExceptionjava.lang.InterruptedException
-
read
public int read() throws java.io.IOExceptionRead a byte.- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOExceptionRead lots of bytes.- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionRead lots of specific bytes.- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOExceptionSkip- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOExceptionGet available.- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
mark
public void mark(int readLimit)
Mark.- Overrides:
markin classjava.io.InputStream
-
reset
public void reset() throws java.io.IOExceptionReset.- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
Check if mark is supported.- Overrides:
markSupportedin classjava.io.InputStream
-
close
public void close() throws java.io.IOExceptionClose.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-