source: src/main/java/geniusweb/partiesserver/Info.java@ 17

Last change on this file since 17 was 1, checked in by bart, 5 years ago

Initial Release

File size: 1.4 KB
RevLine 
[1]1package geniusweb.partiesserver;
2
3import java.io.IOException;
4
5import javax.servlet.ServletException;
6import javax.servlet.http.HttpServlet;
7import javax.servlet.http.HttpServletRequest;
8import javax.servlet.http.HttpServletResponse;
9
10import com.fasterxml.jackson.databind.ObjectMapper;
11
12import geniusweb.partiesserver.repository.RunningPartiesRepo;
13import geniusweb.serverobjects.ServerInfo;
14
15/**
16 * Servlet implementation to get general info from the server.
17 */
18public class Info extends HttpServlet {
19
20 private final static RunningPartiesRepo repo = RunningPartiesRepo
21 .instance();
22 private final static ObjectMapper jackson = new ObjectMapper();
23
24 /**
25 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
26 * response). Returns
27 * <ul>
28 * <li>URL with websocket address to contact the now running agent.
29 * <li>SC_NOT_FOUND (404) if attempt is made to access non-running
30 * party.
31 * <li>SC_SERVICE_UNAVAILABLE (503) if there are no free slots to run
32 * the party.
33 * <li>SC_EXPECTATION_FAILED (417) if something else goes wrong during
34 * instantiating the party (then see logs for more details)
35 * </ul>
36 */
37 @Override
38 protected void doGet(HttpServletRequest request,
39 HttpServletResponse response) throws ServletException, IOException {
40 response.getWriter().append(jackson.writeValueAsString(
41 new ServerInfo(repo.availableSlots(), repo.maximumSlots())));
42 }
43}
Note: See TracBrowser for help on using the repository browser.