collado-mike opened a new pull request, #493: URL: https://github.com/apache/polaris/pull/493
# Description As discussed in the mailing list, this change proposes using the HK2 framework to support CDI-compliant dependency injection using the existing Dropwizard application structure and yaml configuration. This change does not make a logic changes or signature changes except to remove some of the injection-oriented interfaces (e.g., `ConfigurationStoreAware`) and updates constructors to accept dependencies via `@Inject` annotations. The `PolarisApplicationConfig` is configured to be managed by HK2, but populated by the Jackson during the typical Dropwizard configuration parsing. Because the `PolarisApplicationConfig` is managed by HK2, it can invoke a `@PostConstruct` method that registers configured beans with the `serviceLocator` using the config class's own getter methods as `Factory` implementations. Because the other beans are _not_ managed by HK2 (they can't be, since they declare dependencies on other beans that may not yet be instantiated by Jackson), the factory manually calls `inject` on each bean before returning. Jersey has its own `serviceLocator` instance under the hood, so all of the beans bound to the `PolarisApplicationConfig` instance are registered again with the Jersey `serviceLocator` so that they can be found by the jersey components at runtime (I tried using the HK2 bridge that supposedly allows connecting two `serviceLocator`s, but it didn't seem to work and also the licensing on that package suggests possible GPL violation). This also introduces a `@RealmScope` that declares certain dependencies to be created and managed per-realm, rather than per-application or per-request. Some of the instances, such as the `PolarisMetaStoreManager` and the `EntityCache` are intended to be reused across requests, but of course, cannot be reused across realms, as some entities (such as `root` principal and `service_admin` principal role) have the same name across realms. One additional test class is added to ensure that the `@RealmScope`d `EntityCache` is reused across requests, but is not reused across different realms. Fixes # (issue) ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation update - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] PolarisRealmEntityCacheTest **Test Configuration**: * Hardware: * Toolchain: * SDK: # Checklist: Please delete options that are not relevant. - [X] I have performed a self-review of my code - [X] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] If adding new functionality, I have discussed my implementation with the community using the linked GitHub issue -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
