package geniusweb.partiesserver; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.fasterxml.jackson.databind.ObjectMapper; import geniusweb.partiesserver.repository.RunningPartiesRepo; import geniusweb.serverobjects.ServerInfo; /** * Servlet implementation to get general info from the server. */ public class Info extends HttpServlet { private final static RunningPartiesRepo repo = RunningPartiesRepo .instance(); private final static ObjectMapper jackson = new ObjectMapper(); /** * see * {@link HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)}. * Returns to the http caller * */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.getWriter().append(jackson.writeValueAsString( new ServerInfo(repo.availableSlots(), repo.maximumSlots()))); } }