T
- the type of the query resultpublic abstract class QueryServlet<T extends com.google.protobuf.Message> extends MessageServlet<io.spine.client.Query,T>
HttpServlet
which receives query requests and handles them via
a QueryBridge
.
The servlet supports only POST
requests. GET
, HEAD
, PUT
,
DELETE
, OPTIONS
, and TRACE
methods are not supported by default.
In order to perform a query, a client should send an HTTP
POST
request to this servlet. The request body should be a JSON representation of a io.spine.client.Query
.
If the request is valid (i.e. the request body contains a valid Query
), the response will contain a message with the query result. The format of the result
depends on the implementation of QueryBridge
.
If the query cannot be parsed from the request, the response will be empty with the response
code 400
.
A typical implementation would extend this class and provide a QueryBridge
in
the constructor. No additional config is required in order for this servlet to handle
the entity queries.
A QueryServlet
does not support serialization. Please keep that in mind when selecting
a servlet container. When trying to serialize an instance of QueryServlet
, an
UnsupportedOperationException
is thrown.
Modifier | Constructor and Description |
---|---|
protected |
QueryServlet(QueryBridge<T> bridge)
Creates a new instance of
QueryServlet with the given QueryBridge . |
Modifier and Type | Method and Description |
---|---|
protected T |
handle(io.spine.client.Query request)
Handles the servlet request and produces the response message.
|
doPost
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
protected QueryServlet(QueryBridge<T> bridge)
QueryServlet
with the given QueryBridge
.bridge
- the query bridge to be used in this query servletprotected T handle(io.spine.client.Query request)
MessageServlet
handle
in class MessageServlet<io.spine.client.Query,T extends com.google.protobuf.Message>
request
- the request message