Browse Source

修改容器启动时DCN的注册

sunyj 9 years ago
parent
commit
d47c7d99e7

+ 8 - 3
search-console/src/main/java/com/uas/search/console/support/ContextRefreshedProcessor.java

@@ -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();
+			}
 		}
 
 	}