spring boot @Enable*

Enable features:

@Import (Xxxx.class) // key, use the Import annotations, then the callback. Configuration class is a Xxxx.class

Xxxx implements ImportSelector

    selectImports // we pass the array of classes for assembly

Xxx implenments ImportBeanDefinitionRegistrar

  registerBeanDefinitions

demo reference links third way:

https://www.cnblogs.com/lql6/p/11805876.html

 

1) @EnableAsync to begin

① for a new cycle of the output, which allows asynchronous execution added @Async

 ② When the output, if not possible to add @EnableAsync method executed asynchronously on the implementation of FIG.

 View @EnableAsunc notes, internal callback @Import

 2) Implementation Notes monitor equipped with a characteristic view Enable

 ① First, a custom annotation.

 ② class with the introduction ScannerPackageRegistar @Import, which implements the method ImportBeanDefinitionRegistrar in registerBeanDefinitions,

To obtain the specified custom annotations in the scanned array of classes (class written at the start), the BeanDefinitionRegistry achieve a dynamic assembly and the callback MyBeanDefinitionProcessor

ImportBeanDefinitionRegistrar reference links: https://blog.csdn.net/jiachunchun/article/details/94569246

https://www.jianshu.com/p/2b993ced6a4c

(1) a custom annotations, address scanning type

 (2) Get array class packages which defines custom annotations by importingClassMetadata.getAnnotationAttributes, attrs stored in turn into strong List collection.

 

 (3) When the class into the spring to be fitted to the container when it is needed through BeanPostProcessor, so here BeanPostProcessor rewritten, to achieve the monitoring process to the class of the spring assembly.

 (4) Start the class

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/lql6/p/11806469.html