/*
* Copyright (C) 2004 TiongHiang Lee
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Email: thlee@onemindsoft.org
*/
package org.onemind.swingweb.servlet;
import java.awt.Window;
import java.util.logging.Logger;
import javax.servlet.http.*;
import org.onemind.awtbridge.session.SessionLifecycleListener;
import org.onemind.commons.java.lang.reflect.ReflectUtils;
import org.onemind.swingweb.SwingWebComponentManager;
import org.onemind.swingweb.SwingWebContext;
import org.onemind.swingweb.session.SwingWebSession;
/**
* A Servlet for initializing the swingweb application. There's only two parameter needed
* for the application: <br>
* <ul>
* <li>app-class - the application class </li>
* <li>swingweb-config - the swing web configuration </li>
* </ul>
*
* @author TiongHiang Lee (thlee@onemindsoft.org)
*
*/
public class SwingWebServlet extends AbstractSwingWebServlet
{
/** the logger * */
private static final Logger _logger = Logger.getLogger(SwingWebServlet.class.getName());
public SwingWebSession createSession(SwingWebContext context, HttpSession session)
{
return new SwingWebSession(new SwingWebComponentManager());
}
/**
* {@inheritDoc}
*/
protected void startApp(SwingWebSession swSession, HttpServletRequest req, HttpServletResponse resp) throws Exception
{
Window w = getManager().startApp(ReflectUtils.getClass(getAppClass()), null);
if (w instanceof SessionLifecycleListener)
{
swSession.addListener((SessionLifecycleListener) w);
}
}
}