Search code examples
jakarta-eejava-ee-6cdipojo

Can POJO and CDI beans be instantiated from the same class?


It might be extremely basic... In Java EE 6 enviroment:

Can POJO and CDI beans be instantiated from the same class?

What is the fundamental difference between a CDI bean and a POJO?

Probably this question would be useful to beginneers in Java EE Container Managed applications.


Solution

  • Yes.

    Very basically, a POJO is normally instantiated with new operator, and a CDI bean is instantiated (managed) by the container. So the same class can instantiate both POJOs and CDI beans.