Invoking multiple session bean methods from the business delegate per user action
increased the chances of business logic spilling over into the client tier. It also increased
the possibility of client-side transaction management that the EJB component model
should have eliminated. Since multiple session bean methods were involved, it created a
lot difficulty in setting the appropriate transaction attribute while using declarative con-
tainer-managed transaction (CMT) support. Using entity beans that themselves were
transactional components did not help the cause either. It was difficult to decide whether
to handle transactions in session beans or in entity beans.
• Consolidate business workflow in remotely accessible components.
• Expose coarse-grained business interfaces to access entity beans in one network
• Prevent business logic and system-level services such as transaction management
from spilling over into the business tier's clients.
• Improve performance by consolidating business methods.
Expose a remotely accessible session facade , which will encapsulate business logic while
exposing a coarse-grained API to the clients.
Strategies with the Spring Framework
A session facade is an application of the GOF facade pattern to an EJB session bean. The
facade pattern presents a unified interface for a group of interfaces in the subsystem. In
other words, a facade is a higher-level interface that makes it easier to use the subsystem.
In the context of EJBs, this means the session beans act as a facade and expose only a
single business method per user action. This method in turn invokes private session bean
methods. Another option is to consolidate the entire business logic in one session facade
method. This method then provides coarse-grained access to the business tier. Because
only a single method of the remote business object carries out the workflow pertaining to
a use case, it is easy to apply a container-managed transaction on this method. Later in
this chapter I will explain a flexible and cleaner solution in connection with the Applica-
tion Service pattern.