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: improve support for active/inactive beans #43765

Closed
2 tasks done
Ladicek opened this issue Oct 8, 2024 · 4 comments
Closed
2 tasks done

ArC: improve support for active/inactive beans #43765

Ladicek opened this issue Oct 8, 2024 · 4 comments
Labels
area/arc Issue related to ARC (dependency injection) kind/enhancement New feature or request

Comments

@Ladicek
Copy link
Contributor

Ladicek commented Oct 8, 2024

Description

We now have initial support for active/inactive beans in ArC, see #41810. Here are some ideas that would make that better:

We could add an @Active qualifier to inject only active beans into a List, similarly to @All. Alternatively, we could add something like this to InjectableInstance:

default List<T> listActive() {
    return handlesStream().filter(h -> h.getBean().isActive()).map(InstanceHandle::get).toList();
}

We might need to add the ability to use an exception as a cause of an inactive bean (in ActiveResult).

We might want to modify Instance.isUnsatisfied()/isAmbiguous() to remove inactive beans. There was also an idea to make inactive beans suppressed, but we cannot do that, because we sometimes need to access metadata of inactive beans through Instance (notably, to decide if some other bean is active or inactive, and use their ActiveResult as a cause). Perhaps this reason also precludes the modification of isUnsatisfied()/isAmbiguous(), need to think more about it.

We should add active/inactive support to ArC dev UI.

Not sure if there's more.

Implementation ideas

No response

@Ladicek Ladicek added the kind/enhancement New feature or request label Oct 8, 2024
@quarkus-bot quarkus-bot bot added the area/arc Issue related to ARC (dependency injection) label Oct 8, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 8, 2024

/cc @manovotn (arc), @mkouba (arc)

@Ladicek
Copy link
Contributor Author

Ladicek commented Oct 8, 2024

Also CC @yrodiere

@manovotn
Copy link
Contributor

manovotn commented Oct 8, 2024

Not sure if there's more.

@Ladicek we could also modify Dev UI to mark beans that are possibly inactive in your app.

@Ladicek
Copy link
Contributor Author

Ladicek commented Oct 14, 2024

I actually think we shouldn't modify InjectableInstance.isUnsatisfied()/isAmbiguous(), because that would make the result of these methods inconsistent with the behavior of get()/iterator()/etc.

This means the only unfinished thing from the list is supporting an exception as an ActiveResult cause, but that's not a terribly big deal. And perhaps some more user-friendly way of obtaining only active beans, but we need more feedback to actually consider something.

Therefore, closing this as done.

@Ladicek Ladicek closed this as completed Oct 14, 2024
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

No branches or pull requests

2 participants