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

ArC: add support for custom AlterableContext implementations #34418

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Jun 29, 2023

Custom contexts in ArC must implement the InjectableContext interface, which is ArC-specific. To implement CDI Lite properly, ArC must also support custom implementations of AlterableContext.

Fortunately, the InjectableContext interface adds just a few methods on top of AlterableContext, and none of them are critical for custom contexts to function. Therefore, with this commit, we simply take the user-supplied implementation of AlterableContext and generate a subclass that implements InjectableContext, where all the additional methods throw UnsupportedOperationException. This subclass is then registered as the custom context, instead of the original user-supplied class.

Resolves #33664

@Ladicek Ladicek added the area/arc Issue related to ARC (dependency injection) label Jun 29, 2023
@Ladicek Ladicek requested review from mkouba and manovotn June 29, 2023 13:24
@quarkus-bot

This comment has been minimized.

@Ladicek Ladicek force-pushed the arc-custom-alterable-contexts branch from 25b1a5f to 4c5fcf5 Compare June 30, 2023 10:19
@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@Ladicek
Copy link
Contributor Author

Ladicek commented Jul 4, 2023

I'll rebase to rerun CI.

Custom contexts in ArC must implement the `InjectableContext`
interface, which is ArC-specific. To implement CDI Lite properly,
ArC must also support custom implementations of `AlterableContext`.

Fortunately, the `InjectableContext` interface adds just a few
methods on top of `AlterableContext`, and none of them are critical
for custom contexts to function. Therefore, with this commit, we
simply take the user-supplied implementation of `AlterableContext`
and generate a subclass that implements `InjectableContext`, where
all the additional methods throw `UnsupportedOperationException`.
This subclass is then registered as the custom context, instead
of the original user-supplied class.
@Ladicek Ladicek force-pushed the arc-custom-alterable-contexts branch from 4c5fcf5 to 8123224 Compare July 4, 2023 11:26
@mkouba mkouba added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 4, 2023
@quarkus-bot

This comment has been minimized.

@quarkus-bot
Copy link

quarkus-bot bot commented Jul 5, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@Ladicek Ladicek merged commit dc0d198 into quarkusio:main Jul 5, 2023
@quarkus-bot quarkus-bot bot added kind/enhancement New feature or request and removed triage/waiting-for-ci Ready to merge when CI successfully finishes labels Jul 5, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 5, 2023
@Ladicek Ladicek deleted the arc-custom-alterable-contexts branch July 7, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support custom CDI contexts implementing AlterableContext
3 participants