Java ee 框架相关分析

框架
    structs2
        基本原理
        源码分析
    mybatis
        体系结构
        mybatis 源码分析
            
    netty
        netty 系统结构
        netty  源码分析

----------------------------------

1.structs  基本原理:

2.源码分析:

从上面的总结我们可以看到项目用到的相关知识点。当然这是我个人的分析并不全面。要分析一个开源的框架只有项目结合来分析才是最完美的。而接下来我们要做的是找到对应的入口类。显然我们要从Web.xml入手。从Web.xml上面我们可以找到我们需要的类。StrutsPrepareFilter类和StrutsExecuteFilter类。如图下(web.xml的部分内容)

filter包下有四个类分别为:FilterHostConfig.class,StrutsExecuteFilter.class,StrutsPrepareAndExecuteFilter.class,StrutsPrepareFilter.class,

参考博文:https://www.iteye.com/topic/450979

 mybatis
        体系结构

        

Mybatis的功能架构分为三层:

  • API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库。接口层一接收到调用请求就会调用数据处理层来完成具体的数据处理。
  • 数据处理层:负责具体的SQL查找、SQL解析、SQL执行和执行结果映射处理等。它主要的目的是根据调用的请求完成一次数据库操作。
  • 基础支撑层:负责最基础的功能支撑,包括连接管理、事务管理、配置加载和缓存处理,这些都是共用的东西,将他们抽取出来作为最基础的组件。为上层的数据处理层提供最基础的支撑。

        mybatis 源码分析

 相关重要类:

流程分析:

首先看一下参数映射文件相关内容:

1.call   typecaller 

2.执行构造:

 调用堆栈信息:

shouldSetParameter:44, ArrayTypeHandlerTest (org.apache.ibatis.type)
invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
invoke:62, NativeMethodAccessorImpl (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invokeMethod:686, ReflectionUtils (org.junit.platform.commons.util)
proceed:60, MethodInvocation (org.junit.jupiter.engine.execution)
proceed:131, InvocationInterceptorChain$ValidatingInvocation (org.junit.jupiter.engine.execution)
intercept:149, TimeoutExtension (org.junit.jupiter.engine.extension)
interceptTestableMethod:140, TimeoutExtension (org.junit.jupiter.engine.extension)
interceptTestMethod:84, TimeoutExtension (org.junit.jupiter.engine.extension)
apply:-1, 306980751 (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$106)
lambda$ofVoidMethod$0:115, ExecutableInvoker$ReflectiveInterceptorCall (org.junit.jupiter.engine.execution)
apply:-1, 1826699684 (org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall$$Lambda$107)
lambda$invoke$0:105, ExecutableInvoker (org.junit.jupiter.engine.execution)
apply:-1, 565372776 (org.junit.jupiter.engine.execution.ExecutableInvoker$$Lambda$240)
proceed:106, InvocationInterceptorChain$InterceptedInvocation (org.junit.jupiter.engine.execution)
proceed:64, InvocationInterceptorChain (org.junit.jupiter.engine.execution)
chainAndInvoke:45, InvocationInterceptorChain (org.junit.jupiter.engine.execution)
invoke:37, InvocationInterceptorChain (org.junit.jupiter.engine.execution)
invoke:104, ExecutableInvoker (org.junit.jupiter.engine.execution)
invoke:98, ExecutableInvoker (org.junit.jupiter.engine.execution)
lambda$invokeTestMethod$6:212, TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor)
execute:-1, 1254907391 (org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$252)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
invokeTestMethod:208, TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor)
execute:137, TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor)
execute:71, TestMethodTestDescriptor (org.junit.jupiter.engine.descriptor)
lambda$executeRecursively$5:135, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1108924067 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$185)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$7:125, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, 1448525331 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$184)
around:135, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:123, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1427381743 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$183)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:122, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:80, NodeTestTask (org.junit.platform.engine.support.hierarchical)
accept:-1, 873610597 (org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$189)
forEach:1249, ArrayList (java.util)
invokeAll:38, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$5:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1108924067 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$185)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$7:125, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, 1448525331 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$184)
around:135, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:123, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1427381743 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$183)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:122, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:80, NodeTestTask (org.junit.platform.engine.support.hierarchical)
accept:-1, 873610597 (org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService$$Lambda$189)
forEach:1249, ArrayList (java.util)
invokeAll:38, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$5:139, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1108924067 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$185)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$7:125, NodeTestTask (org.junit.platform.engine.support.hierarchical)
invoke:-1, 1448525331 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$184)
around:135, Node (org.junit.platform.engine.support.hierarchical)
lambda$executeRecursively$8:123, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:-1, 1427381743 (org.junit.platform.engine.support.hierarchical.NodeTestTask$$Lambda$183)
execute:73, ThrowableCollector (org.junit.platform.engine.support.hierarchical)
executeRecursively:122, NodeTestTask (org.junit.platform.engine.support.hierarchical)
execute:80, NodeTestTask (org.junit.platform.engine.support.hierarchical)
submit:32, SameThreadHierarchicalTestExecutorService (org.junit.platform.engine.support.hierarchical)
execute:57, HierarchicalTestExecutor (org.junit.platform.engine.support.hierarchical)
execute:51, HierarchicalTestEngine (org.junit.platform.engine.support.hierarchical)
execute:248, DefaultLauncher (org.junit.platform.launcher.core)
lambda$execute$5:211, DefaultLauncher (org.junit.platform.launcher.core)
accept:-1, 105374791 (org.junit.platform.launcher.core.DefaultLauncher$$Lambda$144)
withInterceptedStreams:226, DefaultLauncher (org.junit.platform.launcher.core)
execute:199, DefaultLauncher (org.junit.platform.launcher.core)
execute:132, DefaultLauncher (org.junit.platform.launcher.core)
startRunnerWithArgs:69, JUnit5IdeaTestRunner (com.intellij.junit5)
startRunnerWithArgs:33, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:230, JUnitStarter (com.intellij.rt.junit)
main:58, JUnitStarter (com.intellij.rt.junit)

2.看对应的SQL解析功能:

2.依次循环如下逻辑,解析完毕填充为止。

3.sql runner: 测试一个案例场景,对一个bean 进行upadate 和query 操作:

2.进行query操作哦

4.测试场景:返回结果集和查询属性关联抛出异常:

4.1 

2.根据lamnab 表达式ID嵌套查询

notes: mybatis – MyBatis 3 | 简介

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

执于代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值