Sprockets for Java EE
Create Servlets that automatically read and write JSON objects or Protocol Buffers messages.
Example
Your Servlet will be sent an order in JSON and it will respond with a confirmation in JSON.
public class OrderServlet extends JsonServlet<Order, Confirmation> {
@Override
protected Confirmation jsonPost(Order order,
HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Confirmation confirmation = process(order);
return confirmation;
}
}
WireServlet
follows the same pattern but reads and writes Protocol Buffers messages instead of JSON objects.
Install
<dependency>
<groupId>net.sf.sprockets</groupId>
<artifactId>sprockets-ee</artifactId>
<version>3.0.0</version>
</dependency>