JFinalFilter源碼解析--初始化

web.xmljava

<filter>
        <filter-name>jfinal</filter-name>
        <filter-class>com.jfinal.core.JFinalFilter</filter-class>
        <init-param>
            <param-name>configClass</param-name>
            <param-value>manager.config.ManagerConfig</param-value>
        </init-param>
    </filter>

1. JFinalFilter    程序的入口 web

public void init(FilterConfig filterConfig) throws ServletException {
        createJFinalConfig(filterConfig.getInitParameter("configClass"));
        
        if (jfinal.init(jfinalConfig, filterConfig.getServletContext()) == false)//交給JFinal類去初始化
            throw new RuntimeException("JFinal init error!");
        
        handler = jfinal.getHandler();
        constants = Config.getConstants();
        encoding = constants.getEncoding();
        jfinalConfig.afterJFinalStart();
        
        String contextPath = filterConfig.getServletContext().getContextPath();
        contextPathLength = (contextPath == null || "/".equals(contextPath) ? 0 : contextPath.length());
    }

2. JFinal    進行初始化動做 app



boolean init(JFinalConfig jfinalConfig, ServletContext servletContext) {
        this.servletContext = servletContext;
        this.contextPath = servletContext.getContextPath();
        
        initPathUtil();
        
        Config.configJFinal(jfinalConfig);    // start plugin and init logger factory in this method
        constants = Config.getConstants();
        
        initActionMapping();//初始化請求URL與請求執行者Action的映射關係
        initHandler();//初始化Handler鏈式結構,ActionHandler在鏈表尾部最後處理
        initRender();//設置編碼格式、開發者模式、Render工廠(支持JSP、FreeMarker、Velocity三種視圖模式)
        initActiveRecord();
        initOreillyCos();
        initI18n();
        initTokenManager();
        
        return true;
    }
相關文章
相關標籤/搜索