1 package org.wcb.plugins.beans;
2
3 import org.wcb.autohome.AutoHomeDaemonSession;
4
5 import javax.servlet.http.HttpServlet;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
8 import javax.servlet.ServletException;
9
10 import java.io.IOException;
11 import java.net.URL;
12 import java.net.MalformedURLException;
13
14
15 /***
16 * Copyright (C) 1999 Walter Bogaardt
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 *
32 * Project: Home Automation Interface
33 * Filename: $Id: StartAliceWeb.java,v 1.5 2004/01/02 21:02:57 wbogaardt Exp $
34 * Abstract: Start up action servlet for web interface.
35 *
36 * $Log: StartAliceWeb.java,v $
37 * Revision 1.5 2004/01/02 21:02:57 wbogaardt
38 * removed excessive logging statements, and consolidated some variables
39 *
40 * Revision 1.4 2003/12/12 23:17:36 wbogaardt
41 * javadoc comments refactored methods so they are more descriptive
42 *
43 * Revision 1.3 2003/12/10 21:06:53 wbogaardt
44 * modules page adds but does not reload from saved state
45 *
46 * Revision 1.2 2003/12/09 23:11:42 wbogaardt
47 *
48 * C: ----------------------------------------------------------------------
49 *
50 * Revision 1.1 2003/12/09 17:20:53 wbogaardt
51 * startup servlet for web application
52 *
53 *
54 */
55 public class StartAliceWeb extends HttpServlet{
56
57 /***
58 * Respond to a GET request for the content produced by
59 * this servlet.
60 *
61 * @param request The servlet request we are processing
62 * @param response The servlet response we are producing
63 *
64 * @exception java.io.IOException if an input/output error occurs
65 * @exception javax.servlet.ServletException if a servlet error occurs
66 */
67 public void doGet(HttpServletRequest request,HttpServletResponse response)
68 throws IOException, ServletException
69 {
70
71 }
72
73 public void doPost(HttpServletRequest request,HttpServletResponse response)
74 throws IOException, ServletException
75 {
76
77 }
78
79 /***
80 * Servlet initialization method starts the basic services needed for the
81 * Alice web interface. This also passes the servlet context so that a path
82 * to the web application can be maintained during runtime deployment of a war file.
83 *
84 * @throws ServletException
85 */
86 public void init() throws ServletException
87 {
88 System.out.println("Starting Alice Web Application");
89 AutoHomeDaemonSession.getInstance().loadLastSettings(null,getRealpath("/WEB-INF"));
90 }
91
92
93 /***
94 * Pass in a string of a path directory and this will return
95 * the entire path up to that directory point for example.
96 * A string of "/WEB-INF/" running in this application will return
97 * back a C:/bea/wlserver6.1/config/application/aliceweb/WEB-INF
98 *
99 * @param relativePath Directory name
100 * @return Url of servlet context path.
101 */
102 public URL getUrl(String relativePath) {
103 try {
104 URL absoluteURL = this.getServletContext().getResource(relativePath);
105 return absoluteURL;
106 }
107 catch (MalformedURLException e) {
108 return null;
109 }
110 }
111
112 /***
113 *Pass in a string of a path directory and this will return
114 * the entire path up to that directory point for example.
115 * A string of "/WEB-INF/" running in this application will return
116 * back a C:/bea/wlserver6.1/config/application/aliceweb/WEB-INF
117 *
118 * @param relativePath Directory name
119 * @return string of servlet context path
120 */
121 public String getRealpath(String relativePath) {
122 try {
123 return this.getServletContext().getRealPath(relativePath);
124 }
125 catch (Exception e) {
126 return null;
127 }
128 }
129 }