Java Reference
In-Depth Information
• Product maintenance (create, edit, update, delete)
• Category maintenance (create, edit, update, delete)
• Customer maintenance (create, edit, update, delete)
• Group maintenance (create, edit, update, delete)
The project also uses stateless session beans as façades for interactions with the JPA entit-
trollers for interactions with Facelets pages. The project thus follows the MVC (Model-
View-Controller) pattern and applies the same pattern to all entities and pages, as in the
following example:
•
AbstractFacade
is an abstract class that receives a
Type<T>
and implements
the common operations (CRUD) for this type, where
<T>
is a JPA entity.
•
ProductBean
is a stateless session bean that extends
AbstractFacade
, ap-
plying
Product
as
Type<T>
, and injects the
PersistenceContext
for the
Entity Manager. This bean implements any custom methods needed to interact
with the
Product
entity or to call a custom query.
•
ProductController
is a CDI managed bean that interacts with the necessary
enterprise beans and Facelets pages to control the way the data will be displayed.
ProductBean
begins as follows:
@Stateless
public class ProductBean extends AbstractFacade<Product> {
private static final Logger logger =
Logger.getLogger(ProductBean.class.getCanonicalName());
@PersistenceContext(unitName="forestPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
...
Enterprise Beans Used in Duke's Store
The enterprise beans used in Duke's Store provide the business logic for the application
and are located in the
com.forest.ejb
package. All are stateless session beans.