Package org.restlet.ext.nio.internal.way
Class OutboundWay
- java.lang.Object
-
- org.restlet.ext.nio.internal.way.Way
-
- org.restlet.ext.nio.internal.way.OutboundWay
-
- All Implemented Interfaces:
BufferProcessor,CompletionListener,SelectionListener
- Direct Known Subclasses:
ClientOutboundWay,ServerOutboundWay
@Deprecated public abstract class OutboundWay extends Way
Deprecated.Will be removed to favor lower-level network extensions allowing more control at the Restlet API level.A network connection way though which messages are sent. Messages can be either requests or responses.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.ReadableByteChannelentityChannelDeprecated.The entity as a NIO readable byte channel.private EntityTypeentityChannelTypeDeprecated.The type of the entity channel.private java.nio.channels.SelectionKeyentitySelectionKeyDeprecated.The entity's NIO selection key holding the link between the entity to be written and the way.private intheaderIndexDeprecated.The header index.
-
Constructor Summary
Constructors Constructor Description OutboundWay(Connection<?> connection, int bufferSize)Deprecated.Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddEntityHeaders(Representation entity, Series<Header> headers)Deprecated.Adds the entity headers for the given response.protected voidaddGeneralHeaders(Series<Header> headers)Deprecated.protected abstract voidaddHeaders(Series<Header> headers)Deprecated.Add all the headers, including the general, the message specific and the entity headers.voidclear()Deprecated.Recycles the way so it can be reused.voidflushBuffer()Deprecated.Flush buffers onto the network.java.nio.channels.ReadableByteChannelgetEntityChannel()Deprecated.Returns the entity as a NIO readable byte channel.protected EntityTypegetEntityChannelType()Deprecated.Returns the type of the entity channel.java.nio.channels.FileChannelgetEntityFileChannel()Deprecated.Returns the entity as a NIO file channel.intgetEntityInterestOps()Deprecated.Registers interest of this way for socket NIO operations.java.nio.channels.SelectableChannelgetEntitySelectableChannel()Deprecated.Returns the entity as a NIO non-blocking selectable channel.java.nio.channels.SelectionKeygetEntitySelectionKey()Deprecated.Returns the entity's NIO selection key holding the link between the entity to be written and the way.protected intgetHeaderIndex()Deprecated.Returns the header index.intgetInterestOperations()Deprecated.Returns the operations of interest.protected static java.lang.StringgetVersion(Request request)Deprecated.Returns the protocol version.abstract voidhandle(Response response)Deprecated.Add a message to the outbound way.protected booleanhasIoInterest()Deprecated.Indicates if we want to be selected for IO processing when the socket related socket is prepared.intonDrain(Buffer buffer, int maxDrained, java.lang.Object... args)Deprecated.Drains the byte buffer by writing available bytes to the socket channel.voidonError(Status status)Deprecated.Called on error.intonFill(Buffer buffer, java.lang.Object... args)Deprecated.Fills the byte buffer by writing the current message.voidonFillEof()Deprecated.Called back when a fill operation returns with an EOF status.voidonHeadersCompleted()Deprecated.Callback invoked when a message has been sent.voidonMessageCompleted(boolean endReached)Deprecated.Callback method invoked when the current message has been completely received or sent.protected voidonPostProcessing()Deprecated.Called back after the IO processing to indicate if there is further IO interest.voidonTimeOut()Deprecated.Called back by the controller when an IO time out has been detected.intprocessIoBuffer()Deprecated.Processes the IO buffer by filling and draining it.voidsetEntityChannel(java.nio.channels.ReadableByteChannel entityChannel)Deprecated.Sets the entity as a NIO readable byte channel.protected voidsetEntityChannelType(EntityType entityChannelType)Deprecated.Sets the type of the entity channel.voidsetEntitySelectionKey(java.nio.channels.SelectionKey entityKey)Deprecated.Sets the entity's NIO selection key holding the link between the entity to be written and the way.protected voidsetHeaderIndex(int headerIndex)Deprecated.Sets the header index.protected booleanshouldBeChunked(Representation entity)Deprecated.Indicates if the entity should be chunked because its length is unknown.voidupdateState()Deprecated.Updates the way IO and message states.protected voidwriteLine()Deprecated.Write a new line into the line builder.protected abstract voidwriteStartLine()Deprecated.Writes the start line of the current outbound message.-
Methods inherited from class org.restlet.ext.nio.internal.way.Way
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, toString
-
-
-
-
Field Detail
-
entityChannel
private volatile java.nio.channels.ReadableByteChannel entityChannel
Deprecated.The entity as a NIO readable byte channel.
-
entityChannelType
private volatile EntityType entityChannelType
Deprecated.The type of the entity channel.
-
entitySelectionKey
private volatile java.nio.channels.SelectionKey entitySelectionKey
Deprecated.The entity's NIO selection key holding the link between the entity to be written and the way.
-
headerIndex
private volatile int headerIndex
Deprecated.The header index.
-
-
Constructor Detail
-
OutboundWay
public OutboundWay(Connection<?> connection, int bufferSize)
Deprecated.Constructor.- Parameters:
connection- The parent connection.bufferSize- The byte buffer size.
-
-
Method Detail
-
getVersion
protected static java.lang.String getVersion(Request request)
Deprecated.Returns the protocol version.- Parameters:
request- The request.- Returns:
- The protocol version.
-
addEntityHeaders
protected void addEntityHeaders(Representation entity, Series<Header> headers)
Deprecated.Adds the entity headers for the given response.- Parameters:
entity- The entity to inspect.
-
addGeneralHeaders
protected void addGeneralHeaders(Series<Header> headers)
Deprecated.- Parameters:
headers- The target headersSeries.
-
addHeaders
protected abstract void addHeaders(Series<Header> headers)
Deprecated.Add all the headers, including the general, the message specific and the entity headers.- Parameters:
headers- The headers to update.
-
clear
public void clear()
Deprecated.Description copied from class:WayRecycles the way so it can be reused. Typically invoked by a connection pool.
-
flushBuffer
public void flushBuffer()
Deprecated.Flush buffers onto the network.
-
getEntityChannel
public java.nio.channels.ReadableByteChannel getEntityChannel()
Deprecated.Returns the entity as a NIO readable byte channel.- Returns:
- The entity as a NIO readable byte channel.
-
getEntityChannelType
protected EntityType getEntityChannelType()
Deprecated.Returns the type of the entity channel.- Returns:
- The type of the entity channel.
-
getEntityFileChannel
public java.nio.channels.FileChannel getEntityFileChannel()
Deprecated.Returns the entity as a NIO file channel.- Returns:
- The entity as a NIO file channel.
-
getEntityInterestOps
public int getEntityInterestOps()
Deprecated.Registers interest of this way for socket NIO operations.- Returns:
- The operations of interest.
-
getEntitySelectableChannel
public java.nio.channels.SelectableChannel getEntitySelectableChannel()
Deprecated.Returns the entity as a NIO non-blocking selectable channel.- Returns:
- The entity as a NIO non-blocking selectable channel.
-
getEntitySelectionKey
public java.nio.channels.SelectionKey getEntitySelectionKey()
Deprecated.Returns the entity's NIO selection key holding the link between the entity to be written and the way.- Returns:
- The entity's NIO selection key.
-
getHeaderIndex
protected int getHeaderIndex()
Deprecated.Returns the header index.- Returns:
- The header index.
-
getInterestOperations
public int getInterestOperations()
Deprecated.Description copied from class:WayReturns the operations of interest.- Specified by:
getInterestOperationsin classWay- Returns:
- The operations of interest.
-
handle
public abstract void handle(Response response)
Deprecated.Add a message to the outbound way.- Parameters:
response-
-
hasIoInterest
protected boolean hasIoInterest()
Deprecated.Description copied from class:WayIndicates if we want to be selected for IO processing when the socket related socket is prepared.- Overrides:
hasIoInterestin classWay- Returns:
- True if we want to be selected for IO processing when the socket is ready.
-
onDrain
public int onDrain(Buffer buffer, int maxDrained, java.lang.Object... args) throws java.io.IOException
Deprecated.Description copied from class:WayDrains the byte buffer by writing available bytes to the socket channel.- Specified by:
onDrainin interfaceBufferProcessor- Specified by:
onDrainin classWay- Parameters:
buffer- 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.- Returns:
- The number of bytes drained.
- Throws:
java.io.IOException
-
onError
public void onError(Status status)
Deprecated.Description copied from class:WayCalled on error.
-
onFill
public int onFill(Buffer buffer, java.lang.Object... args) throws java.io.IOException
Deprecated.Description copied from class:WayFills the byte buffer by writing the current message.- Specified by:
onFillin interfaceBufferProcessor- Specified by:
onFillin classWay- Parameters:
buffer- The IO buffer to drain.args- The optional arguments to pass back to the callbacks.- Returns:
- The number of bytes filled.
- Throws:
java.io.IOException
-
onFillEof
public void onFillEof()
Deprecated.Called back when a fill operation returns with an EOF status.
-
onHeadersCompleted
public void onHeadersCompleted() throws java.io.IOExceptionDeprecated.Callback invoked when a message has been sent. Note that only the start line and the headers must have been sent, not the optional body.- Specified by:
onHeadersCompletedin classWay- Throws:
java.io.IOException
-
onMessageCompleted
public void onMessageCompleted(boolean endReached) throws java.io.IOExceptionDeprecated.Description copied from class:WayCallback method invoked when the current message has been completely received or sent.- Specified by:
onMessageCompletedin interfaceCompletionListener- Overrides:
onMessageCompletedin classWay- Parameters:
endReached- Indicates if the end of the socket channel was detected.- Throws:
java.io.IOException
-
onPostProcessing
protected void onPostProcessing()
Deprecated.Description copied from class:WayCalled back after the IO processing to indicate if there is further IO interest. By default, it sets the IO state toIoState.INTEREST.- Specified by:
onPostProcessingin classWay
-
onTimeOut
public void onTimeOut()
Deprecated.Description copied from class:WayCalled back by the controller when an IO time out has been detected.
-
processIoBuffer
public int processIoBuffer() throws java.io.IOExceptionDeprecated.Description copied from class:WayProcesses the IO buffer by filling and draining it.- Overrides:
processIoBufferin classWay- Throws:
java.io.IOException
-
setEntityChannel
public void setEntityChannel(java.nio.channels.ReadableByteChannel entityChannel)
Deprecated.Sets the entity as a NIO readable byte channel.- Parameters:
entityChannel- The entity as a NIO readable byte channel.
-
setEntityChannelType
protected void setEntityChannelType(EntityType entityChannelType)
Deprecated.Sets the type of the entity channel.- Parameters:
entityChannelType- The type of the entity channel.
-
setEntitySelectionKey
public void setEntitySelectionKey(java.nio.channels.SelectionKey entityKey)
Deprecated.Sets the entity's NIO selection key holding the link between the entity to be written and the way.- Parameters:
entityKey- The entity's NIO selection key.
-
setHeaderIndex
protected void setHeaderIndex(int headerIndex)
Deprecated.Sets the header index.- Parameters:
headerIndex- The header index.
-
shouldBeChunked
protected boolean shouldBeChunked(Representation entity)
Deprecated.Indicates if the entity should be chunked because its length is unknown.- Parameters:
entity- The entity to analyze.- Returns:
- True if the entity should be chunked.
-
updateState
public void updateState()
Deprecated.Description copied from class:WayUpdates the way IO and message states.- Overrides:
updateStatein classWay
-
writeLine
protected void writeLine() throws java.io.IOExceptionDeprecated.Write a new line into the line builder.- Throws:
java.io.IOException
-
writeStartLine
protected abstract void writeStartLine() throws java.io.IOExceptionDeprecated.Writes the start line of the current outbound message.- Throws:
java.io.IOException
-
-