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

📄 actionservlet.java

📁 java编程的一些小例子
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
///////////////////////////////////////////////////////////
// DeJaved by mDeJava v1.0. Copyright 1999 MoleSoftware. //
//       To download last version of this software:      //
//            http://molesoftware.hypermatr.net          //
//               e-mail:molesoftware@mail.ru             //
///////////////////////////////////////////////////////////

package org.apache.struts.action;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.DataSource;
import org.apache.commons.beanutils.*;
import org.apache.commons.beanutils.converters.*;
import org.apache.commons.collections.FastHashMap;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.RuleSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.config.*;
import org.apache.struts.config.impl.ModuleConfigImpl;
import org.apache.struts.util.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

// Referenced classes of package org.apache.struts.action:
//            ActionFormBeans, ActionForwards, ActionMappings, RequestProcessor, 
//            PlugIn, ActionFormBean, ActionForward, ActionMapping, 
//            DynaActionFormClass

public class ActionServlet extends HttpServlet
{

    protected String config = null;
    protected Digester configDigester = null;
    protected boolean convertNull = false;
    protected FastHashMap dataSources = null;
    protected int debug = 0;
    protected MessageResources internal = null;
    protected String internalName = null;
    protected static Log log = null;
    protected RequestProcessor processor = null;
    protected String registrations[] = {
        "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN", "/org/apache/struts/resources/struts-config_1_0.dtd", "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN", "/org/apache/struts/resources/struts-config_1_1.dtd", "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN", "/org/apache/struts/resources/web-app_2_2.dtd", "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN", "/org/apache/struts/resources/web-app_2_3.dtd"
    };
    protected String servletMapping = null;
    protected String servletName = null;
    static Class class$org$apache$struts$action$ActionServlet = null; /* synthetic field */
    static Class class$java$math$BigDecimal = null; /* synthetic field */
    static Class class$java$math$BigInteger = null; /* synthetic field */
    static Class class$java$lang$Boolean = null; /* synthetic field */
    static Class class$java$lang$Byte = null; /* synthetic field */
    static Class class$java$lang$Character = null; /* synthetic field */
    static Class class$java$lang$Double = null; /* synthetic field */
    static Class class$java$lang$Float = null; /* synthetic field */
    static Class class$java$lang$Integer = null; /* synthetic field */
    static Class class$java$lang$Long = null; /* synthetic field */
    static Class class$java$lang$Short = null; /* synthetic field */

    public ActionServlet()
    {
        config = "/WEB-INF/struts-config.xml";
        configDigester = null;
        convertNull = false;
        dataSources = new FastHashMap();
        debug = 0;
        internal = null;
        internalName = "org.apache.struts.action.ActionResources";
        processor = null;
        servletMapping = null;
        servletName = null;
    }

    public void destroy()
    {
        if(log.isDebugEnabled())
            log.debug(internal.getMessage("finalizing"));
        destroyModules();
        destroyDataSources();
        destroyInternal();
        getServletContext().removeAttribute("org.apache.struts.action.ACTION_SERVLET");
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if(classLoader == null)
            classLoader = (class$org$apache$struts$action$ActionServlet != null ? class$org$apache$struts$action$ActionServlet : (class$org$apache$struts$action$ActionServlet = class$("org.apache.struts.action.ActionServlet"))).getClassLoader();
        try
        {
            LogFactory.release(classLoader);
        }
        catch(Throwable t) { }
    }

    public void init()
        throws ServletException
    {
        initInternal();
        initOther();
        initServlet();
        getServletContext().setAttribute("org.apache.struts.action.ACTION_SERVLET", this);
        ModuleConfig moduleConfig = initModuleConfig("", config);
        initModuleMessageResources(moduleConfig);
        initModuleDataSources(moduleConfig);
        initModulePlugIns(moduleConfig);
        moduleConfig.freeze();
        for(Enumeration names = getServletConfig().getInitParameterNames(); names.hasMoreElements();)
        {
            String name = (String)names.nextElement();
            if(name.startsWith("config/"))
            {
                String prefix = name.substring(6);
                moduleConfig = initModuleConfig(prefix, getServletConfig().getInitParameter(name));
                initModuleMessageResources(moduleConfig);
                initModuleDataSources(moduleConfig);
                initModulePlugIns(moduleConfig);
                moduleConfig.freeze();
            }
        }

        destroyConfigDigester();
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        process(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        process(request, response);
    }

    public void addServletMapping(String servletName, String urlPattern)
    {
        if(log.isDebugEnabled())
            log.debug("Process servletName=" + servletName + ", urlPattern=" + urlPattern);
        if(servletName == null)
            return;
        if(servletName.equals(this.servletName))
            servletMapping = urlPattern;
    }

    public DataSource findDataSource(String key)
    {
        if(key == null)
            return (DataSource)dataSources.get("org.apache.struts.action.DATA_SOURCE");
        else
            return (DataSource)dataSources.get(key);
    }

    public ActionFormBean findFormBean(String name)
    {
        ActionFormBeans afb = (ActionFormBeans)getServletContext().getAttribute("org.apache.struts.action.FORM_BEANS");
        if(afb == null)
            return null;
        else
            return afb.findFormBean(name);
    }

    public ActionForward findForward(String name)
    {
        ActionForwards af = (ActionForwards)getServletContext().getAttribute("org.apache.struts.action.FORWARDS");
        if(af == null)
            return null;
        else
            return af.findForward(name);
    }

    public ActionMapping findMapping(String path)
    {
        ActionMappings am = (ActionMappings)getServletContext().getAttribute("org.apache.struts.action.MAPPINGS");
        if(am == null)
            return null;
        else
            return am.findMapping(path);
    }

    public int getDebug()
    {
        return debug;
    }

    public MessageResources getInternal()
    {
        return internal;
    }

    public MessageResources getResources()
    {
        return (MessageResources)getServletContext().getAttribute("org.apache.struts.action.MESSAGE");
    }

    public void log(String message, int level)
    {
        if(debug >= level)
            log(message);
    }

    protected void destroyApplications()
    {
        destroyModules();
    }

    protected void destroyModules()
    {
        ArrayList values = new ArrayList();
        for(Enumeration names = getServletContext().getAttributeNames(); names.hasMoreElements(); values.add(names.nextElement()));
        for(Iterator keys = values.iterator(); keys.hasNext();)
        {
            String name = (String)keys.next();
            Object value = getServletContext().getAttribute(name);
            if(value instanceof ModuleConfig)
            {
                ModuleConfig config = (ModuleConfig)value;
                try
                {
                    getRequestProcessor(config).destroy();
                }
                catch(ServletException e)
                {
                    log.error(e);
                }
                getServletContext().removeAttribute(name);
                PlugIn plugIns[] = (PlugIn[])getServletContext().getAttribute("org.apache.struts.action.PLUG_INS" + config.getPrefix());
                if(plugIns != null)
                {
                    for(int i = 0; i < plugIns.length; i++)
                    {
                        int j = plugIns.length - (i + 1);
                        plugIns[j].destroy();
                    }

                    getServletContext().removeAttribute("org.apache.struts.action.PLUG_INS" + config.getPrefix());
                }
            }
        }

    }

    protected void destroyConfigDigester()
    {
        configDigester = null;
    }

    protected void destroyDataSources()
    {
        FastHashMap fasthashmap = dataSources;
        JVM INSTR monitorenter ;
        for(Iterator keys = dataSources.keySet().iterator(); keys.hasNext();)
        {
            String key = (String)keys.next();
            getServletContext().removeAttribute(key);
            DataSource dataSource = findDataSource(key);
            if(dataSource instanceof GenericDataSource)
            {
                if(log.isDebugEnabled())
                    log.debug(internal.getMessage("dataSource.destroy", key));
                try
                {
                    ((GenericDataSource)dataSource).close();
                }
                catch(SQLException e)
                {
                    log.error(internal.getMessage("destroyDataSource", key), e);
                }
            }
        }

        dataSources.clear();
        fasthashmap;
        JVM INSTR monitorexit ;
        break MISSING_BLOCK_LABEL_151;
        Exception exception;
        exception;
        fasthashmap;
        JVM INSTR monitorexit ;
        throw exception;
    }

    protected void destroyInternal()
    {
        internal = null;

⌨️ 快捷键说明

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