BaseServlet.java.svn-base
上传用户: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.Singleton;
  12. public abstract class BaseServlet extends HttpServlet{
  13. BaseService cbs = null;
  14. BlogService bs = null;
  15. AdminService as = null;
  16. public void doGet(HttpServletRequest request, HttpServletResponse response)
  17. throws ServletException, IOException {
  18. }
  19. public void doPost(HttpServletRequest request, HttpServletResponse response)
  20. throws ServletException, IOException {
  21. this.doGet(request, response);
  22. }
  23. protected BlogService getBlogService(){
  24. return (BlogService) Singleton.getInstance("com.appspot.cindyblog.service.BlogService");
  25. }
  26. protected AdminService getAdminService(){
  27. return (AdminService) Singleton.getInstance("com.appspot.cindyblog.service.AdminService");
  28. }
  29. protected void closeEntityManager(EntityManager em){
  30. if(em.isOpen()){
  31. em.close();
  32. }
  33. em = null;
  34. }
  35. }