In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what is the use of spring". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the use of spring"?
1. Spring implements the factory class of the factory pattern, which is called BeanFactory (interface).
Its subclass ApplicationContext is usually used in programs.
Spring is equivalent to a large factory class that is configured in its configuration file through elements for
Create the class name and properties of the instance object.
The factory pattern is a production object-oriented design pattern. With the factory pattern, when a class of
Object, the class specified by new is no longer needed, but the method in the factory is called. You don't need it.
Care about the creation process of the object. Even sometimes, maybe the object you need is just some kind of large classification.
It's fine, but it doesn't have to be a specified type. Do not rely too much on certain classes, all of which are
Easily replaced to improve the maintainability of the entire project.
2. Spring provides good support for IOC (inversion of Control), and IOC is also a programming idea.
It is a kind of architecture art, and the decoupling between modules can be well realized by using this idea.
IOC is the control of the life cycle of object creation, maintenance, destruction and so on. This process is generally
It is actively controlled by our program.
DI is also an important implementation of IOC. The creation of one object often involves the creation of other objects.
This is dependence. Since the IOC mechanism is responsible for the creation of objects
Then this dependency must be taken care of by the IOC container.
The responsible way is DI-- dependency injection, by writing the dependency to the configuration file
Then when the dependent object is created, the dependent object is injected by the IOC container.
If a dependency is detected when creating A, the IOC container sets the object B on which A depends.
After creation, it is injected into A (assembled, implemented through the reflection mechanism), and then An is returned to the object requestor to complete the work.
3. Spring provides a good package for AOP technology, and AOP is called aspect-oriented programming.
That is, there are many methods of unrelated classes in the system.
Add some kind of system function code to these many methods.
Such as adding log, permission judgment, exception handling, this kind of application is called AOP.
The proxy technology is used to realize the AOP function, and the client program no longer calls the target.
While calling the proxy class, the proxy class has the same method declaration as the target class.
You can implement the same method declaration in two ways, one is to implement the same interface
The second is as a subclass of the target. The Proxy class is used in JDK to generate dynamic proxy
Method to generate an implementation class for an interface, or CGLIB if you want to generate a subclass for a class.
The proxy of the system function is provided by the Advice object, and the proxy object is created.
At least the target class and the Advice class are required. Spring provides this support
You only need to configure these two elements in the Spring configuration file to implement the proxy and AOP functions.
At this point, I believe you have a deeper understanding of "what is the use of spring"? you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 237
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.