KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > webapp > MyFacesServlet


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.webapp;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20
21 import javax.faces.webapp.FacesServlet;
22 import javax.servlet.*;
23 import java.io.IOException JavaDoc;
24
25 /**
26  * Derived FacesServlet that can be used for debugging purpose
27  * and to fix the Weblogic startup issue (FacesServlet is initialized before ServletContextListener).
28  *
29  * @author Manfred Geiler (latest modification by $Author: matze $)
30  * @version $Revision: 1.19 $ $Date: 2004/10/13 11:51:01 $
31  * $Log: MyFacesServlet.java,v $
32  * Revision 1.19 2004/10/13 11:51:01 matze
33  * renamed packages to org.apache
34  *
35  * Revision 1.18 2004/07/16 15:16:10 royalts
36  * moved org.apache.myfaces.webapp.webxml and org.apache.util.xml to share src-tree (needed WebXml for JspTilesViewHandlerImpl)
37  *
38  * Revision 1.17 2004/07/01 22:05:11 mwessendorf
39  * ASF switch
40  *
41  * Revision 1.16 2004/04/16 13:21:39 manolito
42  * Weblogic startup issue
43  *
44  */

45 public class MyFacesServlet
46     extends FacesServlet
47 {
48     private static final Log log = LogFactory.getLog(MyFacesServlet.class);
49
50     public void init(ServletConfig servletConfig)
51         throws ServletException
52     {
53         //Check, if ServletContextListener already called
54
ServletContext servletContext = servletConfig.getServletContext();
55         Boolean JavaDoc b = (Boolean JavaDoc)servletContext.getAttribute(org.apache.myfaces.webapp.StartupServletContextListener.FACES_INIT_DONE);
56         if (b == null || b.booleanValue() == false)
57         {
58             log.warn("ServletContextListener not yet called");
59             org.apache.myfaces.webapp.StartupServletContextListener.initFaces(servletConfig.getServletContext());
60         }
61         super.init(servletConfig);
62         log.info("MyFacesServlet for context '" + servletConfig.getServletContext().getRealPath("/") + "' initialized.");
63     }
64
65     public void service(ServletRequest request, ServletResponse response)
66             throws IOException JavaDoc,
67                    ServletException
68     {
69         if (log.isTraceEnabled()) log.trace("MyFacesServlet service start");
70         super.service(request, response);
71         if (log.isTraceEnabled()) log.trace("MyFacesServlet service finished");
72     }
73
74 }
75
Popular Tags