zonghaishang commented on a change in pull request #1550: [Dubbo-Fix 
EnableDubbo annotation bug]
URL: https://github.com/apache/incubator-dubbo/pull/1550#discussion_r179936669
 
 

 ##########
 File path: 
dubbo-config/dubbo-config-spring/src/main/java/com/alibaba/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessor.java
 ##########
 @@ -98,13 +110,88 @@ public void 
postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) t
         Set<String> resolvedPackagesToScan = 
resolvePackagesToScan(packagesToScan);
 
         if (!CollectionUtils.isEmpty(resolvedPackagesToScan)) {
+
+            // register @Service
             registerServiceBeans(resolvedPackagesToScan, registry);
+
+            // register @Component
+            registerComponentBeans(resolvedPackagesToScan, registry);
         } else {
             if (logger.isWarnEnabled()) {
                 logger.warn("packagesToScan is empty , ServiceBean registry 
will be ignored!");
             }
         }
 
+        /**
+         * The solution to consumers early references to unexposed services.
+         */
+        deferConfiguationBeans();
+
+    }
+
+    /**
+     * Registers Beans whose classes was annotated {@link Component}
+     *
+     * @param packagesToScan The base packages to scan
+     * @param registry       {@link BeanDefinitionRegistry}
+     */
+    private void registerComponentBeans(Set<String> packagesToScan, 
BeanDefinitionRegistry registry) {
+
+        DubboClassPathBeanDefinitionScanner scanner =
+                new DubboClassPathBeanDefinitionScanner(registry, environment, 
resourceLoader);
+
+        BeanNameGenerator beanNameGenerator = 
resolveBeanNameGenerator(registry);
+
+        scanner.setBeanNameGenerator(beanNameGenerator);
+
+        scanner.addExcludeFilter(new AnnotationTypeFilter(Controller.class, 
false));
 
 Review comment:
   Process discovery and `@Component` under the same service package.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to