-
1. Re: applying custom binding types
gonorrhea May 30, 2009 5:34 PM (in response to gonorrhea)I think I realized the answer. Binding types are (at least part of) the solution for loose typing in Web Beans.
This approach seems to be similar to the best practice used in Spring to design to interfaces so you can switch out the implementation class without breaking your client code.
So in this context of JCDI/Web Beans, if the implementation class changes, then you simply change the annotation (binding type) and then nothing is broken in your client code. Like using java.util.List and then switching from ArrayList to LinkedList but an annotation is now required.
Correct?
-
2. Re: applying custom binding types
gavin.king May 30, 2009 8:03 PM (in response to gonorrhea)Well, not exactly. If I was going to change the binding type every time I changed the implementation of the interface, I might as well just use the concrete class at the injection point. Nothing's gained by using an annotation instead.
No, the real use case is if I have multiple beans with the same type, for example @UserDatabase EntityManager, @ProductDatabase EntityManager, etc.
For the case where you are trying to achieve polymorphism, you are supposed to use deployment types, or producer methods.