File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
04fx/spring01/src/main/java/io/kimmking/spring02 Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ package io .kimmking .spring02 ;
2
+
3
+ import io .kimmking .spring01 .Student ;
4
+ import org .springframework .beans .BeansException ;
5
+ import org .springframework .beans .factory .config .BeanPostProcessor ;
6
+ import org .springframework .stereotype .Component ;
7
+
8
+ @ Component
9
+ public class HelloBeanPostProcessor implements BeanPostProcessor {
10
+ @ Override
11
+ public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
12
+ System .out .println (" ====> postProcessBeforeInitialization " + beanName +":" + bean );
13
+ // 可以加点额外处理
14
+ // 例如
15
+ if (bean instanceof Student ) {
16
+ Student student = (Student ) bean ;
17
+ student .setName (student .getName () + System .currentTimeMillis ());
18
+ }
19
+ return bean ;
20
+ }
21
+
22
+ @ Override
23
+ public Object postProcessAfterInitialization (Object bean , String beanName ) throws BeansException {
24
+ System .out .println (" ====> postProcessAfterInitialization " + beanName +":" + bean );
25
+ return bean ;
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments