package fr.univrennes1.cri.calendar;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.log4j.Logger;



/**
 * @author S.Gougeon
 * date : 16 janv. 2004
 * Centre de Ressources Informatiques
 * Université de Rennes 1
 * 
 */
public class LanceClean extends HttpServlet {
	Logger logger = Logger.getLogger("lanceClean.java");
	Clean lanceur = null;

		public void init()
		{
		}

		public void init(ServletConfig config)
			throws ServletException
		{
			super.init(config);
			logger.info("On entre dans la fonction init()");
			lanceur = new Clean();
			try
			{
					logger.info("Lancement du thread Clean.class");
					lanceur.remind();
				
			}
			catch(Exception e)
			{	
				logger.info("[LanceClean] Erreur de lancement du thread Clean.class");
				lanceur.interrupt();
				throw new ServletException("Erreur de lancement du Thread Clean.class : " + e);
			}
		}

		public void destroy()
		{
			logger.info("On entre dans la fonction destroy()");
			lanceur.kill();
		}

		protected void processRequest(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
		{
			response.setContentType("text/html");
			PrintWriter out = response.getWriter();
			out.close();
		}

		protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
		{
			processRequest(request, response);
		}

		protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException
		{
			processRequest(request, response);
		}

		public String getServletInfo()
		{
			return "Short description";
		}
	}

