File tree Expand file tree Collapse file tree 3 files changed +62
-4
lines changed
src/main/java/com/crossoverjie/spring Expand file tree Collapse file tree 3 files changed +62
-4
lines changed Original file line number Diff line number Diff line change 1+ package com .crossoverjie .spring .aware ;
2+
3+ import com .crossoverjie .Application ;
4+ import org .slf4j .Logger ;
5+ import org .slf4j .LoggerFactory ;
6+ import org .springframework .beans .BeansException ;
7+ import org .springframework .context .ApplicationContext ;
8+ import org .springframework .context .ApplicationContextAware ;
9+ import org .springframework .stereotype .Component ;
10+
11+ /**
12+ * Function:
13+ *
14+ * @author crossoverJie
15+ * Date: 20/03/2018 21:54
16+ * @since JDK 1.8
17+ */
18+ @ Component
19+ public class SpringLifeCycleAware implements ApplicationContextAware {
20+ private final static Logger LOGGER = LoggerFactory .getLogger (SpringLifeCycleAware .class );
21+
22+ private ApplicationContext applicationContext ;
23+
24+ @ Override
25+ public void setApplicationContext (ApplicationContext applicationContext ) throws BeansException {
26+ this .applicationContext = applicationContext ;
27+ LOGGER .info ("SpringLifeCycleAware start" );
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package com .crossoverjie .spring .processor ;
2+
3+ import com .crossoverjie .Application ;
4+ import org .slf4j .Logger ;
5+ import org .slf4j .LoggerFactory ;
6+ import org .springframework .beans .BeansException ;
7+ import org .springframework .beans .factory .config .BeanPostProcessor ;
8+ import org .springframework .stereotype .Component ;
9+
10+ /**
11+ * Function:
12+ *
13+ * @author crossoverJie
14+ * Date: 20/03/2018 22:11
15+ * @since JDK 1.8
16+ */
17+ @ Component
18+ public class SpringLifeCycleProcessor implements BeanPostProcessor {
19+ private final static Logger LOGGER = LoggerFactory .getLogger (SpringLifeCycleProcessor .class );
20+ @ Override
21+ public Object postProcessBeforeInitialization (Object bean , String beanName ) throws BeansException {
22+ return bean ;
23+ }
24+
25+ @ Override
26+ public Object postProcessAfterInitialization (Object bean , String beanName ) throws BeansException {
27+ return bean ;
28+ }
29+ }
Original file line number Diff line number Diff line change 1919public class SpringLifeCycleService implements InitializingBean ,DisposableBean {
2020 private final static Logger LOGGER = LoggerFactory .getLogger (SpringLifeCycleService .class );
2121 @ Override
22- public void destroy () throws Exception {
23- LOGGER .info ("SpringLifeCycleService destroy " );
22+ public void afterPropertiesSet () throws Exception {
23+ LOGGER .info ("SpringLifeCycleService start " );
2424 }
2525
2626 @ Override
27- public void afterPropertiesSet () throws Exception {
28- LOGGER .info ("SpringLifeCycleService start " );
27+ public void destroy () throws Exception {
28+ LOGGER .info ("SpringLifeCycleService destroy " );
2929 }
3030}
You can’t perform that action at this time.
0 commit comments