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

Allow components to ask for dependencies with specific scopes (Bugzilla Bug 386431) #3

Open
mcculls opened this issue Oct 25, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@mcculls
Copy link
Contributor

mcculls commented Oct 25, 2021

This issue was created automatically with bugzilla2github

Bugzilla Bug 386431

Date: 2012-08-01 18:34:59 -0400
From: Stuart McCulloch <[email protected]>
To: Project Inbox <[email protected]>

See also: https://issues.sonatype.org/browse/SISU-3
Last updated: 2013-07-16 21:17:03 -0400

Comment 2144108

Date: 2012-08-01 18:34:59 -0400
From: Stuart McCulloch <[email protected]>

Migrated from https://issues.sonatype.org/browse/SISU-3

The auto-wiring code adds bindings for implicit (non-local) injected dependencies by introspecting injection sites and using that information to generate bindings at runtime. At the moment it assumes such bindings are unscoped, but some components might want to inject a dependency using a specific scope (such as per-request or per-session).

Changing the dependency analyzer to look for scope annotations on the injection site is trivial, the main issue is that a lot of scope annotations (such as the existing Guice ones) can only be placed on types, not individual members - one solution would be to mark the component itself with the scope, and then apply that to any of its dependencies. Another thing to watch out for is when the same dependency is used in conflicting scopes. This is of particular concern when you want to scope a configuration value where the raw type is not under your control and value is used in many places.

In fact the best solution might actually be to solve this use-case another way and avoid auto-wiring scoped bindings. For example, currently users can inject Providers to get per-lookup instances and then manage the values themselves.

@mcculls mcculls added the enhancement New feature or request label Oct 25, 2021
cstamas added a commit that referenced this issue May 17, 2024
Was 1.0.7 here vs 1.1.11 in sisu.inject, went with higher.
cstamas pushed a commit that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant