concept JSF in category ejb

appears as: JSF
EJB 3 in Action, Second Edition

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.

Application servers are where EJBs have been traditionally deployed. Application servers are Java EE containers that include support for all Java EE APIs, as well as facilities for administration, deployment, monitoring, clustering, load balancing, security, and so on. In addition to supporting Java EE-related technologies, some application servers can also function as production-quality HTTP servers. Others support modularity via technologies like OSGi. As of Java EE 6, application servers can also come in a scaled-down, lightweight Web Profile form. The Web Profile is a smaller subset of Java EE APIs specifically geared toward web applications. Web Profile APIs include JSF 2.2, CDI 1.1, EJB 3.2 Lite (discussed in section 1.4.2), JPA 2.1, JTA 1.2, and bean validation. At the time of writing, GlassFish and Resin provided Java EE 7 Web Profile offerings. Note that Java EE 7 Web Profile implementations are free to add APIs as they wish. For example, Resin adds JMS, as well as most of the EJB API including messaging, remoting, and scheduling (but not EJB 2 backward compatibility). Figure 1.4 shows how the Web Profile compares with the complete Java EE platform.

Figure 1.4. Java EE Web Profile versus full Java EE platform

The Web Profile defines a complete stack on which to build a modern web application. Web applications are now rarely written from the ground up using raw Servlets, but instead sit on top of JSF and make use of the various EE technologies.

Figure 2.2. The ActionBazaar scenario implemented using EJB 3. From the EJB 3 perspective, the presentation layer is an amorphous blob that generates business logic–tier requests (in this case it’s implemented using JSF). The business logic–tier components match up with the distinct processes in the scenario—putting a bid on an item and ordering the item won. The business logic–tier components use JPA entities to persist the application state into the database via persistence-layer DAO components.

2.3.1. Using CDI with JSF 2 and EJB 3

To see how CDI can be used as the superglue between JSF and EJB 3, let’s get back to the BidService stateless session bean example. Recall that BidService allows you to save bids into the database. Clearly, the addBid functionality would likely be used on a page that allows the bidder to place a bid on an item. If you’re familiar with auction sites, this page could look something like figure 2.4.