QueryServlet

public abstract class QueryServlet<T extends Message> extends MessageServlet<I, O>

An 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.

Parameters

<T>

the type of the query result

Constructors

Link copied to clipboard
protected void QueryServlet(QueryBridge<T> bridge)
Creates a new instance of QueryServlet with the given QueryBridge.

Functions

Link copied to clipboard
protected T handle(Query request)
Handles the servlet request and produces the response message.

Inherited functions

Link copied to clipboard
public void doPost(HttpServletRequest req, HttpServletResponse resp)