bachelor-thesis/chapters/thesis/appendix05_servlet.java
2024-09-18 00:19:25 +02:00

28 lines
1 KiB
Java

public class PerfStatServlet extends HttpServlet {
private final static Logger m_Logger = Logger.getLogger(PerfStatServlet.class.toString());
@Inject
private PerfStatistics perfStatistics;
public PerfStatServlet() {
m_Logger.info("PerfStatServlet() Constructor");
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String openJPAStatistics = perfStatistics.getOpenJPAStatistics();
String entityClasses = perfStatistics.getEntityClasses();
String ehCache = perfStatistics.getEhCacheManager();
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentType(MediaType.APPLICATION_JSON);
PrintWriter out = resp.getWriter();
out.print("{ \"openJPAStatistics\": ");
out.print(openJPAStatistics);
out.print(", \"entityClasses\": ");
out.print(entityClasses);
out.print(", \"ehCache\": ");
out.print(ehCache);
out.print(" }");
}
}