Use Design Patterns
Learn and use as many EJB design patterns as possible. Most patterns will save you development time, improve the performance of your application, and make it more maintainable. It’s fair to say that without patterns, writing solid J2EE applications would be very hard.
Because this is not a design patterns book, we will not examine in detail the multitude of EJB patterns that exist out there. Instead, we’ll focus on several patterns that most EJB developers will find useful in their work.
Session façade
A session façade is the most frequently used EJB design pattern. It’s a way to encapsulate business workflow logic to get better performance and to have more maintainable code. The basic idea is very simple: put all business workflow logic into stateless session beans, and have clients call those beans instead of calling the different components of the application. This concept is shown in Figure 2-1.
There are many advantages to this pattern. The most significant is that moving all business logic into its own layer makes the code a lot cleaner and more manageable. Because each workflow operation corresponds to one business method in the session bean, all implementation logic for that operation is executed under one transaction. This means you need to set the transaction attributes for the session bean methods to “Required” for this ...
Get Java Enterprise Best Practices now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.