Interface RequestContext
- All Known Implementing Classes:
RequestHandler
public interface RequestContext
A request context is the asynchronous interface for working with a pending request.
The context must be provided when sending a signal, and the RequestSink is obligated to send all
replies to this context. The context will also be notified if the RequestSink closes the request, or notifies about an error.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(RequestListener listener) Add aRequestListener
to context.boolean
addResponse
(Message msg) Add a signal response to give back to requesting clientvoid
Signal end of stream (the current context holder will not provide any more data).boolean
isClosed()
boolean
keepAlive
(long until) Request that this request should be kept alive a bit longervoid
Notify signal context that server has closed this request.void
Notify signal context that an error has occurred while waiting for datavoid
removeListener
(RequestListener listener) Remove a RequestListener from context
-
Method Details
-
isClosed
boolean isClosed()- Returns:
- true if this request is closed down (will not accept any more responses)
-
keepAlive
boolean keepAlive(long until) Request that this request should be kept alive a bit longer- Parameters:
until
- Ask this request to keep open at least until this timestamp- Returns:
- true if the request is granted (will not guarantee that endpoint clients keep this up)
-
notifyError
Notify signal context that an error has occurred while waiting for data- Parameters:
e
- exception that was caught
-
notifyClose
void notifyClose()Notify signal context that server has closed this request. The request may already be closed on the client side. -
addListener
Add aRequestListener
to context. A context implementation should notify any registered listeners about relevant events.- Parameters:
listener
- listener to add
-
removeListener
Remove a RequestListener from context- Parameters:
listener
- listener to remove
-
addResponse
Add a signal response to give back to requesting client- Parameters:
msg
- the response message to add- Returns:
- true if the response message was accepted, false if it was discarded
-
endOfStream
void endOfStream()Signal end of stream (the current context holder will not provide any more data).
-