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

Last change on this file since 41 was 41, checked in by bart, 3 years ago

refactor to help reusing partiesserver

File size: 1.3 KB
Line 
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 geniusweb.partiesserver.repository.RunningPartiesRepo;
11import geniusweb.serverobjects.ServerInfo;
12
13/**
14 * Servlet implementation to get general info from the server.
15 */
16public class Info extends HttpServlet {
17
18 private final static RunningPartiesRepo repo = RunningPartiesRepo
19 .instance();
20
21 /**
22 * see
23 * {@link HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)}.
24 * Returns to the http caller
25 * <ul>
26 * <li>URL with websocket address to contact the now running agent.
27 * <li>SC_NOT_FOUND (404) if attempt is made to access non-running party.
28 * <li>SC_SERVICE_UNAVAILABLE (503) if there are no free slots to run the
29 * party.
30 * <li>SC_EXPECTATION_FAILED (417) if something else goes wrong during
31 * instantiating the party (then see logs for more details)
32 * </ul>
33 */
34 @Override
35 protected void doGet(HttpServletRequest request,
36 HttpServletResponse response) throws ServletException, IOException {
37 response.getWriter().append(Constants.getJackson().writeValueAsString(
38 new ServerInfo(repo.availableSlots(), repo.maximumSlots())));
39 }
40}
Note: See TracBrowser for help on using the repository browser.