|
|
@@ -22,9 +22,14 @@ public class ContextRefreshedProcessor implements ApplicationListener<ContextRef
|
|
|
|
|
|
@Override
|
|
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
|
|
- if (sysConf.getRegisterDCN()) {
|
|
|
- dcnRegistrationManager.unregisterDataChangeNotification();
|
|
|
- dcnRegistrationManager.registerDataChangeNotification();
|
|
|
+ // 事件会发生两次:
|
|
|
+ // 1.Initializing Spring root WebApplicationContext;
|
|
|
+ // 2.Initializing Spring FrameworkServlet 'spring-mvc-dispatcher'
|
|
|
+ // 2的情况下log4j刚初始化完成,此时注册DCN
|
|
|
+ if (event.getApplicationContext().getParent() != null) {
|
|
|
+ if (sysConf.getRegisterDCN()) {
|
|
|
+ dcnRegistrationManager.registerDataChangeNotification();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|