Session Facade

Brief Description

Many business processes involve complex manipulations of business classes. Business classes often participate in multiple business processes or workflows. Complex processes that involve multiple business objects can lead to tight coupling between those classes, with a resulting decrease in flexibility and design clarity. Complex relationships between low-level business components make clients difficult to write.

The Session Facade pattern defines a higher-level business component that contains and centralizes complex interactions between lower-level business components. A Session Facade is implemented as a session enterprise bean. It provides clients with a single interface for the functionality of an application or application subset. It also decouples lower-level business components from one another, making designs more flexible and comprehensible.

Fine-grained access through remote interfaces is inadvisable because it increases network traffic and latency. The "before" diagram in Figure 1 below shows a sequence diagram of a client accessing fine-grained business objects through a remote interface. The multiple fine-grained calls create a great deal of network traffic, and performance suffers because of the high latency of the remote calls.

Figure 1. Sequence diagram before and after adding Session Facade

Introducing a Session Facade, as shown in the "after" diagram in Figure 1, decreases network traffic and latency, because all access to fine-grained business objects is local. The Session Facade also acts as a Mediator [ GHJV95 ] between the business objects, decoupling their APIs from one another.

Detailed Description

See the Core J2EETM Patterns

Detailed Example


Copyright © 2002 Sun Microsystems, Inc. All Rights Reserved.