kapua icon indicating copy to clipboard operation
kapua copied to clipboard

Replacing manual jaxb configuration with class path scan and dependency injection

Open dseurotech opened this issue 3 years ago • 1 comments

Implements single point of JAXB configuration through package scan and proper dependency injection.

Related Issue This PR fixes/closes #3426

Description of the solution adopted First of all, the two concerns of creating the creating the JAXB Context and identifying the classes needed have been separated in two different classes: JAXBContextProviderImpl and XmlSerializableClassesProvider respectively. JAXBContextProviderImpl actually accepts a generic list of ClassProvider implementations in order to allow for test cases and/or future expansions (allowing modules to specify their own list of classes to be serialized).

XmlSerializableClassesProvider performs class path scan, looking for all instances of classes declaring the XmlRootElement annotation. The class is initialized with a list of valid packages to scan, and a list of packages to exclude. This is used in conjunction with the guice implementation of the kapua locator, passing the same set of packages declared in the locator.xml (see GuiceLocatorImpl)

Any side note on the changes made This PR includes a number of fixes to issues that emerged during development - some serializable classes had invalid annotations (e.g.: order of field serialization including invalid fields, deserialization instructions referencing non-existing class methods, etc.)

dseurotech avatar Dec 29 '22 11:12 dseurotech

Codecov Report

Merging #3686 (9cdbca1) into develop (20844cd) will decrease coverage by 17.55%. The diff coverage is 54.43%.

:exclamation: Current head 9cdbca1 differs from pull request most recent head 115a5f2. Consider uploading reports for the commit 115a5f2 to get more accurate results

Impacted file tree graph

@@              Coverage Diff               @@
##             develop    #3686       +/-   ##
==============================================
- Coverage      55.82%   38.28%   -17.55%     
==============================================
  Files           1829     1830        +1     
  Lines          34006    33968       -38     
  Branches        2717     2700       -17     
==============================================
- Hits           18985    13003     -5982     
- Misses         14026    20067     +6041     
+ Partials         995      898       -97     
Impacted Files Coverage Δ
...apua/broker/core/BrokerJAXBContextInitializer.java 0.00% <0.00%> (ø)
...se/kapua/broker/core/setting/BrokerSettingKey.java 0.00% <0.00%> (-100.00%) :arrow_down:
...kapua/commons/configuration/ServiceConfigImpl.java 73.33% <ø> (ø)
...er/commons/xml/ConsumerJAXBContextInitializer.java 0.00% <0.00%> (ø)
...ne/client/queue/QueuedJobExecutionCreatorImpl.java 0.00% <0.00%> (ø)
...ob/engine/client/queue/QueuedJobExecutionImpl.java 0.00% <0.00%> (ø)
...client/queue/QueuedJobExecutionListResultImpl.java 0.00% <0.00%> (ø)
...gine/client/queue/QueuedJobExecutionQueryImpl.java 0.00% <0.00%> (ø)
...eclipse/kapua/app/api/web/JaxbContextResolver.java 0.00% <0.00%> (-77.78%) :arrow_down:
...eclipse/kapua/app/api/web/RestApisApplication.java 0.00% <ø> (-62.97%) :arrow_down:
... and 504 more

codecov[bot] avatar Dec 29 '22 11:12 codecov[bot]