⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileenvplugin.java

📁 chatper4JdonCMS.rar
💻 JAVA
字号:
package com.jdon.cms.events;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.util.ArrayList;import javax.servlet.ServletException;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.struts.action.ActionServlet;import org.apache.struts.action.PlugIn;import org.apache.struts.config.ModuleConfig;import org.apache.struts.util.LabelValueBean;import com.jdon.util.Debug;import com.jdon.cms.xml.XmlUtil;import com.jdon.util.StringUtil;/** * * <p><strong>IMPLEMENTATION WARNING</strong> - If this web application is run * from a WAR file, or in another environment where reading and writing of the * web application resource is impossible, the initial contents will be copied * to a file in the web application temporary directory provided by the * container.  This is for demonstration purposes only - you should * <strong>NOT</strong> assume that files written here will survive a restart * of your servlet container.</p> * * @author Craig R. McClanahan * @version $Revision: 1.8 $ $Date: 2003/02/17 00:31:45 $ */public final class FileEnvPlugIn implements PlugIn {    private final static String module = FileEnvPlugIn.class.getName();    private final static XmlUtil xmlUtil = XmlUtil.getInstance();    // ----------------------------------------------------- Instance Variables    /**     * The application configuration for our owning module.     */    private ModuleConfig config = null;    /**     * The {@link ActionServlet} owning this application.     */    private ActionServlet servlet = null;    /**     * The web application resource path of our persistent database     * storage file.     */    private String pathname = "/WEB-INF/web.xml";    // --------------------------------------------------------- PlugIn Methods    /**     * Gracefully shut down this database, releasing any resources     * that were allocated at initialization.     */    public void destroy() {        Debug.logWarning("Finalizing File plug in", module);//        servlet.getServletContext().removeAttribute(Constants.DATABASE_KEY);        servlet = null;        config = null;    }    /**     * Initialize and load our initial database from persistent storage.     *     * @param servlet The ActionServlet for this web application     * @param config The ApplicationConfig for our owning module     *     * @exception ServletException if we cannot configure ourselves correctly     */    public void init(ActionServlet servlet, ModuleConfig config)        throws ServletException {        Debug.logWarning("Initializing file env plug in from '", module);        // Remember our associated configuration and servlet        this.config = config;        this.servlet = servlet;        String realpath = servlet.getServletContext().getRealPath(pathname);        File file = new File(realpath);        String homeDir = file.getParent();        homeDir = StringUtil.replace(homeDir, "WEB-INF", "");        try {          xmlUtil.setHomeDir(homeDir);          xmlUtil.InitFileEnv();        } catch (Exception e) {            throw new ServletException("Cannot init file env" , e);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -