kylixs commented on a change in pull request #9129:
URL: https://github.com/apache/dubbo/pull/9129#discussion_r736501370



##########
File path: 
dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboSpringInitializer.java
##########
@@ -54,6 +64,42 @@ public static void initialize(BeanDefinitionRegistry 
registry) {
         initContext(context, registry, beanFactory);
     }
 
+    public static boolean remove(BeanDefinitionRegistry registry) {
+        return contextMap.remove(registry) != null;
+    }
+
+    public static boolean remove(ApplicationContext springContext) {
+        List<BeanDefinitionRegistry> removingKeys = new ArrayList<>();
+        for (Map.Entry<BeanDefinitionRegistry, DubboSpringInitContext> entry : 
contextMap.entrySet()) {
+            DubboSpringInitContext initContext = entry.getValue();
+            if (initContext.getApplicationContext() == springContext ||
+                initContext.getBeanFactory() == 
springContext.getAutowireCapableBeanFactory() ||
+                initContext.getRegistry() == 
springContext.getAutowireCapableBeanFactory()
+            ) {
+                removingKeys.add(entry.getKey());
+            }
+        }
+        for (BeanDefinitionRegistry key : removingKeys) {
+            DubboSpringInitContext context = contextMap.remove(key);
+            logger.info("Unbind dubbo module " + 
getModelName(context.getModuleModel()) + " from spring container: " +
+                ObjectUtils.identityToString(key));
+        }
+        return contextMap.keySet().removeAll(removingKeys);

Review comment:
       Fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to