Java Reference
In-Depth Information
Centralization of security and transaction control management
Testable and mockable pattern implementations 
NOTE You may see this implementation referred to as the POJO façade to
distinguish it from the stateful and stateless implementations that you will see
later in this chapter.
Unlike many other patterns described in this topic, Java EE does not offer a built‐in implementation
of this method. Nevertheless, it is straightforward to implement using stateful or stateless EJB. Using
EJB offers the advantage of easy access to other EJB that the façade might require.
Façade with Stateless Beans
To demonstrate this implementation, assume that you have three EJBs as shown in Listing 3‐2 with
distinct but related functionality: CustomerService , LoanService , and AccountService
LISTING 3‐2: Code for three EJBs that form the subsystem to the façade
package com.devchronicles.facade;
import javax.ejb.Stateless;
public class CustomerService {
public long getCustomer(int sessionID) {
// get logged in customer id
return 100005L;
public boolean checkId(long x) {
// check if customer id is valid
return true;
package com.devchronicles.facade;
import javax.ejb.Stateless;
public class LoanService {
public boolean checkCreditRating(long id, double amount) {
// check if customer is eligible for the amount
return true;
Search WWH ::

Custom Search