View Javadoc

1   /*
2    * The SmartWeb Framework
3    * Copyright (C) 2004-2006
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18   *
19   * For further informations on the SmartWeb Framework please visit
20   *
21   *                        http://smartweb.sourceforge.net
22   */
23  package net.smartlab.web;
24  
25  import java.io.IOException;
26  
27  import javax.servlet.ServletException;
28  import javax.servlet.http.HttpServletRequest;
29  import javax.servlet.http.HttpServletResponse;
30  
31  /**
32   * The <i>front controller</i> class of the framework. It extends the Jakarta
33   * Struts implementation to ensure the correct closure of the Hibernate session.
34   * 
35   * @author rlogiacco
36   * 
37   * @uml.dependency supplier="net.smartlab.web.Action"
38   * @uml.dependency supplier="net.smartlab.web.Domain"
39   * 
40   * @web.servlet name="action" load-on-startup="1"
41   * @web.servlet-init-param name="config" value="/WEB-INF/struts.xml"
42   * @web.servlet-mapping url-pattern="*.do"
43   */
44  public class ActionServlet extends org.apache.struts.action.ActionServlet {
45  
46  	private static final long serialVersionUID = 6243504848590158405L;
47  
48  
49  	/**
50  	 * @see org.apache.struts.action.ActionServlet#process(javax.servlet.http.HttpServletRequest,
51  	 *      javax.servlet.http.HttpServletResponse)
52  	 */
53  	protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException,
54  			ServletException {
55  		try {
56  			super.process(request, response);
57  		} finally {
58  			try {
59  				BusinessObjectFactory.close();
60  			} catch (DAOException daoe) {
61  				super.getServletContext().log("failed to close session", daoe);
62  			}
63  		}
64  	}
65  }