Skip to content
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

3.0 improve reference bean register #7497

Merged
merged 36 commits into from
Apr 30, 2021

Conversation

kylixs
Copy link
Member

@kylixs kylixs commented Apr 1, 2021

What is the purpose of the change

Improve reference bean register, make xml parsing and annotation processing register bean definition in a similar way, solving the problem of reference injection.

Brief changelog

@DubboReference annotation and <dubbo:reference /> xml elements:

  1. The main processing logic of @DubboReference annotation:
  • First, scan all bean definitions, find the field and method annotated by @DubboReference, and register the reference bean definition;
  • Then, inject the reference bean to other beans by matching type and name;
  1. Support using@DubboReference with @Bean in java-config class, and support @Conditional on ReferenceBean
    By post processing AnnotatedBeanDefinition which created by java-config @Configuration class , parsing @DubboReference with @Bean and set reference props to bean definition attribute.

  2. Improve reference bean props populating

  3. Through the reference key, if the attributes of @DubboReference annotation and the <dubbo:reference /> xml bean are the same, they share the same bean definition.

  4. The default value of @DubboReference/@DubboService/@Method/@Argument annotated int type is changed to -1, and the default value of String type is an empty string.
    @DubboReference and @DubboService annotations add scope attribute, @method annotation adds parameters attribute.

Others:

  1. Upgrade Spring version to 5.x
  2. Upgrade dubbo-config-spring unit tests to junit 5
  3. Add tests for issuse Autowired a ReferenceBean failed in some situation in Spring enviroment. #6000 and registry twice consumer service use @DubboReference annotation #7003 , localcall and import xml
    and xml/注解方式定义的消费服务bean如何配合@Conditional相关注解 dubbo-spring-boot-project#779

TODO:

  1. fix dubbo-spring-boot unit tests

Verifying this change

XXXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

guohao and others added 19 commits March 16, 2021 15:27
* Add grpc status to dubbo status convention

* Add triple timeout support
@codecov-io
Copy link

codecov-io commented Apr 1, 2021

Codecov Report

Merging #7497 (0e6eb47) into 3.0 (be54ec2) will increase coverage by 1.18%.
The diff coverage is 73.98%.

Impacted file tree graph

@@             Coverage Diff              @@
##                3.0    #7497      +/-   ##
============================================
+ Coverage     57.61%   58.80%   +1.18%     
- Complexity      371      372       +1     
============================================
  Files          1049     1052       +3     
  Lines         41915    42214     +299     
  Branches       6245     6278      +33     
============================================
+ Hits          24149    24823     +674     
+ Misses        14980    14650     -330     
+ Partials       2786     2741      -45     
Impacted Files Coverage Δ Complexity Δ
.../org/apache/dubbo/config/AbstractMethodConfig.java 100.00% <ø> (ø) 0.00 <0.00> (ø)
...ain/java/org/apache/dubbo/config/MethodConfig.java 98.73% <ø> (ø) 0.00 <0.00> (ø)
...org/apache/dubbo/config/context/ConfigManager.java 78.46% <ø> (+0.47%) 0.00 <0.00> (ø)
.../factory/annotation/ServiceClassPostProcessor.java 84.10% <ø> (+2.64%) 0.00 <0.00> (ø)
.../config/spring/reference/ReferenceBeanBuilder.java 7.07% <7.07%> (ø) 0.00 <0.00> (?)
...nnotation/AbstractAnnotationBeanPostProcessor.java 67.72% <57.57%> (-2.91%) 0.00 <0.00> (ø)
...onfig/spring/schema/DubboBeanDefinitionParser.java 79.77% <83.33%> (+11.71%) 0.00 <0.00> (ø)
.../config/spring/reference/ReferenceBeanManager.java 85.71% <85.71%> (ø) 0.00 <0.00> (?)
...notation/ReferenceAnnotationBeanPostProcessor.java 85.50% <85.89%> (+4.95%) 0.00 <0.00> (ø)
.../org/apache/dubbo/config/spring/ReferenceBean.java 90.66% <87.80%> (+34.66%) 0.00 <0.00> (ø)
... and 100 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be54ec2...0e6eb47. Read the comment docs.

@codecov-commenter
Copy link

codecov-commenter commented Apr 30, 2021

Codecov Report

Merging #7497 (4e01a17) into 3.0 (175d85f) will increase coverage by 1.17%.
The diff coverage is 73.72%.

Impacted file tree graph

@@             Coverage Diff              @@
##                3.0    #7497      +/-   ##
============================================
+ Coverage     57.17%   58.35%   +1.17%     
- Complexity      402      404       +2     
============================================
  Files          1063     1066       +3     
  Lines         42700    43004     +304     
  Branches       6387     6421      +34     
============================================
+ Hits          24413    25094     +681     
+ Misses        15465    15125     -340     
+ Partials       2822     2785      -37     
Impacted Files Coverage Δ Complexity Δ
.../org/apache/dubbo/config/AbstractMethodConfig.java 100.00% <ø> (ø) 0.00 <0.00> (ø)
...ain/java/org/apache/dubbo/config/MethodConfig.java 98.73% <ø> (ø) 0.00 <0.00> (ø)
...a/org/apache/dubbo/config/ReferenceConfigBase.java 69.00% <ø> (+12.00%) 0.00 <0.00> (ø)
...org/apache/dubbo/config/context/ConfigManager.java 78.46% <ø> (+0.47%) 0.00 <0.00> (ø)
.../factory/annotation/ServiceClassPostProcessor.java 84.10% <ø> (+2.64%) 0.00 <0.00> (ø)
.../config/spring/reference/ReferenceBeanBuilder.java 9.09% <9.09%> (ø) 0.00 <0.00> (?)
...nnotation/AbstractAnnotationBeanPostProcessor.java 67.72% <57.57%> (-2.91%) 0.00 <0.00> (ø)
.../org/apache/dubbo/config/spring/ReferenceBean.java 87.50% <79.48%> (+31.50%) 0.00 <0.00> (ø)
...onfig/spring/schema/DubboBeanDefinitionParser.java 79.77% <83.33%> (+11.71%) 0.00 <0.00> (ø)
.../config/spring/reference/ReferenceBeanManager.java 85.71% <85.71%> (ø) 0.00 <0.00> (?)
... and 98 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 175d85f...4e01a17. Read the comment docs.

Copy link
Contributor

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@chickenlj chickenlj merged commit 3a3d0ef into apache:3.0 Apr 30, 2021
@kylixs kylixs deleted the 3.0-improve-reference-bean-register branch October 23, 2021 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants