01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.servlet;
22:
23: import java.awt.Window;
24: import java.util.logging.Logger;
25: import javax.servlet.http.*;
26: import org.onemind.awtbridge.session.SessionLifecycleListener;
27: import org.onemind.commons.java.lang.reflect.ReflectUtils;
28: import org.onemind.swingweb.SwingWebComponentManager;
29: import org.onemind.swingweb.SwingWebContext;
30: import org.onemind.swingweb.session.SwingWebSession;
31:
32: /**
33: * A Servlet for initializing the swingweb application. There's only two parameter needed
34: * for the application: <br>
35: * <ul>
36: * <li>app-class - the application class </li>
37: * <li>swingweb-config - the swing web configuration </li>
38: * </ul>
39: *
40: * @author TiongHiang Lee (thlee@onemindsoft.org)
41: *
42: */
43: public class SwingWebServlet extends AbstractSwingWebServlet {
44:
45: /** the logger * */
46: private static final Logger _logger = Logger
47: .getLogger(SwingWebServlet.class.getName());
48:
49: public SwingWebSession createSession(SwingWebContext context,
50: HttpSession session) {
51: return new SwingWebSession(new SwingWebComponentManager());
52: }
53:
54: /**
55: * {@inheritDoc}
56: */
57: protected void startApp(SwingWebSession swSession,
58: HttpServletRequest req, HttpServletResponse resp)
59: throws Exception {
60: Window w = getManager().startApp(
61: ReflectUtils.getClass(getAppClass()), null);
62: if (w instanceof SessionLifecycleListener) {
63: swSession.addListener((SessionLifecycleListener) w);
64: }
65: }
66: }
|