문제

I have several components which are application scoped. Depending on which environment I am in, I want to install one or the other. In JBoss Seam, I would use @Install(false), then configure the bean that I wanted through components.xml.

Is there a similar method for doing this in CDI / WELD?

Thanks,

Walter

도움이 되었습니까?

해결책

Well, you can always use a producer method and decide which implementation to instantiate based on some configuration of yours. Remember that in CDI the amount of xml is put to minimum.

So, something like:

@Produces
public Component createComponent() {
   if (configuration.isSomething()) {
       return new ComponentImpl1();
   } else {
       return new ComponentImpl2();
   }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top