The purpose of CDI technology in Java EE and its relation to user interface technologies such as JSF and back end technologies such as EJB

This question directly follows from another question here . The last paragraph of the answer to this question mentions CDI technology.

Can you explain what the purpose of this technology is. Is there a connection between this technology and JSF and EJB? I went through the question , but I still do not understand what the purpose of this technology is. I specifically want to know where it is suitable for other Java EE technologies such as EJB and JSF.

+4
source share
2 answers

Addendum to the correct answer of Bojo:

CDI is a superset of JSF managed beans, and JSF will ultimately condemn its own managed beans. In JSF, steps have already been taken for this.

CDI is not a superset of EJB beans, but they complement each other. CDI not only provides a more advanced DI in EJB beans, but it is also able to provide an EJB beans scope (mainly used for beans state). EJB in turn provides transaction and security services among others that CDI does not offer. Like JSF beans, EJB beans will eventually be integrated with the CDI component model. Marina Vatkina (EJB spec lead), among others , hinted at this.

Further reading:

+7
source

First, CDI provides a standard framework for dependency injection. It determines how objects get their dependencies, not by creating an instance ( private FooDao dao = new FooDao() ), but through a container that creates and manages the instances. You can learn more about dependency injection (google / wiki).

The standard defines how this works with both JSF and EJB.

  • your managed JSF beans can be defined using CDI so that you can deploy services to managed beans, and so CDI manages the life cycle of a managed JSF beans
  • An EJB can also benefit from an extended injection of CDI dependencies (they previously had their own, different from DI functionality).

In short, CDI binds all the components in JavaEE in the spring way with all its components, but CDI is the standard.

+3
source

All Articles