Jfinal启动原理及源码简析
以下所有源码只截取了部分代码,标题即为类名
1、Web.xml
<filter-name>jfinal</filter-name>
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
2、JFinalFilter
if (jfinal.init(jfinalConfig, filterConfig.getServletContext()) == false)
3、Jfinal
boolean init(JFinalConfig jfinalConfig, ServletContext servletContext) {Config.configJFinal(jfinalConfig); // start plugin and init log factory in this method}
4、Config
static void configJFinal(JFinalConfig jfinalConfig) {jfinalConfig.configConstant(constants); initLogFactory();jfinalConfig.configRoute(routes);jfinalConfig.configPlugin(plugins); startPlugins(); // very important!!!jfinalConfig.configInterceptor(interceptors);jfinalConfig.configHandler(handlers);}
加载jfinalConfig配置文件
5、jfinalConfig
public void configRoute(Routes me) {//增加自定义routeme.add(new ApiRoute());
6、 Routes
public Routes add(Routes routes) {if (routes != null) {routes.config(); // very important!!!for (Entry<String, Class<? extends Controller>> e : routes.map.entrySet()) {String controllerKey = e.getKey();if (this.map.containsKey(controllerKey)) {throw new IllegalArgumentException("The controllerKey already exists: " + controllerKey); }this.map.put(controllerKey, e.getValue());this.viewPathMap.put(controllerKey, routes.getViewPath(controllerKey));}}return this;}
7、JFinalFilter
加载完jfinalConfig回到JFinalFilter
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {try {handler.handle(target, request, response, isHandled);}
// handler.handle(target, request, response, isHandled);是整个Filter最核心的方法
这里的handlre来自JFinalFilter.init方法中52行handler=jfinal.getHandler();
8、Jfinal
private void initHandler() {Handler actionHandler = new ActionHandler(actionMapping, constants);handler = HandlerFactory.getHandler(Config.getHandlers().getHandlerList(), actionHandler);}
handler是由HandlerFactory的getHandler方法得来的,此处使用handler子类ActionHandler,并且传进去了有两个参数,一个是ActionMapping类的变量,一个是constants。
ActionMapping在ActionMapping中定义了一个路由(routes)和一个Interceptors,这个routes类里面主要的核心是两个Map,主要处理处理一些关于ActionMapping中对应的ControllerKey与Controller.class的事情。看下ActionHandler
9、ActionHandler
1)、根据ActionMapping获得相应的Action,
Action action = actionMapping.getAction(target, urlPara);
2)、然后利用反射进行方法的调用,最后把结果映射到相应的页面上去
new Invocation(action, controller).invoke();
转载于:https://www.cnblogs.com/Genesisx/p/6543310.html
Jfinal启动原理及源码简析相关推荐
- django源码简析——后台程序入口
django源码简析--后台程序入口 这一年一直在用云笔记,平时记录一些tips或者问题很方便,所以也就不再用博客进行记录,还是想把最近学习到的一些东西和大家作以分享,也能够对自己做一个总结.工作中主 ...
- 【Android项目】本地FM收音机开发及源码简析
[Android项目]本地FM收音机开发及源码简析 目录 1.概述 2.收音机的基本原理 3.收音机其他信息 RDS功能 4.Android开发FM收音机源码解析 5.App层如何设计本地FM应用 6 ...
- 【Golang源码分析】Go Web常用程序包gorilla/mux的使用与源码简析
目录[阅读时间:约10分钟] 一.概述 二.对比: gorilla/mux与net/http DefaultServeMux 三.简单使用 四.源码简析 1.NewRouter函数 2.HandleF ...
- Log-Pilot 源码简析
Log-Pilot 源码简析 简单介绍 源码简析 Pilot结构体 Piloter接口 main函数 Pilot.Run Pilot.New Pilot.watch Pilot.processEven ...
- (Ajax)axios源码简析(三)——请求与取消请求
传送门: axios源码简析(一)--axios入口文件 axios源码简析(二)--Axios类与拦截器 axios源码简析(三)--请求与取消请求 请求过程 在Axios.prototype.re ...
- java ArrayList 概述 与源码简析
ArrayList 概述 与源码简析 1 ArrayList 创建 ArrayList<String> list = new ArrayList<>(); //构造一个初始容量 ...
- Spring Boot源码简析 @EnableTransactionManagement
相关阅读 Spring Boot源码简析 事务管理 Spring Boot源码简析 @EnableAspectJAutoProxy Spring Boot源码简析 @EnableAsync Sprin ...
- ffmpeg实战教程(十三)iJKPlayer源码简析
要使用封装优化ijk就必须先了解ffmpeg,然后看ijk对ffmpeg的C层封装! 这是我看ijk源码时候的笔记,比较散乱.不喜勿喷~ ijk源码简析: 1.ijkplayer_jni.c 封装的播 ...
- PhxRPC源码简析
文章目录 前言 1. 背景 2. 特性 一.编译运行 1. 编译 2. 运行 二.整体框架 运行框架 代码框架 源码目录 生成代码 与svrkit的比较 三.network socket流 strea ...
- Spring Boot源码简析 @Qualifier
源码 @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementT ...
最新文章
- 人群计数--Mixture of Counting CNNs
- Sql Server使用链接服务器远程取数据!
- fcntl函数-文件控制函数
- 怎么判断日出时间早晚_云南8日游攻略以及费用,从西安到云南旅游怎么安排行程?...
- Funambol DM 安装过程
- Java Number Math 类
- pyspider all 启动失败:ValueError: Invalid configuration
- 17 CO配置-控制-产品成本控制-产品成本计划编制-定义成本核算类型
- python 输入输出转web_云计算开发学习笔记:Python3 输入和输出方式
- 显示无效imap服务器地址,imap服务器地址是什么意思
- BCHN近期收到一笔1000 BCH的匿名捐款
- 【C++入门】C++ STL概述
- 2021.4.18高一模拟赛
- 舞蹈课 (C++堆的优先级与重载)
- SSID、BSSID、ESSID的区别
- oracle的listener监听启动报TNS-12555/ TNS-12560 TNS-00525错误
- 有道云笔记客户端的下载和安装、使用(博主推荐)
- STM32 学习笔记 expected a type specifier
- PMP考试中的各种图总结
- 2分钟部署人生模拟器,解锁人生新剧情
热门文章
- truffle Migration是什么
- C++ std::shared_ptr是什么意思
- Hyperledger Fabric教程(11)-- 链码和背书策略
- PHP如何使用IPFS API用法
- 2021湖南高考成绩分段查询,2021年湖南高考成绩排名查询系统,湖南高考位次排名查询...
- redis mysql 视图_Redis 可以用来做数据库吗?
- JDBC12 ORM01 Object[]存放一条记录
- linux mysql 主从数据库_Linux下MySQL数据库主从同步配置
- linux系统pdf目录编辑器,Linux操作系统(三)编辑器与实用程序.pdf
- 1.4.2.PHP5.6 狐教程-环境(Mac下 PHP开发环境 配置及安装 php5.6.x nginx mysql)