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

Refactorings/repository pattern #3726

Merged

Conversation

dseurotech
Copy link
Contributor

@dseurotech dseurotech commented Feb 27, 2023

This PR replaces the static DAOs in favour of injectable Repositories, and introduces transaction management within services.

Related Issue
This PR expands upon (and includes) #3705

Description of the solution adopted
PR3726 - DAOs to Repositories Presentation.pdf

Usage of static DAOS has been replaced by injectable Repositories (see org.eclipse.kapua.storage.KapuaEntityRepository and subclasses), with proper transaction management (TxManager class), and more flexible cache management with the KapuaEntityRepositoryCachingWrapper and subclasses.

Any side note on the changes made
The changes in this PR affect indirectly the generation of events (now explicit, as per slides) and the wiring of ServiceModules (that now need to be explicitly declared in the module's wiring)

Deprecations

  • org.eclipse.kapua.commons.service.internal.ServiceDAO and all classes extending/using it, e.g.: ServiceConfigDAO, in favour of org.eclipse.kapua.storage.KapuaEntityRepository and subclasses
  • org.eclipse.kapua.commons.core.ServiceModuleConfiguration and ServiceModuleProvider, in favour of directly binding ServiceModule classes in guice's wiring
  • org.eclipse.kapua.commons.event.ServiceEventModule class hierarchy, in favour of org.eclipse.kapua.commons.event.ServiceEventTransactionalModule
  • Old persistence logic in package org.eclipse.kapua.commons.jpa.*, in favour of org.eclipse.kapua.storage.TxManager and related classes:
    • EntityManager
    • EntityManagerCallback
    • EntityManagerContainer
    • EntityManagerFactory
    • EntityManagerSession
    • EntityManagerVoidCallback
    • TransactionManager
    • TransactionManagerNotTransacted
    • TransactionManagerTransacted
  • org.eclipse.kapua.service.device.management.commons.AbstractDeviceManagementServiceImpl in favour of AbstractDeviceManagementTransactionalServiceImpl in the same package

@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Merging #3726 (58d6e14) into develop (d763e11) will decrease coverage by 0.20%.
The diff coverage is 17.14%.

❗ Current head 58d6e14 differs from pull request most recent head 705ca1d. Consider uploading reports for the commit 705ca1d to get more accurate results

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3726      +/-   ##
=============================================
- Coverage      20.61%   20.42%   -0.20%     
  Complexity         6        6              
=============================================
  Files           1902     1935      +33     
  Lines          40721    41503     +782     
  Branches        3878     3946      +68     
=============================================
+ Hits            8395     8476      +81     
- Misses         31914    32630     +716     
+ Partials         412      397      -15     
Files Changed Coverage Δ
...stractKapuaConfigurableResourceLimitedService.java 0.00% <0.00%> (ø)
...onfiguration/AbstractKapuaConfigurableService.java 0.00% <0.00%> (ø)
...uration/AbstractKapuaConfigurableServiceCache.java 100.00% <ø> (ø)
...iguration/KapuaConfigurableServiceSchemaUtils.java 72.00% <ø> (ø)
.../kapua/commons/configuration/ServiceConfigDAO.java 0.00% <ø> (ø)
...ons/configuration/ServiceConfigurationManager.java 0.00% <ø> (ø)
...ion/ServiceConfigurationManagerCachingWrapper.java 26.08% <0.00%> (ø)
...kapua/commons/core/ServiceModuleConfiguration.java 0.00% <ø> (-66.67%) ⬇️
.../kapua/commons/core/ServiceModuleProviderImpl.java 0.00% <ø> (ø)
...a/org/eclipse/kapua/commons/crypto/CryptoUtil.java 75.40% <ø> (ø)
... and 73 more

... and 254 files with indirect coverage changes

@dseurotech dseurotech force-pushed the refactorings/repositoryPattern branch 11 times, most recently from 372050b to a66006b Compare March 8, 2023 16:44
@dseurotech dseurotech force-pushed the refactorings/repositoryPattern branch 7 times, most recently from b163215 to 003cc3d Compare March 16, 2023 13:29
@dseurotech dseurotech force-pushed the refactorings/repositoryPattern branch 11 times, most recently from eef1f14 to 2b469fb Compare March 27, 2023 07:41
…ity methods where possible instead of reinventing the wheel

Signed-off-by: dseurotech <[email protected]>
Signed-off-by: dseurotech <[email protected]>
Signed-off-by: dseurotech <[email protected]>
Signed-off-by: dseurotech <[email protected]>
Signed-off-by: dseurotech <[email protected]>
…verriding delete and override methods a million times

Signed-off-by: dseurotech <[email protected]>
…the old event system without reworking it completely

Signed-off-by: dseurotech <[email protected]>
…to hook the old event system without reworking it completely"

This reverts commit b960501.
Signed-off-by: dseurotech <[email protected]>
…y;ManagerFactory every time)

Signed-off-by: dseurotech <[email protected]>
@dseurotech dseurotech force-pushed the refactorings/repositoryPattern branch from cf1f199 to 705ca1d Compare August 7, 2023 09:48
@riccardomodanese riccardomodanese merged commit 06977cc into eclipse:develop Aug 8, 2023
29 of 30 checks passed
@dseurotech dseurotech deleted the refactorings/repositoryPattern branch August 8, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CQ pending This PR needs a CQ to be approved from Eclipse before merging. Enhancement This PR/Issue improves an part of Kapua
Projects
Development

Successfully merging this pull request may close these issues.

3 participants