2017  Kodetalk | Feedback | Privacy Policy | Terms | About
userimage

what is difference between EJB and CDI?

what is difference between EJB and CDI?
userimage

CDI

  • CDI - it is about dependency injection. It means that you can inject interface implementation anywhere.
  • This object can be anything, it can be not related to EJB and there is nothing about EJB.
  • You are going to use CDI when you want to inject non-EJB services, different implementations or algorithms (so you don't need EJB there at all).

EJB

  • EJB you do understand, and probably you are confused by @EJB annotation - it allows you to inject implementation into your service or whatever.
  • The main idea is that class, where you inject, should be managed by EJB container.
Answer is