In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
What is an overview of AOP? in view of this question, this article introduces in detail the corresponding analysis and answers, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
In the previous case, we need to create our own ApplicationContext object, and then call getBean to get the Bean that needs to be tested
Spring provides a more convenient way to create the ApplicationContext needed for testing, and it can help us to inject the Bean we need to test directly into the test class.
AOP concept
In the software industry, AOP is the abbreviation of AspectOrientedProgramming, translated as: a technology for aspect-oriented programming, which realizes the unified maintenance of program functions through pre-compilation and runtime dynamic agents. AOP is the continuation of OOP, is a hot spot in software development, is also an important content of Spring framework, and is a derivative paradigm of functional programming. Each part of the business logic can be isolated by using AOP, which reduces the coupling between the various parts of the business logic, improves the reusability of the program, and improves the efficiency of development at the same time.
Why do you need AOP
In project development, we often encounter a series of general requirements such as access control, log output, transaction management, data statistics and so on. This seemingly simple requirement will bring trouble in the actual development.
Look at AOP again.
Let's not think about how to solve these problems. In fact, AOP appears because we need to extend some existing methods, but we can't solve them by modifying the source code or changing the way they are called.
On the other hand, it is necessary to add functionality to the original method without modifying the source code and calling the method unchanged.
Because there are many methods that need to be extended, these methods are called an aspect, that is, an aspect is a collection of methods that need to be extended.
The purpose of AOP
The repetitive codes such as logging, performance statistics, security control, transaction handling and exception handling are separated from the business logic code. by separating these behaviors, we hope that they can be separated into non-business logic methods. and then change these behaviors will not affect the business logic code.
Looking directly at the name is indeed quite abstract, there is no way, when you create a new thing, you often want to give it a nb name, and this solution is aimed at some fixed scenarios, it is difficult to find a very accurate name to describe the solution.
Terms related to AOP
The concept of AOP was put forward by the AOP Alliance aopalliance, and the related concept also comes from the definition of aopalliance.
Connection point (joinpoint)
Is the point where the extension content interacts with the original content, which can be understood as a place that can be extended, usually a method, and attributes are also supported as connection points in AspectJ.
Example: three methods in the case
Tangent point (pointcut)
Pointcuts refer to the content to be extended (with added functionality), including methods or properties (joinpoint)
Example: two methods with added functionality in the case
Notification (adivce)
Notification refers to the function to be added to the pointcut
According to the timing of execution, it can be divided into:
Front, back, exception, final, surround, introduction
Introduction notification refers to adding methods or properties to a class without modifying the class code.
Example: output execution time function in the above case
Target (target)
The goal is to apply the notification object, that is, the object to be enhanced
Example: userDao in the above case
Weave in (weaving)
Weaving is a verb that describes the process of applying extended functionality to target
Example: the process of modifying the source code in a case
Agent (proxy)
Spring uses a proxy to complete the AOP, and when you enhance an object, you get a proxy object.
The whole process of SpringAOP is to apply advice to target and finally generate proxy, and we end up using proxy objects; raccoons change princes and steal beams and pillars.
Section (aspect)
It is a combination of pointcut and notification, and it is an abstract concept; an aspect refers to the collection of all pointcuts that apply the same notification
This is the answer to the overview question on what is called AOP. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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: 0
*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.