- Java EE 8 Design Patterns and Best Practices
- Rhuan Rocha Jo?o Purifica??o
- 411字
- 2021-07-23 16:54:57
The classic Session Fa?ade pattern scenario
The Session Fa?ade pattern can be used in several architectures. The following diagram shows a classic model of Session Fa?ade usage:

Looking at the preceding diagram, we can see that a client (typically a web component or a Business Delegate implementation) accesses the facade layer. In this architecture, we find some options that depict the use of the Session Fa?ade.
The Fa?ade can handle different business objects (BO). Later in this chapter, we will see a better description of a BO and the business-object pattern. A business object is the representation of a conceptual model, which is a real-world object. A BO may have methods that describe its behavior. In this case, we will say that this BO reflects a non-anemic model (an anemic domain object contains a few business methods, such as validation and calculation). Here, the BO can use a Data-Access Object (DAO) pattern as a strategy for executing CRUD operations.
The Fa?ade can directly access a POJO JPA (Java Persistence API) entity. If the conceptual model of the business object is very close to the data model, we can fully represent this business object (an actor of a use case of the application) as a persistence entity. Most of the time, a Session Fa?ade is implemented as an EJB session. Although a JPA entity does not require an EJB container to run because it runs in both JSE and JEE environments, the EJB and JPA technologies make a very successful combination. Since the JEE 5.0 platform, JPA has been the default specification for object-relational mapping (OR mapping) and persistence-management. JPA version 1.0 is part of the JSR 220 specification (EJB 3.0). The final result of the EJB 3.0 specification is that three separate documents were produced, the third being the Java Persistence API. This described the persistence model for the JSE and JEE environments. More internal services are offered naturally by the implementation of the EJB technology, such as transaction and security control:
- In most applications, the Session Fa?ade uses a DAO implementation to perform the crud operations with the persistence layer. We will see later that the DAO pattern encapsulates the details related to crud, and can directly use a JDBC implementation or a JPA implementation to perform the crud work.
The following is an activity diagram with the component tiers involved in the Session Fa?ade pattern:

The following shows the Session Fa?ade pattern-sequence diagram:

- 全屋互聯(lián):智能家居系統(tǒng)開發(fā)指南
- Cybersecurity:Attack and Defense Strategies
- vSphere Virtual Machine Management
- SOA實(shí)踐者說
- 開源安全運(yùn)維平臺(tái)OSSIM疑難解析:入門篇
- 新手易學(xué):系統(tǒng)安裝與重裝
- Linux性能優(yōu)化
- Linux內(nèi)核設(shè)計(jì)的藝術(shù):圖解Linux操作系統(tǒng)架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- 分布式系統(tǒng)設(shè)計(jì)實(shí)踐
- Linux網(wǎng)絡(luò)操作系統(tǒng)項(xiàng)目教程(RHEL 7.4/CentOS 7.4)(第3版)(微課版)
- Linux應(yīng)用大全 基礎(chǔ)與管理
- Windows網(wǎng)絡(luò)編程(第2版)
- Implementing Domain-Specific Languages with Xtext and Xtend(Second Edition)
- Learning Joomla! 3 Extension Development(Third Edition)
- 再也不踩坑的kubernetes實(shí)戰(zhàn)指南