I have an custom qualifier annotation
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface MyQualifier {
MyQualiferEnum value();
}
And some beans
@Component
@Scope("prototype")
@MyQualifier(MyQualifierEnum.BLACK)
public class BlackBean {
@Component
@Scope("prototype")
@MyQualifier(MyQualifierEnum.WHITE)
public class WhiteBean {
I try @Lookup but it rely on bean name or class and I can't pass annotation and it attributes to lookup-method
Then I try
context.getgetBeansWithAnnotation(MyQualifier.class)
but it leads to all @MyQualifier beans instantiated that worse for me.
I can't introduce @MyQualifierBlack, @MyQualiferWhite etc separate annotations, I exactly need enum so how I can inject that prototype beans depends on MyQualifierEnum value, for example MyQualifierEnum.BLACK, at runtime without unnecessary initialization of other @MyQualifier annotated beans?