Skip to content

Commit

Permalink
[ISSUE #198] support spring @AliasFor extend
Browse files Browse the repository at this point in the history
  • Loading branch information
loongs-zhang committed Sep 3, 2022
1 parent 7550e16 commit 7df7bd7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.qq.tars.spring.annotation.TarsServant;
import org.springframework.aop.framework.Advised;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.AnnotatedElementUtils;

import java.util.Map;

Expand Down Expand Up @@ -93,7 +93,7 @@ private ServantHomeSkeleton loadServant(Object bean) throws Exception {

ServerConfig serverCfg = ConfigurationManager.getInstance().getServerConfig();

homeName = AnnotationUtils.getAnnotation(bean.getClass(), TarsServant.class).name();
homeName = AnnotatedElementUtils.findMergedAnnotation(bean.getClass(), TarsServant.class).name();
if (StringUtils.isEmpty(homeName)) {
throw new RuntimeException("servant name is null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.qq.tars.spring.annotation.TarsClient;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;
Expand All @@ -51,7 +51,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw

private void processFields(Object bean, Field[] declaredFields) {
for (Field field : declaredFields) {
TarsClient annotation = AnnotationUtils.getAnnotation(field, TarsClient.class);
TarsClient annotation = AnnotatedElementUtils.findMergedAnnotation(field, TarsClient.class);
if (annotation == null) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.core.annotation.AnnotatedElementUtils;

import java.io.IOException;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -152,7 +153,7 @@ private ServantHomeSkeleton loadServant(Object bean) throws Exception {

ServerConfig serverCfg = ConfigurationManager.getInstance().getServerConfig();

homeName = bean.getClass().getAnnotation(TarsServant.class).name();
homeName = AnnotatedElementUtils.findMergedAnnotation(bean.getClass(), TarsServant.class).name();
if (StringUtils.isEmpty(homeName)) {
throw new RuntimeException("servant name is null.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -75,7 +75,7 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw

private void processFields(Object bean, Field[] declaredFields) {
for (Field field : declaredFields) {
TarsClient annotation = AnnotationUtils.getAnnotation(field, TarsClient.class);
TarsClient annotation = AnnotatedElementUtils.findMergedAnnotation(field, TarsClient.class);
if (annotation == null) {
continue;
}
Expand Down

0 comments on commit 7df7bd7

Please sign in to comment.