Package de.danet.an.wfdemo.jbportal

Source Code of de.danet.an.wfdemo.jbportal.InitServlet

/*
* This file is part of the WfXML servlet.
* Copyright (C) 2001-2007 Danet GmbH (www.danet.de), BU BTS.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* $Id: InitServlet.java 2249 2007-02-12 21:37:07Z mlipp $
*
* $Log$
* Revision 1.1  2007/02/10 21:13:56  mlipp
* Started JBoss portal.
*
*/
package de.danet.an.wfdemo.jbportal;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;

/**
* This class provides an interface between the workflow engine (i.e. its
* processes and any HTTP based client (e.g. Web browser application).
*
* <p>
* The servlet works as a mediator for services of the different roles,
* excluding the observer, as they are defined by the Wf-XML 2.0 standard.
* </p>
*
* @author Michael Lipp
* @web.servlet name="JBoss Portal Init Servlet"
*              display-name="JBoss Portal Init Servlet"
*              description="Initializes some Portal properties"
*              load-on-startup="30000"
* @web.servlet-mapping url-pattern="/does-not-serve-anything-really"
*/
public class InitServlet extends HttpServlet {
    /** Logger instance. */
    private static final org.apache.commons.logging.Log logger
        = org.apache.commons.logging.LogFactory.getLog(InitServlet.class);

    /**
     * Default initialization method.
     *
     * @param servletConfig
     *            a <code>ServletConfig</code> value
     * @exception ServletException
     *                if an error occurs
     */
    public void init(ServletConfig servletConfig) throws ServletException {
        try {
            Context cx = Context.enter();
            Scriptable scope = cx.initStandardObjects(null);
            ServletContext servletContext = servletConfig.getServletContext();
            ((ScriptableObject)scope).defineProperty
              ("servletContext", servletContext,
               ScriptableObject.PERMANENT | ScriptableObject.READONLY);
            InputStream is
                = servletContext.getResourceAsStream("initScript.js");           
            Reader sr = new InputStreamReader (is, "ISO-8859-1");
            cx.evaluateReader (scope, sr, "<script>", 1, null);
        } catch (IOException e) {
            throw new ServletException (e);
        } finally {
            Context.exit();
        }
    }

}
TOP

Related Classes of de.danet.an.wfdemo.jbportal.InitServlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.