This question directly follows from another question of mine here. The last paragraph of the answer to that question mentions CDI
technology.
Can you explain what is the purpose of that technology. Is there any relation of that technology with JSF and EJB? I have been through this question but I'm not clear on what is the purpose of that technology yet. I specifically want to know where it fits with other Java EE technologies like EJB and JSF.
Adding to the correct answer of Bozho:
CDI is a superset of JSF's managed beans, and JSF will eventually deprecate their own native managed bean system. In JSF 2.2 steps have already been taken for this.
CDI is not a superset of EJB beans, but they complement each other. CDI does not only provide more advanced DI to EJB beans, but is also capable of giving EJB beans a scope (mostly used for stateful beans). EJB on its turn provides transactional and security services among others , which CDI does not offer. Like JSF managed beans, EJB beans will eventually be merged into the CDI component model. Marina Vatkina (EJB spec lead) among others has strongly hinted at this.
Further reading:
First, CDI is a dependency-injection standard framework. It defines ways for objects to obtain their dependencies not through instantiation (private FooDao dao = new FooDao()
) but via a container which creates and manages instances. You can read more about dependency injection (google/wiki).
The standard defines how that works with both JSF and EJB.
In short, CDI binds all components in JavaEE in a way spring does with all of its components, but CDI is a standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With