Package org.restlet.ext.nio.internal.way
Class Way
- java.lang.Object
-
- org.restlet.ext.nio.internal.way.Way
-
- All Implemented Interfaces:
BufferProcessor,CompletionListener,SelectionListener
- Direct Known Subclasses:
InboundWay,OutboundWay
@Deprecated public abstract class Way extends java.lang.Object implements SelectionListener, CompletionListener, BufferProcessor
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 exchanged. Messages can be either sent or received, requests or responses.
-
-
Field Summary
Fields Modifier and Type Field Description private BufferbufferDeprecated.The IO buffer.private Connection<?>connectionDeprecated.The parent connection.private Series<Header>headersDeprecated.The message headers.private IoStateioStateDeprecated.The IO state.private java.lang.StringBuilderlineBuilderDeprecated.The line builder.private BufferStatelineBuilderStateDeprecated.The line builder state.private ResponsemessageDeprecated.The current message exchanged.private MessageStatemessageStateDeprecated.The message state.private SelectionRegistrationregistrationDeprecated.The NIO selection registration.
-
Constructor Summary
Constructors Constructor Description Way(Connection<?> connection, int bufferSize)Deprecated.Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanLoop(Buffer buffer, java.lang.Object... args)Deprecated.Indicates if the processing loop can continue.voidclear()Deprecated.Recycles the way so it can be reused.protected voidclearLineBuilder()Deprecated.Clears the line builder and adjust its state.booleancouldDrain(Buffer buffer, java.lang.Object... args)Deprecated.Indicates if the buffer could be drained again.booleancouldFill(Buffer buffer, java.lang.Object... args)Deprecated.Indicates if the buffer could be filled again.abstract MessagegetActualMessage()Deprecated.Returns the actual message, request or response.BuffergetBuffer()Deprecated.Returns the IO buffer.Connection<?>getConnection()Deprecated.Returns the parent connection.Series<Header>getHeaders()Deprecated.Returns the response headers.ConnectionHelper<?>getHelper()Deprecated.Returns the parent connector helper.abstract intgetInterestOperations()Deprecated.Returns the operations of interest.IoStategetIoState()Deprecated.Returns the IO state.java.lang.StringBuildergetLineBuilder()Deprecated.Returns the line builder.BufferStategetLineBuilderState()Deprecated.Returns the line builder state.intgetLoadScore()Deprecated.Returns a score representing the way load and that could be compared with other ways of the same parent connection.protected java.util.logging.LoggergetLogger()Deprecated.Returns the logger.ResponsegetMessage()Deprecated.Returns the current message processed.MessageStategetMessageState()Deprecated.Returns the message state.SelectionRegistrationgetRegistration()Deprecated.Returns the socket's NIO registration holding the link between the channel and the connection.protected booleanhasIoInterest()Deprecated.Indicates if we want to be selected for IO processing when the socket related socket is prepared.booleanisAvailable()Deprecated.Indicates if the way is available to handle new messages.booleanisEmpty()Deprecated.Indicates if the way is empty.voidonClosed()Deprecated.Callback method invoked when the parent connection is ready to be closed.abstract intonDrain(Buffer buffer, int maxDrained, java.lang.Object... args)Deprecated.Drains the byte buffer by writing available bytes to the socket channel.abstract voidonError(Status status)Deprecated.Called on error.abstract intonFill(Buffer buffer, java.lang.Object... args)Deprecated.Fills the byte buffer by writing the current message.protected abstract voidonHeadersCompleted()Deprecated.Callback method invoked when the headers of the current message have been completely received or sent.voidonMessageCompleted(boolean endDetected)Deprecated.Callback method invoked when the current message has been completely received or sent.protected abstract voidonPostProcessing()Deprecated.Called back after the IO processing to indicate if there is further IO interest.voidonSelected(SelectionRegistration selectionRegistration)Deprecated.Callback method invoked when the way has been selected for IO operations it registered interest in.abstract voidonTimeOut()Deprecated.Called back by the controller when an IO time out has been detected.voidpostProcess(int drained)Deprecated.Does nothing by default.intpreProcess(int maxDrained, java.lang.Object... args)Deprecated.Does nothing by default.protected intprocessIoBuffer()Deprecated.Processes the IO buffer by filling and draining it.protected voidsetHeaders(Series<Header> headers)Deprecated.Sets the response headers to be written.voidsetIoState(IoState ioState)Deprecated.Sets the IO state.protected voidsetLineBuilderState(BufferState lineBuilderState)Deprecated.Sets the line builder state.protected voidsetMessage(Response message)Deprecated.Sets the current message processed.protected voidsetMessageState(MessageState messageState)Deprecated.Sets the message state.protected voidsetRegistration(SelectionRegistration registration)Deprecated.Sets the NIO selection registration holding the link between the connection and the way.java.lang.StringtoString()Deprecated.voidupdateState()Deprecated.Updates the way IO and message states.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.restlet.ext.nio.internal.buffer.BufferProcessor
onFillEof
-
-
-
-
Field Detail
-
buffer
private final Buffer buffer
Deprecated.The IO buffer.
-
connection
private final Connection<?> connection
Deprecated.The parent connection.
-
ioState
private volatile IoState ioState
Deprecated.The IO state.
-
lineBuilder
private final java.lang.StringBuilder lineBuilder
Deprecated.The line builder.
-
lineBuilderState
private volatile BufferState lineBuilderState
Deprecated.The line builder state.
-
message
private volatile Response message
Deprecated.The current message exchanged.
-
messageState
private volatile MessageState messageState
Deprecated.The message state.
-
registration
private volatile SelectionRegistration registration
Deprecated.The NIO selection registration.
-
-
Constructor Detail
-
Way
public Way(Connection<?> connection, int bufferSize)
Deprecated.Constructor.- Parameters:
connection- The parent connection.bufferSize- The byte buffer size.
-
-
Method Detail
-
canLoop
public boolean canLoop(Buffer buffer, java.lang.Object... args)
Deprecated.Indicates if the processing loop can continue.- Specified by:
canLoopin interfaceBufferProcessor- Parameters:
buffer- The IO buffer to drain.args- The optional arguments to pass back to the callbacks.- Returns:
- True if the processing loop can continue.
-
clear
public void clear()
Deprecated.Recycles the way so it can be reused. Typically invoked by a connection pool.
-
clearLineBuilder
protected void clearLineBuilder()
Deprecated.Clears the line builder and adjust its state.
-
couldDrain
public boolean couldDrain(Buffer buffer, java.lang.Object... args)
Deprecated.Indicates if the buffer could be drained again.- Parameters:
buffer- The IO buffer to drain.args- The optional arguments to pass back to the callbacks.- Returns:
- True if the buffer could be drained again.
-
couldFill
public boolean couldFill(Buffer buffer, java.lang.Object... args)
Deprecated.Indicates if the buffer could be filled again.- Specified by:
couldFillin interfaceBufferProcessor- Parameters:
buffer- The IO buffer to fill.args- The optional arguments to pass back to the callbacks.- Returns:
- True if the buffer could be filled again.
-
getActualMessage
public abstract Message getActualMessage()
Deprecated.Returns the actual message, request or response.- Returns:
- The actual message, request or response.
-
getBuffer
public Buffer getBuffer()
Deprecated.Returns the IO buffer.- Returns:
- The IO buffer.
-
getConnection
public Connection<?> getConnection()
Deprecated.Returns the parent connection.- Returns:
- The parent connection.
-
getHeaders
public Series<Header> getHeaders()
Deprecated.Returns the response headers.- Returns:
- The response headers to be written.
-
getHelper
public ConnectionHelper<?> getHelper()
Deprecated.Returns the parent connector helper.- Returns:
- The parent connector helper.
-
getInterestOperations
public abstract int getInterestOperations()
Deprecated.Returns the operations of interest.- Returns:
- The operations of interest.
-
getIoState
public IoState getIoState()
Deprecated.Returns the IO state.- Returns:
- The IO state.
-
getLineBuilder
public java.lang.StringBuilder getLineBuilder()
Deprecated.Returns the line builder.- Returns:
- The line builder.
-
getLineBuilderState
public BufferState getLineBuilderState()
Deprecated.Returns the line builder state.- Returns:
- The line builder state.
-
getLoadScore
public int getLoadScore()
Deprecated.Returns a score representing the way load and that could be compared with other ways of the same parent connection.- Returns:
- A score representing the way load.
-
getLogger
protected java.util.logging.Logger getLogger()
Deprecated.Returns the logger.- Returns:
- The logger.
-
getMessage
public Response getMessage()
Deprecated.Returns the current message processed.- Returns:
- The current message processed.
-
getMessageState
public MessageState getMessageState()
Deprecated.Returns the message state.- Returns:
- The message state.
-
getRegistration
public SelectionRegistration getRegistration()
Deprecated.Returns the socket's NIO registration holding the link between the channel and the connection.- Returns:
- The socket's NIO registration holding the link between the channel and the connection.
-
hasIoInterest
protected boolean hasIoInterest()
Deprecated.Indicates if we want to be selected for IO processing when the socket related socket is prepared.- Returns:
- True if we want to be selected for IO processing when the socket is ready.
-
isAvailable
public boolean isAvailable()
Deprecated.Indicates if the way is available to handle new messages.- Returns:
- True if the way is available to handle new messages.
-
isEmpty
public boolean isEmpty()
Deprecated.Indicates if the way is empty.- Returns:
- True if the way is empty.
-
onClosed
public void onClosed()
Deprecated.Callback method invoked when the parent connection is ready to be closed.
-
onDrain
public abstract int onDrain(Buffer buffer, int maxDrained, java.lang.Object... args) throws java.io.IOException
Deprecated.Drains the byte buffer by writing available bytes to the socket channel.- Specified by:
onDrainin interfaceBufferProcessor- 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 abstract void onError(Status status)
Deprecated.Called on error.- Parameters:
status- The error status.
-
onFill
public abstract int onFill(Buffer buffer, java.lang.Object... args) throws java.io.IOException
Deprecated.Fills the byte buffer by writing the current message.- Specified by:
onFillin interfaceBufferProcessor- 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
-
onHeadersCompleted
protected abstract void onHeadersCompleted() throws java.io.IOExceptionDeprecated.Callback method invoked when the headers of the current message have been completely received or sent.- Throws:
java.io.IOException
-
onMessageCompleted
public void onMessageCompleted(boolean endDetected) throws java.io.IOExceptionDeprecated.Callback method invoked when the current message has been completely received or sent.- Specified by:
onMessageCompletedin interfaceCompletionListener- Parameters:
endDetected- Indicates if the end of the socket channel was detected.- Throws:
java.io.IOException
-
onPostProcessing
protected abstract void onPostProcessing()
Deprecated.Called back after the IO processing to indicate if there is further IO interest. By default, it sets the IO state toIoState.INTEREST.
-
onSelected
public void onSelected(SelectionRegistration selectionRegistration)
Deprecated.Callback method invoked when the way has been selected for IO operations it registered interest in.- Specified by:
onSelectedin interfaceSelectionListener- Parameters:
selectionRegistration- The selected registration.
-
onTimeOut
public abstract void onTimeOut()
Deprecated.Called back by the controller when an IO time out has been detected.
-
postProcess
public void postProcess(int drained) throws java.io.IOExceptionDeprecated.Does nothing by default.- Specified by:
postProcessin interfaceBufferProcessor- Parameters:
drained- The number of bytes drained or -1 if the filling source has ended.- Throws:
java.io.IOException
-
preProcess
public int preProcess(int maxDrained, java.lang.Object... args) throws java.io.IOExceptionDeprecated.Does nothing by default.- Specified by:
preProcessin interfaceBufferProcessor- Parameters:
maxDrained- The maximum number of bytes drained by this call or 0 for unlimited length.args- The optional arguments to pass back to the callbacks.- Returns:
- The number of bytes drained or -1 if the filling source has ended.
- Throws:
java.io.IOException
-
processIoBuffer
protected int processIoBuffer() throws java.io.IOExceptionDeprecated.Processes the IO buffer by filling and draining it.- Throws:
java.io.IOException
-
setHeaders
protected void setHeaders(Series<Header> headers)
Deprecated.Sets the response headers to be written.- Parameters:
headers- The response headers.
-
setIoState
public void setIoState(IoState ioState)
Deprecated.Sets the IO state.- Parameters:
ioState- The IO state.
-
setLineBuilderState
protected void setLineBuilderState(BufferState lineBuilderState)
Deprecated.Sets the line builder state.- Parameters:
lineBuilderState- The line builder state.
-
setMessage
protected void setMessage(Response message)
Deprecated.Sets the current message processed.- Parameters:
message- The current message processed.
-
setMessageState
protected void setMessageState(MessageState messageState)
Deprecated.Sets the message state.- Parameters:
messageState- The message state.
-
setRegistration
protected void setRegistration(SelectionRegistration registration)
Deprecated.Sets the NIO selection registration holding the link between the connection and the way.- Parameters:
registration- The NIO selection registration holding the link between the connection and the way.
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object
-
updateState
public void updateState()
Deprecated.Updates the way IO and message states.
-
-