BaseServlet.java
上传用户:cdpainuo
上传日期:2022-07-12
资源大小:5257k
文件大小:1k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package com.appspot.cindyblog.servlet;
  2. import java.io.IOException;
  3. import javax.persistence.EntityManager;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.http.HttpServlet;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import com.appspot.cindyblog.service.AdminService;
  9. import com.appspot.cindyblog.service.BaseService;
  10. import com.appspot.cindyblog.service.BlogService;
  11. import com.appspot.cindyblog.util.Counter;
  12. import com.appspot.cindyblog.util.Singleton;
  13. public abstract class BaseServlet extends HttpServlet{
  14. BaseService cbs = null;
  15. BlogService bs = null;
  16. AdminService as = null;
  17. Counter counter = Counter.getCounter();
  18. public void doGet(HttpServletRequest request, HttpServletResponse response)
  19. throws ServletException, IOException {
  20. }
  21. public void doPost(HttpServletRequest request, HttpServletResponse response)
  22. throws ServletException, IOException {
  23. this.doGet(request, response);
  24. }
  25. protected BlogService getBlogService(){
  26. return (BlogService) Singleton.getInstance(BlogService.class);
  27. }
  28. protected AdminService getAdminService(){
  29. return (AdminService) Singleton.getInstance(AdminService.class);
  30. }
  31. protected void closeEntityManager(EntityManager em){
  32. if(em.isOpen()){
  33. em.close();
  34. }
  35. em = null;
  36. }
  37. }