public class ResponseHandlerContext extends Object
The "write" methods of this class ensure that at most one final
response message is written to the underlying channel. Attempts to write more than one final response message will
be ignored with a warning log message.
Note: an object of this class should be used instead of writing to the channel directly when multiple threads
are expected to produce final response messages concurrently. Callers must ensure that the same
ResponseHandlerContext
is used by all threads writing response messages for the same request.
Constructor and Description |
---|
ResponseHandlerContext(Context context) |
Modifier and Type | Method and Description |
---|---|
Context |
getContext() |
void |
writeAndFlush(ResponseMessage message)
Writes a response message to the underlying channel while ensuring that at most one
final response is written. |
void |
writeAndFlush(ResponseStatusCode code,
Object responseMessage)
Writes a response message to the underlying channel while ensuring that at most one
final response is written. |
public ResponseHandlerContext(Context context)
public Context getContext()
public void writeAndFlush(ResponseMessage message)
final
response is written.
Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.
Attempts to write more than one final response message will be ignored.
public void writeAndFlush(ResponseStatusCode code, Object responseMessage)
final
response is written.
The caller must make sure that the provided response status code matches the content of the message.
Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.
Attempts to write more than one final response message will be ignored.
writeAndFlush(ResponseMessage)
Copyright © 2013–2018 Apache Software Foundation. All rights reserved.