KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > clipbuilder > InitServlet


1 package org.jahia.clipbuilder;
2
3 import javax.servlet.*;
4 import javax.servlet.http.*;
5 import java.io.*;
6 import org.apache.log4j.xml.DOMConfigurator;
7 import javax.xml.parsers.*;
8
9
10 /**
11  * Init Object
12  *
13  *@author Tlili Khaled
14  */

15 public class InitServlet extends HttpServlet {
16     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(InitServlet.class);
17
18
19     /**
20      * Initialize global variables
21      *
22      *@exception ServletException Description of Exception
23      */

24     public void init() throws ServletException {
25         initLog4j();
26     }
27
28
29     /**
30      * Description of the Method
31      *
32      *@param request Description of Parameter
33      *@param response Description of Parameter
34      *@exception ServletException Description of Exception
35      *@exception IOException Description of Exception
36      */

37     public void service(HttpServletRequest request, HttpServletResponse response) throws
38             IOException, ServletException {
39         //This servlet does nothing else than initilizing the context
40

41     }
42
43
44     /**
45      * Clean up ressources
46      */

47     public void destroy() {
48     }
49
50
51
52     /**
53      * init log4J
54      *
55      *@exception FactoryConfigurationError Description of Exception
56      */

57     private void initLog4j() throws FactoryConfigurationError {
58         String JavaDoc prefix = getServletContext().getRealPath("/");
59         String JavaDoc xmlFile = getInitParameter("log4j-xml-init-file");
60         // if the log4j-init-file is not set, then no point in trying
61
if (xmlFile != null) {
62             DOMConfigurator.configure(prefix + xmlFile);
63         }
64
65         logger.debug("Log4j configured, initializing the rest of the ...");
66         logger.debug("[ Initialize the context ]");
67     }
68
69
70
71
72 }
73
Popular Tags