public abstract class HttpInput<T> extends ServletInputStream
HttpInput
provides an implementation of ServletInputStream
for HttpChannel
.
HttpInput
holds a queue of items passed to it by calls to #content(T)
.
HttpInput
stores the items directly; if the items contain byte buffers, it does not copy them
but simply holds references to the item, thus the caller must organize for those buffers to valid while
held by this class.
To assist the caller, subclasses may override methods #onContentQueued(T)
,
#onContentConsumed(T)
and onAllContentConsumed()
that can be implemented so that the
caller will know when buffers are queued and consumed.
Modifier and Type | Field and Description |
---|---|
protected boolean |
_earlyEOF |
protected boolean |
_inputEOF |
Constructor and Description |
---|
HttpInput() |
Modifier and Type | Method and Description |
---|---|
int |
available() |
protected void |
blockForContent() |
void |
consumeAll() |
void |
content(T item)
Add some content to the input stream
|
void |
earlyEOF()
This method should be called to signal to the HttpInput
that an EOF has arrived before all the expected content.
|
protected abstract int |
get(T item,
byte[] buffer,
int offset,
int length) |
boolean |
isEarlyEOF() |
boolean |
isShutdown() |
Object |
lock() |
protected void |
onAllContentConsumed()
Called by this HttpInput to signal all available content has been consumed
|
protected abstract void |
onContentConsumed(T item) |
protected void |
onContentQueued(T item)
Called by this HttpInput to signal new content has been queued
|
protected void |
onEOF()
Called by this HttpInput to signal it has reached EOF
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
recycle() |
protected abstract int |
remaining(T item) |
void |
shutdown() |
isFinished, isReady, readLine, setReadListener
close, mark, markSupported, read, reset, skip
public Object lock()
public void recycle()
public int read() throws IOException
read
in class InputStream
IOException
public int available()
available
in class InputStream
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
protected abstract int remaining(T item)
protected abstract int get(T item, byte[] buffer, int offset, int length)
protected abstract void onContentConsumed(T item)
protected void blockForContent() throws IOException
IOException
protected void onContentQueued(T item)
item
- protected void onAllContentConsumed()
protected void onEOF()
public void content(T item)
item
- public void earlyEOF()
public boolean isEarlyEOF()
public void shutdown()
public boolean isShutdown()
public void consumeAll()
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.