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

Add support for @Qualifier annotations (as alternative to @Named) #12

Closed
rbygrave opened this issue Nov 27, 2018 · 0 comments
Closed

Add support for @Qualifier annotations (as alternative to @Named) #12

rbygrave opened this issue Nov 27, 2018 · 0 comments
Assignees
Milestone

Comments

@rbygrave
Copy link
Contributor

Create a qualifier annotation. e.g.

@Qualifier
@Retention(RUNTIME)
public @interface Blue {
}

Specify the qualifier annotation rather than @Named on beans and injection targets (constructor parameters, field injection).

@Blue
@Singleton
public class BlueStore implements SomeStore {
...

Constructor injection:

@Singleton
public class StoreManagerWithQualifier {

  private final SomeStore store;

  public StoreManagerWithQualifier(@Blue SomeStore store) {
    this.store = store;
  }

Field injection:

@Singleton
public class StoreManagerWithFieldQualifier {

  @Inject
  @Blue
  SomeStore store;
@rbygrave rbygrave added this to the 0.12 milestone Nov 27, 2018
@rbygrave rbygrave self-assigned this Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant