Java Reference
In-Depth Information
the business logic's implementation details it can prevent changes to it affecting the
presentation tier. The downside is that you must typically write more code to encap-
sulate the business logic.
You must also address other important issues, such as how to handle transac-
tions, security, and remoting, since they are generally the responsibility of the
business logic's interface code. The business tier's interface typically ensures that
each call to the business tier executes in a transaction in order to preserve the
consistency of the database. Similarly, it also verifies that the caller is authorized to
invoke a business method. The business tier's interface is also responsible for han-
dling some kinds of remote clients.
Let's consider the options.
2.3.1
EJB session facade
The classic- J2EE approach is to encapsulate business logic with an EJB-based ses-
sion façade. The EJB container provides transaction management, security, distrib-
uted transactions, and remote access. The façade also improves maintainability by
encapsulating the business logic. The coarse-grained API can also improve perfor-
mance by minimizing the number of calls that the presentation tier must make to
the business tier. Fewer calls to the business tier reduce the number of database
transactions and increase the opportunity to cache objects in memory. It also
reduces the number of network round-trips if the presentation tier is accessing the
business tier remotely. Figure 2.4 shows an example of an EJB -based session façade.
Web
Component
Web
Component
Presentation Tier
Business Tier
EJB Container
Encapsulation
Container-Managed Transactions
Declarative Security
Session
Façade
Business
Object
Business
Object
Figure 2.4
Encapsulating the business
logic with an EJB session
façade
Business
Object
 
 
 
Search WWH ::




Custom Search