eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

Jaxb autodiscovery #4048

Closed dseurotech closed 2 months ago

dseurotech commented 2 months ago

Enable autoscan for classes to be fed to the JaxbContext within the application namespaces

Related Issue This PR fixes/closes 1770 and fixes/closes 3426

Description of the solution adopted This PR actually introduces a basic jaxb provider (JAXBContextProviderImpl) which collects (via constructor injection and the use of Guice's Multibindings) classes coming from any number of _JaxbClassProvider_s. Two instances of such Class Providers are supplied:

  1. SimpleJaxbClassProvider to reference individual classes. Use this to signal module-specific classes that might escape the autoscanning provided by the other implementation
  2. XmlRootAnnotatedJaxbClassesScanner to scan via reflection across all of locator's namespaces for classes annotated with XmlRootElement.

Any side note on the changes made Side changes are the promotion of LocatorConfig to api level as a data-container class, while its creation (specifically, xml parsing) has been singled out and moved in a more appropriate class. While refactoring this, any residue of the incomplete and unused feature of locator providers has been eliminated. Notice that autoscan is supplied as an alternative mechanism to providing Jaxb configuration the old way, so this pr should not be breaking. In all project leaf modules the original JaxbProviders has been kept, even if in a deprecated state, in order to provide easier debugging in case of emerging issues.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 85.55556% with 26 lines in your changes missing coverage. Please review.

Project coverage is 16.78%. Comparing base (20a640d) to head (9da5667). Report is 11 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4048/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4048 +/- ## ============================================= + Coverage 16.66% 16.78% +0.12% Complexity 22 22 ============================================= Files 2009 2006 -3 Lines 52161 52087 -74 Branches 4409 4383 -26 ============================================= + Hits 8691 8745 +54 + Misses 43068 42947 -121 + Partials 402 395 -7 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4048?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [...mmons/rest/model/IsJobRunningMultipleResponse.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons-rest%2Fmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Frest%2Fmodel%2FIsJobRunningMultipleResponse.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy1yZXN0L21vZGVsL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY29tbW9ucy9yZXN0L21vZGVsL0lzSm9iUnVubmluZ011bHRpcGxlUmVzcG9uc2UuamF2YQ==) | `0.00% <ø> (ø)` | | | [...kapua/commons/rest/model/IsJobRunningResponse.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons-rest%2Fmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Frest%2Fmodel%2FIsJobRunningResponse.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy1yZXN0L21vZGVsL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY29tbW9ucy9yZXN0L21vZGVsL0lzSm9iUnVubmluZ1Jlc3BvbnNlLmphdmE=) | `0.00% <ø> (ø)` | | | [...kapua/commons/rest/model/MultipleJobIdRequest.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons-rest%2Fmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Frest%2Fmodel%2FMultipleJobIdRequest.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy1yZXN0L21vZGVsL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY29tbW9ucy9yZXN0L21vZGVsL011bHRpcGxlSm9iSWRSZXF1ZXN0LmphdmE=) | `0.00% <ø> (ø)` | | | [.../java/org/eclipse/kapua/commons/CommonsModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2FCommonsModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvQ29tbW9uc01vZHVsZS5qYXZh) | `77.27% <100.00%> (+3.58%)` | :arrow_up: | | [...kapua/commons/configuration/ServiceConfigImpl.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fconfiguration%2FServiceConfigImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvY29uZmlndXJhdGlvbi9TZXJ2aWNlQ29uZmlnSW1wbC5qYXZh) | `73.33% <ø> (ø)` | | | [...e/kapua/commons/util/log/ConfigurationPrinter.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Futil%2Flog%2FConfigurationPrinter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvdXRpbC9sb2cvQ29uZmlndXJhdGlvblByaW50ZXIuamF2YQ==) | `98.27% <100.00%> (+0.33%)` | :arrow_up: | | [.../eclipse/kapua/locator/guice/GuiceLocatorImpl.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=locator%2Fguice%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Flocator%2Fguice%2FGuiceLocatorImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-bG9jYXRvci9ndWljZS9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2xvY2F0b3IvZ3VpY2UvR3VpY2VMb2NhdG9ySW1wbC5qYXZh) | `85.95% <100.00%> (+19.80%)` | :arrow_up: | | [.../eclipse/kapua/message/internal/MessageModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=message%2Finternal%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fmessage%2Finternal%2FMessageModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-bWVzc2FnZS9pbnRlcm5hbC9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL21lc3NhZ2UvaW50ZXJuYWwvTWVzc2FnZU1vZHVsZS5qYXZh) | `100.00% <100.00%> (ø)` | | | [.../java/org/eclipse/kapua/app/api/web/AppModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=rest-api%2Fweb%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fapp%2Fapi%2Fweb%2FAppModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-cmVzdC1hcGkvd2ViL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYXBwL2FwaS93ZWIvQXBwTW9kdWxlLmphdmE=) | `90.00% <100.00%> (+2.50%)` | :arrow_up: | | [.../kapua/app/api/web/RestApiJAXBContextProvider.java](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree&filepath=rest-api%2Fweb%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fapp%2Fapi%2Fweb%2FRestApiJAXBContextProvider.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-cmVzdC1hcGkvd2ViL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYXBwL2FwaS93ZWIvUmVzdEFwaUpBWEJDb250ZXh0UHJvdmlkZXIuamF2YQ==) | `0.00% <ø> (-80.00%)` | :arrow_down: | | ... and [14 more](https://app.codecov.io/gh/eclipse/kapua/pull/4048?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | | ... and [15 files with indirect coverage changes](https://app.codecov.io/gh/eclipse/kapua/pull/4048/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)