You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by GitBox <gi...@apache.org> on 2022/06/12 06:17:51 UTC

[GitHub] [incubator-shenyu] dragon-zhang commented on a diff in pull request #3537: [ISSUE #3484] springmvc client lossless registration

dragon-zhang commented on code in PR #3537:
URL: https://github.com/apache/incubator-shenyu/pull/3537#discussion_r895115141


##########
shenyu-client/shenyu-client-http/shenyu-client-springmvc/src/main/java/org/apache/shenyu/client/springmvc/init/SpringMvcClientEventListener.java:
##########
@@ -102,46 +103,42 @@ public SpringMvcClientBeanPostProcessor(final PropertiesConfig clientConfig,
         mappingAnnotation.add(RequestMapping.class);
         publisher.start(shenyuClientRegisterRepository);
     }
-    
+
     @Override
-    public Object postProcessAfterInitialization(@NonNull final Object bean, @NonNull final String beanName) throws BeansException {
-        Class<?> clazz = bean.getClass();
-        if (AopUtils.isAopProxy(bean)) {
-            clazz = AopUtils.getTargetClass(bean);
-        }
-        // Filter out is not controller out
-        if (Boolean.TRUE.equals(isFull) || !hasAnnotation(bean.getClass(), Controller.class)) {
-            return bean;
+    public void onApplicationEvent(final ContextRefreshedEvent event) throws BeansException {
+        Map<String, Object> controllerBeans = event.getApplicationContext().getBeansWithAnnotation(Controller.class);
+        for (Map.Entry<String, Object> entry : controllerBeans.entrySet()) {
+            handler(entry.getValue());
         }
-        
-        final ShenyuSpringMvcClient beanShenyuClient = AnnotatedElementUtils.findMergedAnnotation(clazz, ShenyuSpringMvcClient.class);
-        final String superPath = buildApiSuperPath(clazz);
+    }
+
+    private void handler(@NonNull final Object bean) {
+        final ShenyuSpringMvcClient beanShenyuClient = AnnotationUtils.findAnnotation(bean.getClass(), ShenyuSpringMvcClient.class);

Review Comment:
   1. lost aop handle
   ```java
           Class<?> clazz = bean.getClass();
           if (AopUtils.isAopProxy(bean)) {
               clazz = AopUtils.getTargetClass(bean);
           }
   ```
   2. should use `AnnotatedElementUtils#findMergedAnnotation`



-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org