GithubHelp home page GithubHelp logo

spring源码阅读笔记 about blog HOT 13 OPEN

zxy16305 avatar zxy16305 commented on July 26, 2024
spring源码阅读笔记

from blog.

Comments (13)

zxy16305 avatar zxy16305 commented on July 26, 2024

这破玩意儿这么复杂的吗 😈
一开始是以xml为入口看的,之后就是以web为入口看的(想看controller的实例化过程),所以笔记有点混乱 😹

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

②--常用接口

记录一些常用到的接口的功能


  • BeanPostProcessor : 用来做一些bean的初始化/销毁时调用的函数(hook)
  • PriorityOrdered :
    下面这两个接口影响到添加BeanPostProcessor 的标志位
  • InstantiationAwareBeanPostProcessor : 可在bean实例化前/后调用的方法
  • DestructionAwareBeanPostProcessor:可在bean销毁前调用方法

以上所述方法都是接口中的方法 😂

  • SingletonBeanRegistry:公用的单实例注册接口
  • ThemeSource : 用来管理Theme
  • Theme : 用来管理MessageSource
  • ApplicationEventMulticaster : 用来管理ApplicationListener和他的事件
  • Aware :

+Environment :代表了当前程序运行的环境。同时创建代表环境的两个重要的概念,profiles和properties。profiles也就是一些bean(从xml或者注解而来)。

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

③可以研究的细节(未分类的意思)

  • getBeanNamesForType 的具体实现方式(先看作一个整体,方便阅读源码逻辑)

  • RootBeanDefinition 这个类在bean创建的时候被用到

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

④--RequestDispatcherServlet

前瞻

spring同一般的tomcat的servlet程序,只在web.xml处多配了 ContextLoaderListener和RequestDispatcherServlet两个类,就完成了servlet的拓展。看过了ComtextLoaderListener后(一知半解),再来看看ResquestDispatcherServlet。


在web.xml把他配成了一个servlet,并映射到 “/”路径上(一般情况下),这样任何请求都会到这个servlet里面。
观察其重写方法( init() , service(req,resp) , destroy() )的位置,

  • 重写 init()方法在 HttpServletBean 里面,
  • 重写 service() 方法在 FrameworkServlet 里面(同时也重写了do**方法)
  • 重写 destory() 方法在 FrameworkServlet 里面

流程简介

image

这个流程把主要的方法(有注释的方法 😂)列出来了,第二步看上去很奇怪是因为,HttpServlet里没有定义Patch的method。

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

⑤--注解记录--持续更新

bean factory 的初始化

    *
  1. BeanNameAware's {@code setBeanName} *
  2. BeanClassLoaderAware's {@code setBeanClassLoader} *
  3. BeanFactoryAware's {@code setBeanFactory} *
  4. EnvironmentAware's {@code setEnvironment} *
  5. EmbeddedValueResolverAware's {@code setEmbeddedValueResolver} *
  6. ResourceLoaderAware's {@code setResourceLoader} * (only applicable when running in an application context) *
  7. ApplicationEventPublisherAware's {@code setApplicationEventPublisher} * (only applicable when running in an application context) *
  8. MessageSourceAware's {@code setMessageSource} * (only applicable when running in an application context) *
  9. ApplicationContextAware's {@code setApplicationContext} * (only applicable when running in an application context) *
  10. ServletContextAware's {@code setServletContext} * (only applicable when running in a web application context) *
  11. {@code postProcessBeforeInitialization} methods of BeanPostProcessors *
  12. InitializingBean's {@code afterPropertiesSet} *
  13. a custom init-method definition *
  14. {@code postProcessAfterInitialization} methods of BeanPostProcessors *

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

spring-Integration(好用的很)

Remoting

JMS

JCA

JCA

Email

Tasks


Scheduling

介绍一下Cron表达式

Cron表达式由6或7个空格分割的时间字段组成,各个字段的含义:

字段位置 位置含义 允许值 允许的特殊字符
1 0-59 , - * /
2 分钟 0-59 , - * /
3 小时 0-23 , - * /
4 日期 1-31 , - * ? / L W C
5 月份 1-12 , - * /
6 星期 1-7 , - * ? / L C #
7 年(可选) 空值;1970-2099 , - * /

特殊字符含义:

  1. 星号(*):表示对应时间域的每一时刻
  2. 问好(?):只能在日期和星期字段中使用,为“无意义的值”
  3. 减号(-):表达一个范围
  4. 逗号(,):表达一个列表值
  5. 斜杠(/):(x/y)表达一个等步长序列,x为起始值,y为增量步长值
  6. L:只能在日期和星期字段中使用,代表LAST。日期中表示月份的最后一天;星期中表示星期六;但出现在星期中。且前面有数字X时,表示这个月的最后X天,例如5L,该月最后星期四。
  7. W:只能出现在日期字段里,表示距离该星期最近的工作日。
  8. LW:当月最后一个工作日
    9.井号(#):只能在星期字段中使用,表示当月的某个工作日。 6#3表示该月第三个星期五。没有则忽略不触发
  9. C:日期和星期中使用。表示计划所关联的日期。5C(不是很懂)

要配合springboot用的话

@Configuration
@EnableAsync
@EnableScheduling
public class AnsyConfig {
    @Scheduled(cron = "0/15 * * * * *")
    public void method1(){ System.out.println(1000); }
}

Cache

SPEL

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

zxy16305 avatar zxy16305 commented on July 26, 2024

占楼

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.