CDI: pass through qualifier from one injection point to the other

北城余情 提交于 2020-01-15 06:43:12

问题


I'd like to kind of pass-through a qualifier annotation using CDI. With that I mean that I'd want to add a qualifier to an injection point with that qualifier not being applied directly for the "first-level" injection target (because there is only one implementation for this) but a field within ("2nd level") the injected EJB. Is this possible with CDI? Does it maybe already work out-of-the-box?

It should look similar to:

@Stateless
public class MyFirstLevelEJB {

@Inject
//this guy has different Implementations with qualifiers, I want to use the qualifier here
private CDIBean2ndLevel myCDIBean;

}

2nd EJB:
@Stateless
public class My2ndLevelEJB {

@Inject
@AlternativeImplementation //this is the qualifier which I want to apply for CDIBean2ndLevel
MyFirstLevelEJB anInjectedEBJ; 
}

Any help is greatly appreciated

来源:https://stackoverflow.com/questions/18013305/cdi-pass-through-qualifier-from-one-injection-point-to-the-other

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!