Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJB as controller

Tags:

java

ejb

When developing a Java EE application, it is possible to use EJBs as controllers?

The EJB container provides features such as lifecycle management, and concurrency control, Is it correct create a stateless EJB to be a controller and injects it into a ManagedBean?

like image 744
Lucas Merencia Avatar asked Nov 03 '22 19:11

Lucas Merencia


1 Answers

From EJB 3.0 and specially in 3.1, the EJB Beans become more and more POJOs thus the EJB concept blurs in favor of the more generic Managed Bean concept, inside the CDI. Even the @EJB annotation "competes" with @Inject and could eventually be replaced by it.

So in CDI, a controller can be a managed bean and take advantage of the Java EE server features like lifecycle management and such.

like image 50
magarciaschopohl Avatar answered Nov 08 '22 13:11

magarciaschopohl