From: <mr...@us...> - 2003-01-08 05:53:08
|
Update of /cvsroot/struts/struts-resume/src/web/org/appfuse/webapp In directory sc8-pr-cvs1:/tmp/cvs-serv29189 Added Files: StartupServlet.java Log Message: --- NEW FILE: StartupServlet.java --- package org.appfuse.webapp; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.appfuse.common.Constants; import cirrus.hibernate.Hibernate; import cirrus.hibernate.HibernateException; /** * Application Startup Servlet. All initialization is performed here.<br /> * First the Servlet Init Parameters are parsed and validated.<br /> * Then the Context init parameters are parsed and validated. <br /> * * <p><a href="StartupServlet.java.html"><i>View Source</i></a></p> * * @author Matt Raible * @version $Revision: 1.1 $ $Date: 2003/01/08 05:53:04 $ * * @web.servlet * display-name="Startup Servlet" * load-on-startup="1" * name="startup" */ public class StartupServlet extends HttpServlet { /** * The <code>Log</code> instance for this class */ private Log log = LogFactory.getLog(StartupServlet.class); /** * Validates the Init and Context parameters and sets servlet context * variables * * @throws ServletException if the init parameters are invalid or any * other problems occur during initialisation */ public void init() throws ServletException { // retrieve Servlet Init Parameters first... // ensure Context Parameters are present and valid String daoType = getServletContext().getInitParameter(Constants.DAO_TYPE); // if daoType is not specified, use DAO as default if (daoType == null) { log.warn("No 'daoType' Context Parameter supplied in web.xml, using default (hibernate)"); daoType = Constants.DAO_TYPE_HIBERNATE; } getServletContext().setAttribute(Constants.DAO_TYPE, daoType); // all Context Parameters present and valid... // Configure Hibernate. try { Hibernate.configure(); } catch (HibernateException h) { log.fatal("Error configuring Hibernate!", h); throw new ServletException("Error configuring Hibernate", h); } // output the retrieved values for the Init and Context Parameters if (log.isDebugEnabled()) { log.debug("daoType: " + daoType); log.debug("Initialization complete [OK]"); } } } // end of StartupServlet |