Blog: bugstack.cn
Precipitation, share, grow, let yourself and others can gain something! 😄
One, foreword
No serious! Write face classics, go to Spring source 🌶?
Yes, after writing 4 interviews about the Spring core source code, I decided to hand polish Spring. Why do you do that? Because all the content I want to write, I hope it is for the purpose of understanding science thinking to learn, rather than relying on hard memorization. And every Spring source content analysis covered in the book so far is still very large, even if some of the non-mainstream logic is removed. Experienced old drivers can read a few times to accept, but in terms of the new can only be put into the collection folder to eat ash!
Those of you who have read the Java Experience Manual I compiled will know that it is a technical book that explains the core of Java with an interview title and tries to prove to you that code is a concrete implementation of mathematical logic. As you peruse the books, you’ll find a lot of math in Java: perturbation functions, load factors, zipper addressing, open addressing, Fibonacci hashing, the use of the golden ratio, and so on.
So when I wrote the handbook on the Spring series, I wanted it to be a compilation of technical information and value that would help programmers grow, not just a list of miscellaneous things. Then draw lessons from tiny-Spring, mini-Spring and my experience of learning spring and often torturing the development of middleware, to write a suitable for their precipitation is also satisfied with the learning of spring materials.
Fu Elder brother’s face classics are “false”, come up to learn mathematics, source, dig core! Good! Now that you say so, let’s define our goals, plan, and get started!
Second, the target
This warehouse to learn Spring source code for the purpose of taking readers a little handwritten simplified version of the Spring framework, understand the Spring core principle, for the subsequent in-depth study of Spring to lay a foundation.
In the process of handwriting will eliminate the complex content of Spring source code, extract the core logic in the overall framework, simplify the code implementation process, retain the core functions, such as: IOC, AOP, Bean life cycle, context, scope, resource processing and other content implementation.
All content implementation will start from Jane, step by step to lead everyone to implement, and finally all content is completed, in providing a relatively complete small-Spring, in this process as long as you can follow down, then you will be able to easily read spring source code.
Three, plans,
I was supposed to have a Spring AOP filter notifier article ready this week, and the source code is ready. But I guess the reading is split and most of it goes into favorites.
The greatest hope of writing an article is to interact with readers, not afraid of your suggestions, but afraid of your not giving three! All the comments, comments, likes and shares given by readers are the beginning of the next article’s 120 miles of power, so after the source of this article is finished, I decided to tidy up the Spring, not only let me have a sense of learning process precipitation, but also let readers can really learn this part of the content. Back, that is eight-part essay, understand, can rise posture!
To be reasonable, in fact, I am also a willing to hand source master, because I can get part of the source code in the process of business system development, it is unlikely to contact the technical content. And this part from the source code to learn the technical content can be reused to the business system development, for example, I have written a lot of middleware and design patterns, are from the content of the framework source code mining and application.
How much is the Spring framework source code?
So far, I have written four chapters of case source code, mainly including: container creation, Bean definition and registration, instance construction, property filling, because the initial content is relatively simple, so it will be faster to write. The structure of the directory is as follows, and further chapters will be added:
- Chapter 1: Introduction, What can Writing Spring bring you?
- Chapter 2: create | Spring Bean containersmall-spring-step-01
- Chapter 3: the definition of a Spring Bean | and registrationsmall-spring-step-02
- Chapter 4: Spring Bean constructor instantiation strategy and additional dynamically generated using |small-spring-step-03
- Chapter 5: give Bean | object with attribute informationsmall-spring-step-04
- Chapter 6: To be filed…
Standing in my point of view, the source code is faster than writing articles, even if it is a very simple knowledge point, also want to do neither complex redundant introduction, also want to be able to put the breadth and depth of knowledge clearly. Therefore, IN this process, I will also read a lot of materials and documents on the official website, and finally show the valuable content that is in line with the current chapter to readers for learning. At the same time, it is also a personal accumulation of technical content.
Four, the source code
This chapter is the beginning of the whole Spring manual column, so here the source address and learning to use the way to explain to the reader, easy to follow you in the follow-up can smoothly learn to this part of the content.
- Source directory:Github.com/fuzhengwei/… –
Summary article, source code, Visio, XMIND, PPT, including the creation process of sorting out content, convenient for readers to learn
- Source code implementation:Github.com/small-sprin… –
Dismantle the implementation steps, build organizational engineering, show each chapter of the specific source code implementation process, if you want to also can participate in the construction of the project
Five, the summary
- When you read Spring’s source code, you’ll see all sorts of nesting, recursion, proxies, and jumping programs that might not even know where to hit breakpoints when trying to debug. Eventually lead to their own will not look down the source code! This is because Spring has been developed for a long time, and it has made too many supplements and optimizations to meet different scenarios. Therefore, what we need to do is to peel the silk and cocoon, reflect the core, and reflect the most directly relevant content for learning, so that it will be easier to understand.
- In the process of learning the source code, small Fu Ge will start with you from the simplest, the simplest Bean container, maybe sometimes some chapters content is not too much, but I will help you establish some knowledge association, as far as possible so that you in this learning process, harvest more.
- So this chapter is about
Spring hand rolled
That’s the beginning of the column, and you can read the article and get the source code until we’ve done everything we need to develop a relatively complete Spring framework. I hope you and I can keep learning to punch in the process!
Six, series recommendation
- “Java Face book Manual” PDF, 417 pages 115,000 words, complete & release!
- Spring Bean IOC, AOP loop depends on interpretation
- Full process source code parsing for getBean in Spring
- What are the features of Spring IOC?
- How do I stuff a Bean into a Spring container?