AOP(Aspect Oriented Programming) is Aspect Oriented Programming. In OOP, when we need to introduce the same common behavior for multiple objects with different inheritance relationships, such as logging, security monitoring, etc., we need to reference the common behavior in each object, resulting in repeated code, which is not conducive to program maintenance. So there is a complement to object-oriented programming, section-oriented programming, where AOP focuses horizontally rather than vertically.
AOP custom tag parsing
We know that during container loading, when you register beanDefinition in the doRegisterBeanDefinition method, you go into parseBeanDefinition, and by comparing namespaces, Enter the parseCustomElement method to parse custom tags. First, find the corresponding handler in the namespace and execute init to register the corresponding parse. Take the following example:
<aop:aspectj-autoproxy/>
Copy the code
AspectJAutoProxyBeanDefinitionParser
public BeanDefinition parse(Element element, AspectJAnnotationAutoProxyCreator ParserContext ParserContext) {/ / registration AopNamespaceUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext, element); // Handling of subclasses in annotations extendBeanDefinition(Element, parserContext); return null; }Copy the code