-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support placeholder in SofaService and SofaReference annotation. #264
Conversation
这个竟然是用代理去实现的,又学到了新姿势!一直以为注解类是final不能代理,直到看到了基于annotation类内聚做代理的,艺术艺术。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
SofaService sofaServiceAnnotation = beanClass.getAnnotation(SofaService.class); | ||
AnnotationWrapperBuilder<SofaService> builder = AnnotationWrapperBuilder.wrap( | ||
beanClass.getAnnotation(SofaService.class)).withBinder(binder); | ||
SofaService sofaServiceAnnotation = builder.build(); | ||
|
||
if (sofaServiceAnnotation == null) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this we should first check whether sofaServiceAnnotation is null ,then wrap it , otherwise there will be many temp AnnotationWrapperBuilder
objects since ServiceAnnotationBeanPostProcessor
is a BeanPostProcessor
which will work on many beans and only a very small part of them are annotated with @SofaService
. At the same time, we can assert delegate not null on AnnotationWrapperBuilder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good advice.
AnnotationWrapperBuilder<SofaReference> builder = AnnotationWrapperBuilder.wrap( | ||
field.getAnnotation(SofaReference.class)).withBinder(binder); | ||
SofaReference sofaReferenceAnnotation = builder.build(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above suggested.
* @since 2.5.2 | ||
*/ | ||
public interface PlaceHolderBinder { | ||
String bind(String string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comment for this interface and method. And should we provide a default Implement? I see a lot of duplicate implements below.
…astack#264) * support placeholder in SofaService and SofaReference annotation
… (#282) * support placeholder in SofaService and SofaReference annotation
#260