Source code: openfuture/editxml/servlet/EditXmlJspServlet.java
1 package openfuture.editxml.servlet;
2 /*
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.<p>
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.<p>
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br>
16 * http://www.gnu.org/copyleft/lesser.html
17 */
18
19 import java.io.File;
20 import java.io.IOException;
21 import java.net.MalformedURLException;
22 import java.util.Hashtable;
23 import java.util.Iterator;
24 import java.util.LinkedList;
25 import java.util.Locale;
26 import java.util.Vector;
27 import javax.servlet.ServletConfig;
28 import javax.servlet.ServletException;
29 import javax.servlet.http.HttpServlet;
30 import javax.servlet.http.HttpServletRequest;
31 import javax.servlet.http.HttpServletResponse;
32 import openfuture.editxml.model.DomainManager;
33 import openfuture.editxml.model.JspConstants;
34 import openfuture.util.misc.SessionLocales;
35 import openfuture.util.servlet.HttpActionServlet;
36 import org.apache.struts.action.Action;
37 import org.apache.struts.util.MessageResources;
38
39 // Configuration Management Information:
40 // -------------------------------------
41 // $Id: EditXmlJspServlet.java,v 1.1.1.1 2001/07/08 18:29:31 wreissen Exp $
42 //
43 // Version History:
44 // ----------------
45 // $Log: EditXmlJspServlet.java,v $
46 // Revision 1.1.1.1 2001/07/08 18:29:31 wreissen
47 // initial version registered ad SourceForge
48 //
49 // Revision 1.1 2001/05/09 20:07:27 wreissen
50 // initial version.
51 //
52 //
53 //
54 // ***********************************************************************************
55 /**
56 * Servlet initializing the JSP contexts.<p>
57 *
58 *
59 * Created: Tue Apr 10 18:05:00 2001
60 *
61 * @author <a href="mailto:wolfgang@openfuture.de">Wolfgang Reissenberger</a>
62 * @version $Revision: 1.1.1.1 $
63 */
64
65 public class EditXmlJspServlet extends HttpActionServlet
66 implements JspConstants {
67
68
69 /**
70 * Initializes the servlet. The following initialization
71 * parameters are recognized:
72 * <ul>
73 * <li> <strong>openfuture.bugbase.locales</strong>: Comma
74 * separated list of used locales.<br>
75 * [<em>Default: de_DE, en_GB</em>]
76 * </ul><p>
77 *
78 * The following context parameters are set:
79 * <ul>
80 * <li> <strong>openfuture.bugbase.locales</strong>: an instance of
81 * {@link openfuture.util.misc.SessionLocales}. The locales are
82 * instantiated with the value from the initialization parameter
83 * <strong>openfuture.bugbase.locales</strong>.
84 * <li> <strong>{@link org.apache.struts.action.Action.LOCALE_KEY
85 org.apache.struts.action.LOCALE}</strong>:
86 * the currentlocale. It is instantiated with the first element
87 * from <strong>openfuture.bugbase.locales</strong>.
88 * </ul>
89 *
90 * @param config a <code>ServletConfig</code> value
91 * @exception ServletException if an error occurs
92 */
93 public void init (ServletConfig config) throws ServletException {
94
95 super.init(config);
96
97 // initialize the locales
98 String value = getInitParameter("openfuture.bugbase.locales");
99 if (value == null) value = "de_DE, en_GB";
100
101 SessionLocales locales = new SessionLocales(value);
102
103 getServletContext().setAttribute(LOCALES, locales);
104 log("Known locales: " + locales.getCodes());
105
106 // set the actual locale to the first given locale.
107 Locale locale = (Locale) locales.getLocales().getFirst();
108 getServletContext().setAttribute(Action.LOCALE_KEY, locale);
109
110 if (getServletContext().getAttribute(XML_DOMAINS) != null) {
111 LinkedList domains = (LinkedList) getServletContext().getAttribute(XML_DOMAINS);
112 DomainManager dm = new DomainManager(domains);
113 getServletContext().setAttribute(DOMAINMANAGER, dm);
114
115 log ("Domain manager initialized.");
116 } else {
117 log ("No XML domains defined! Domain manager NOT initialized.");
118 }
119
120 }
121
122 } // EditXmlJspServlet
123
124