Package net.officefloor.server
Interface RequestHandler<R>
-
public interface RequestHandler<R>Handles requests.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcloseConnection(java.lang.Throwable exception)Allows to close connection.voidexecute(SocketRunnable runnable)StreamBufferPool<java.nio.ByteBuffer>getStreamBufferPool()Obtains theStreamBufferPoolfor thsiRequestHandler.voidhandleRequest(R request)Handles a request.booleanisReadingInput()Indicates if readingSocketinput from client.voidsendImmediateData(StreamBuffer<java.nio.ByteBuffer> immediateHead)Sends data immediately.
-
-
-
Method Detail
-
isReadingInput
boolean isReadingInput()
Indicates if reading
Socketinput from client.To avoid out of memory, the reading from the
Socketmay be halted temporarily. This indicates if actively reading input from theSocket.- Returns:
trueif readingSocketinput from client.
-
getStreamBufferPool
StreamBufferPool<java.nio.ByteBuffer> getStreamBufferPool()
Obtains theStreamBufferPoolfor thsiRequestHandler.- Returns:
StreamBufferPoolfor thsiRequestHandler.
-
execute
void execute(SocketRunnable runnable)
- Parameters:
runnable-SocketRunnable.
-
handleRequest
void handleRequest(R request) throws java.io.IOException, java.lang.IllegalStateException
Handles a request.
This may only be invoked by the
SocketThread.- Parameters:
request- Request.- Throws:
java.io.IOException- If fails to handle the request.java.lang.IllegalStateException- If invoked from anotherThread.
-
sendImmediateData
void sendImmediateData(StreamBuffer<java.nio.ByteBuffer> immediateHead) throws java.lang.IllegalStateException
Sends data immediately.
This may only be invoked by the
SocketThread.- Parameters:
immediateHead- HeadStreamBufferto linked list ofStreamBufferinstances of data to send immediately.- Throws:
java.lang.IllegalStateException- If invoked from anotherThread.
-
closeConnection
void closeConnection(java.lang.Throwable exception)
Allows to close connection.- Parameters:
exception- OptionalExceptionfor the cause of closing the connection.nullto indicate normal close.
-
-