newbaby2012 2022-02-13 08:17:53 阅读数:310
·
Note that it inherits InstantiationAwareBeanPostProcessor Interface
All interceptors implement Advice Interface , Or a Advice object , such as MethodAdvice
The proxy object passes through addAdvice To add interceptors , When you call a proxy object method, you first call MethodBeforeAdvice Of before Method
aop xml context Configure interceptors
Handwriting spring mvc
Put commonly used variables into the cache Map in
Learn first xml Version of spring Source code
Have a look addAdvice Method
processon Have a look AOP and IOC Mind maps
How to solve circular dependency earlySingletonExposure
spring Three level cache , Have a look singletonObjects
Is learning source code for secondary expansion ?
servletContainerInitializer https://segmentfault.com/a/1190000022763768
springboot Is based on annotations ? No xml
At the beginning of looking at the source code, it depends on the return value
therefore spring getbean Returned object , Are they all proxy objects ??
beforeSingletonCreation There's a what ?
resolveBeforeInstantiation Create proxy object Place the cache , profiling aspect ? But the premise is that there must be an object
So the actual proxy object is , stay initializeBean Of applyBeanPostProcessorAfterInitialization In the method
But this · Must have EnableAspectAutoProxy annotation
At the beginning of the screenshot !! The back should also
In every way ?
Reference resources spring Source code 1_AOP_ Enjoy learning _qq_53294028 The blog of -CSDN Blog
There are three steps to generate the section :
1. Config Class add @EnableAspectJAutoProxy, Put business logic and aspect classes in it
@Configuration
@EnableAspectJAutoProxy
public class Cap10MainConfig {
@Bean
public Calculator calculator(){
return new Calculator();
}
@Bean
public LogAspects logAspects(){
return new LogAspects();
}
}
2. adopt @Aspect Declare the facet class , And define... In the section class pointCut and Before,After etc.
// Log facet class
@Aspect
public class LogAspects {
@Pointcut("execution(public int com.enjoy.cap10.aop.Calculator.*(..))")
public void pointCut(){};
//@before Represents a cut in... Before the target method is executed , And specify before which method to cut in
@Before("pointCut()")
public void logStart(){
System.out.println(" Division operation .... The parameter list is :{}");
}
}
3. Business class
public class Calculator {
// Business logic approach
public int div(int i, int j){
System.out.println("--------");
return i/j;
}
}
Write for yourself ,ioc aop transaction
copyright:author[newbaby2012],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130817507618.html