Refactor PolarisConfigurationStore to streamline value typing#3324
Refactor PolarisConfigurationStore to streamline value typing#3324dimas-b wants to merge 2 commits intoapache:mainfrom
Conversation
| * <p>This method is meant to be overridden by concrete configuration store implementations. This | ||
| * method is not meant to be calls by code that needs access to configuration values. | ||
| * Configuration consumers should call typed methods that take a {@link PolarisConfiguration} | ||
| * parameter instead. |
There was a problem hiding this comment.
| * <p>This method is meant to be overridden by concrete configuration store implementations. This | |
| * method is not meant to be calls by code that needs access to configuration values. | |
| * Configuration consumers should call typed methods that take a {@link PolarisConfiguration} | |
| * parameter instead. | |
| * <p>This method is meant to be overridden by concrete configuration store implementations. | |
| * Prefer the typed functions that take a {@link PolarisConfiguration} parameter instead of a {@code String}. |
There was a problem hiding this comment.
I reformatted the javadoc, hoping to emphasize the need to use typed methods.
TBH, I'm not sure whether the "prefer" suggestion is targeting callers or implementors 🤔 WDYT?
* Avoid generic return types when the value type is not certain * Add new method to be overridden by implementation that returns `Object` to avoid arbitrary casts to `T` * Type casts are performed only when the expected value type is known. * This change is backward-compatible with older implementations of `PolarisConfigurationStore`
53dc814 to
a71fbcb
Compare
| /** | ||
| * Retrieve the current value for a configuration key for a given realm. May be null if not set. | ||
| * | ||
| * <p>This method is meant to be overridden by concrete configuration store implementations. |
There was a problem hiding this comment.
Actually, I wonder whether this function and the getConfiguration functions should have a default implementation at all. Wouldn't it be cleaner to move that to the actual implementation? Mean, this interface isn't really an interface but rather a not-really abstract class.
There was a problem hiding this comment.
Good point. I've been thinking about splitting this into an API/SPI pair too, but I thought it might be too intrusive... Let me actually try that refactoring and see what's impacted.
* Improve code isolation by using `RealmConfig` (like most other code) instead of the lower-level `PolarisConfigurationStore` * This also enabled proper CDI request-scoped injection in concert with apache#3411 * Additionally, this enables further code cleanup in `PolarisConfigurationStore` as discussed in apache#3324 with the goal of using this interface for the backend configuration code, while `RealmConfig` becomes the corresponding frontend interface. * Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from its dependencies (not from `CallContext`) to avoid cycles in CDI.
* Improve code isolation by using `RealmConfig` (like most other code) instead of the lower-level `PolarisConfigurationStore` * This also enabled proper CDI request-scoped injection in concert with apache#3411 * Additionally, this enables further code cleanup in `PolarisConfigurationStore` as discussed in apache#3324 with the goal of using this interface for the backend configuration code, while `RealmConfig` becomes the corresponding frontend interface. * Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from its dependencies (not from `CallContext`) to avoid cycles in CDI.
* Improve code isolation by using `RealmConfig` (like most other code) instead of the lower-level `PolarisConfigurationStore` * This also enabled proper CDI request-scoped injection in concert with apache#3411 * Additionally, this enables further code cleanup in `PolarisConfigurationStore` as discussed in apache#3324 with the goal of using this interface for the backend configuration code, while `RealmConfig` becomes the corresponding frontend interface. * Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from its dependencies (not from `CallContext`) to avoid cycles in CDI.
* Use injected RealmConfig in JdbcMetaStoreManagerFactory * Improve code isolation by using `RealmConfig` (like most other code) instead of the lower-level `PolarisConfigurationStore` * This also enabled proper CDI request-scoped injection in concert with #3411 * Additionally, this enables further code cleanup in `PolarisConfigurationStore` as discussed in #3324 with the goal of using this interface for the backend configuration code, while `RealmConfig` becomes the corresponding frontend interface. * Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from its dependencies (not from `CallContext`) to avoid cycles in CDI.
* Use injected RealmConfig in JdbcMetaStoreManagerFactory * Improve code isolation by using `RealmConfig` (like most other code) instead of the lower-level `PolarisConfigurationStore` * This also enabled proper CDI request-scoped injection in concert with apache#3411 * Additionally, this enables further code cleanup in `PolarisConfigurationStore` as discussed in apache#3324 with the goal of using this interface for the backend configuration code, while `RealmConfig` becomes the corresponding frontend interface. * Fix `ServiceProducers.realmConfig()` to make a `RealmConfigImpl` directly from its dependencies (not from `CallContext`) to avoid cycles in CDI.
|
Closing in favour of #3573 |
Avoid generic return types when the value type is not certain
Add new method to be overridden by implementation that returns
Objectto avoid arbitrary casts toTType casts are performed only when the expected value type is known.
This change is backward-compatible with older implementations of
PolarisConfigurationStoreChecklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)