01: /*
02: * This file is part of the WfXML servlet.
03: * Copyright (C) 2001-2007 Danet GmbH (www.danet.de), BU BTS.
04: * All rights reserved.
05: *
06: * This program is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU General Public License as published by
08: * the Free Software Foundation; either version 2 of the License, or
09: * (at your option) any later version.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: * GNU General Public License for more details.
15: *
16: * You should have received a copy of the GNU General Public License
17: * along with this program; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: * $Id: InitServlet.java,v 1.2 2007/02/12 21:37:07 mlipp Exp $
21: *
22: * $Log: InitServlet.java,v $
23: * Revision 1.2 2007/02/12 21:37:07 mlipp
24: * Added more portlets.
25: *
26: * Revision 1.1 2007/02/10 21:13:56 mlipp
27: * Started JBoss portal.
28: *
29: */
30: package de.danet.an.wfdemo.jbportal;
31:
32: import java.io.IOException;
33: import java.io.InputStream;
34: import java.io.InputStreamReader;
35: import java.io.Reader;
36: import java.io.StringReader;
37:
38: import javax.servlet.ServletConfig;
39: import javax.servlet.ServletContext;
40: import javax.servlet.ServletException;
41: import javax.servlet.http.HttpServlet;
42:
43: import org.mozilla.javascript.Context;
44: import org.mozilla.javascript.Scriptable;
45: import org.mozilla.javascript.ScriptableObject;
46:
47: /**
48: * This class provides an interface between the workflow engine (i.e. its
49: * processes and any HTTP based client (e.g. Web browser application).
50: *
51: * <p>
52: * The servlet works as a mediator for services of the different roles,
53: * excluding the observer, as they are defined by the Wf-XML 2.0 standard.
54: * </p>
55: *
56: * @author Michael Lipp
57: * @web.servlet name="JBoss Portal Init Servlet"
58: * display-name="JBoss Portal Init Servlet"
59: * description="Initializes some Portal properties"
60: * load-on-startup="30000"
61: * @web.servlet-mapping url-pattern="/does-not-serve-anything-really"
62: */
63: public class InitServlet extends HttpServlet {
64: /** Logger instance. */
65: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
66: .getLog(InitServlet.class);
67:
68: /**
69: * Default initialization method.
70: *
71: * @param servletConfig
72: * a <code>ServletConfig</code> value
73: * @exception ServletException
74: * if an error occurs
75: */
76: public void init(ServletConfig servletConfig)
77: throws ServletException {
78: try {
79: Context cx = Context.enter();
80: Scriptable scope = cx.initStandardObjects(null);
81: ServletContext servletContext = servletConfig
82: .getServletContext();
83: ((ScriptableObject) scope).defineProperty("servletContext",
84: servletContext, ScriptableObject.PERMANENT
85: | ScriptableObject.READONLY);
86: InputStream is = servletContext
87: .getResourceAsStream("initScript.js");
88: Reader sr = new InputStreamReader(is, "ISO-8859-1");
89: cx.evaluateReader(scope, sr, "<script>", 1, null);
90: } catch (IOException e) {
91: throw new ServletException(e);
92: } finally {
93: Context.exit();
94: }
95: }
96:
97: }
|