Save This Page
Home » openjdk-7 » net.sourceforge » myfaces » webapp » [javadoc | source]
    1   /**
    2    * MyFaces - the free JSF implementation
    3    * Copyright (C) 2003  The MyFaces Team (http://myfaces.sourceforge.net)
    4    *
    5    * This library is free software; you can redistribute it and/or
    6    * modify it under the terms of the GNU Lesser General Public
    7    * License as published by the Free Software Foundation; either
    8    * version 2.1 of the License, or (at your option) any later version.
    9    *
   10    * This library is distributed in the hope that it will be useful,
   11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   13    * Lesser General Public License for more details.
   14    *
   15    * You should have received a copy of the GNU Lesser General Public
   16    * License along with this library; if not, write to the Free Software
   17    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   18    */
   19   package net.sourceforge.myfaces.webapp;
   20   
   21   import net.sourceforge.myfaces.util.logging.LogUtil;
   22   
   23   import javax.faces.webapp.FacesServlet;
   24   import javax.servlet;
   25   import java.io.ByteArrayOutputStream;
   26   import java.io.IOException;
   27   import java.io.PrintStream;
   28   
   29   /**
   30    * DOCUMENT ME!
   31    * @author Manfred Geiler (latest modification by $Author: manolito $)
   32    * @version $Revision: 1.6 $ $Date: 2003/03/12 22:56:48 $
   33    */
   34   public class MyFacesServlet
   35       implements Servlet
   36   {
   37   
   38       private final FacesServlet _facesServlet = new FacesServlet();
   39   
   40       public void destroy()
   41       {
   42           _facesServlet.destroy();
   43       }
   44   
   45       public ServletConfig getServletConfig()
   46       {
   47           return _facesServlet.getServletConfig();
   48       }
   49   
   50       public String getServletInfo()
   51       {
   52           return _facesServlet.getServletInfo();
   53       }
   54   
   55       public void init(ServletConfig servletConfig)
   56           throws ServletException
   57       {
   58           synchronized (System.out)
   59           {
   60               PrintStream oldOut = System.out;
   61               //Sun's copyright is nice and important, but drives me crazy during testing...
   62               //Uncomment the following line during development if you feel the same:
   63               System.setOut(new PrintStream(new ByteArrayOutputStream()));
   64               _facesServlet.init(servletConfig);
   65               System.setOut(oldOut);
   66           }
   67   
   68           LogUtil.getLogger().info("MyFacesServlet for context '" + servletConfig.getServletContext().getRealPath("/") + "' initialized.");
   69       }
   70   
   71       public void service(ServletRequest request, ServletResponse response)
   72           throws IOException, ServletException
   73       {
   74           try
   75           {
   76               _facesServlet.service(request, response);
   77           }
   78           catch (Exception e)
   79           {
   80               e.printStackTrace(System.err);
   81               Throwable t = e.getCause();
   82               while (t != null)
   83               {
   84                   System.err.println("Root cause:");
   85                   t.printStackTrace(System.err);
   86                   t = t.getCause();
   87               }
   88               throw new ServletException(e);
   89           }
   90       }
   91   }

Save This Page
Home » openjdk-7 » net.sourceforge » myfaces » webapp » [javadoc | source]