public abstract class OutboundWay extends Way
| Constructor and Description |
|---|
OutboundWay(Connection<?> connection,
int bufferSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEntityHeaders(Representation entity,
Series<Header> headers)
Adds the entity headers for the given response.
|
protected void |
addGeneralHeaders(Series<Header> headers)
|
protected abstract void |
addHeaders(Series<Header> headers)
Add all the headers, including the general, the message specific and the
entity headers.
|
void |
clear()
Recycles the way so it can be reused.
|
void |
flushBuffer()
Flush buffers onto the network.
|
ReadableByteChannel |
getEntityChannel()
Returns the entity as a NIO readable byte channel.
|
protected EntityType |
getEntityChannelType()
Returns the type of the entity channel.
|
FileChannel |
getEntityFileChannel()
Returns the entity as a NIO file channel.
|
int |
getEntityInterestOps()
Registers interest of this way for socket NIO operations.
|
SelectableChannel |
getEntitySelectableChannel()
Returns the entity as a NIO non-blocking selectable channel.
|
SelectionKey |
getEntitySelectionKey()
Returns the entity's NIO selection key holding the link between the
entity to be written and the way.
|
protected int |
getHeaderIndex()
Returns the header index.
|
int |
getInterestOperations()
Returns the operations of interest.
|
protected static String |
getVersion(Request request)
Returns the protocol version.
|
abstract void |
handle(Response response)
Add a message to the outbound way.
|
protected boolean |
hasIoInterest()
Indicates if we want to be selected for IO processing when the socket
related socket is prepared.
|
int |
onDrain(Buffer buffer,
int maxDrained,
Object... args)
Drains the byte buffer by writing available bytes to the socket channel.
|
void |
onError(Status status)
Called on error.
|
int |
onFill(Buffer buffer,
Object... args)
Fills the byte buffer by writing the current message.
|
void |
onFillEof()
Called back when a fill operation returns with an EOF status.
|
void |
onHeadersCompleted()
Callback invoked when a message has been sent.
|
void |
onMessageCompleted(boolean endReached)
Callback method invoked when the current message has been completely
received or sent.
|
protected void |
onPostProcessing()
Called back after the IO processing to indicate if there is further IO
interest.
|
void |
onTimeOut()
Called back by the controller when an IO time out has been detected.
|
int |
processIoBuffer()
Processes the IO buffer by filling and draining it.
|
void |
setEntityChannel(ReadableByteChannel entityChannel)
Sets the entity as a NIO readable byte channel.
|
protected void |
setEntityChannelType(EntityType entityChannelType)
Sets the type of the entity channel.
|
void |
setEntitySelectionKey(SelectionKey entityKey)
Sets the entity's NIO selection key holding the link between the entity
to be written and the way.
|
protected void |
setHeaderIndex(int headerIndex)
Sets the header index.
|
protected boolean |
shouldBeChunked(Representation entity)
Indicates if the entity should be chunked because its length is unknown.
|
void |
updateState()
Updates the way IO and message states.
|
protected void |
writeLine()
Write a new line into the line builder.
|
protected abstract void |
writeStartLine()
Writes the start line of the current outbound message.
|
canLoop, clearLineBuilder, couldDrain, couldFill, getActualMessage, getBuffer, getConnection, getHeaders, getHelper, getIoState, getLineBuilder, getLineBuilderState, getLoadScore, getLogger, getMessage, getMessageState, getRegistration, isAvailable, isEmpty, onClosed, onSelected, postProcess, preProcess, setHeaders, setIoState, setLineBuilderState, setMessage, setMessageState, setRegistration, toStringpublic OutboundWay(Connection<?> connection, int bufferSize)
connection - The parent connection.bufferSize - The byte buffer size.protected static String getVersion(Request request)
request - The request.protected void addEntityHeaders(Representation entity, Series<Header> headers)
entity - The entity to inspect.protected void addGeneralHeaders(Series<Header> headers)
headers - The target headers Series.protected abstract void addHeaders(Series<Header> headers)
headers - The headers to update.public void clear()
Waypublic void flushBuffer()
public ReadableByteChannel getEntityChannel()
protected EntityType getEntityChannelType()
public FileChannel getEntityFileChannel()
public int getEntityInterestOps()
public SelectableChannel getEntitySelectableChannel()
public SelectionKey getEntitySelectionKey()
protected int getHeaderIndex()
public int getInterestOperations()
WaygetInterestOperations in class Waypublic abstract void handle(Response response)
response - protected boolean hasIoInterest()
WayhasIoInterest in class Waypublic int onDrain(Buffer buffer, int maxDrained, Object... args) throws IOException
WayonDrain in interface BufferProcessoronDrain in class Waybuffer - The IO buffer to drain.maxDrained - The maximum number of bytes drained by this call.args - The optional arguments to pass back to the callbacks.IOExceptionpublic int onFill(Buffer buffer, Object... args) throws IOException
WayonFill in interface BufferProcessoronFill in class Waybuffer - The IO buffer to drain.args - The optional arguments to pass back to the callbacks.IOExceptionpublic void onFillEof()
public void onHeadersCompleted()
throws IOException
onHeadersCompleted in class WayIOExceptionpublic void onMessageCompleted(boolean endReached)
throws IOException
WayonMessageCompleted in interface CompletionListeneronMessageCompleted in class WayendReached - Indicates if the end of the socket channel was detected.IOExceptionprotected void onPostProcessing()
WayIoState.INTEREST.onPostProcessing in class Waypublic void onTimeOut()
Waypublic int processIoBuffer()
throws IOException
WayprocessIoBuffer in class WayIOExceptionpublic void setEntityChannel(ReadableByteChannel entityChannel)
entityChannel - The entity as a NIO readable byte channel.protected void setEntityChannelType(EntityType entityChannelType)
entityChannelType - The type of the entity channel.public void setEntitySelectionKey(SelectionKey entityKey)
entityKey - The entity's NIO selection key.protected void setHeaderIndex(int headerIndex)
headerIndex - The header index.protected boolean shouldBeChunked(Representation entity)
entity - The entity to analyze.public void updateState()
WayupdateState in class Wayprotected void writeLine()
throws IOException
IOExceptionprotected abstract void writeStartLine()
throws IOException
IOExceptionCopyright © 2005–2015. All rights reserved.