The MVC architecture and Design pattern of Java EE (ii.)

Source: Internet
Author: User

5. Session Surface

Session façade mode adjusts operations between cooperative enterprise objects and synthesizes application functions into a single, simple interface; it reduces the complexity of collaboration between classes and makes it possible for the caller of the class to change without changing the class, which is typically implemented as a session bean. A complex interaction to hide the underlying EJB.

The background of this design pattern is that the EJB usually includes both the program data and the program logic, which will be applied to the client layer through a certain interface, which will cause some difficulties in the multi-level Java-EE platform application.

Specifically, in a multi-tiered system on the Java-EE platform, the following problems usually exist:

(1) The relationship between the layers is too close, the customer layer and the back end of the business object has strong dependence;

(2) There are multiple method calls between the client and the server, resulting in Web performance problems;

(3) The lack of a certain client access mechanism, so that some background objects are casual access.

A multi-level Java EE application usually has many server-side objects implemented by EJB, which are usually responsible for providing system services, data information, etc., that is, as a business object, they include both the relevant program data and the program logic; in the Java EE application System, Objects that are responsible for program logic are typically implemented by the session bean, objects that represent persistent storage and that are shared among multiple users are implemented by entity beans; Of course, users of the application system need to access enterprise objects to meet their own needs, if the enterprise object to provide users with interfaces, users can directly communicate with the relevant objects, But in this way, the user must be responsible for managing the relationships between the calling enterprise objects and handling the business processes in between; however, if there is too direct interaction between the user and the business object, the connection between the two is too tight, and the user is too dependent on the specific implementation of the Enterprise object, and is responsible for managing the business object lookup and creation related to the interaction process, as well as the relationship between different objects, and even some times the user needs to manage the transaction management links between the multiple invocations.

As users ' needs grow, this is often the case that the application system, the user and the interaction between different enterprise objects will become more and more complex, and enterprise objects may need some internal updates to meet the needs of the former, but in this case users need to be based on the changes in enterprise objects to make corresponding changes, This situation will cause considerable trouble to the application system, when accessing the EJB application system, the user needs to interact with the remote object. If the user interacts directly with all relevant business objects, will have a huge web burden, because a remote call will be generated for each EJB activation, and if there are a large number of system users, the interaction between the user and the object will put a lot of pressure on the web communication, causing the system to be greatly compromised. If users have direct access to the enterprise objects on the backend, but the system lacks a unified user access mechanism, these accesses are likely to become disorganized, resulting in degraded system performance and even some security issues.

To solve these problems, developers can adopt a session-side design pattern that uses session beans to implement a face (façade) that contains the interaction of all related objects in a workflow, which is responsible for managing business objects and providing a unified service access layer to the user. The session surface can interact with the underlying object and provide a service layer that contains only the interfaces that must be provided, thereby isolating the complex object interaction from the user; The session face is also responsible for managing the interaction between enterprise data and enterprise objects and expressing the enterprise logic that is needed. The session surface can also manage the interaction between enterprise objects, and the session surface also manages the creation, lookup, modification, and deletion of objects, depending on the needs of the workflow.

In a complex application system, the session surface can delegate the management of its lifecycle to a single Help object, for example, the session surface can deliver the work of the management session and entity Bean Lifecycle to the service locator object, and in the application system, it is also important to examine the role relationships between business objects, Some relationships may be temporary, that is, only used in certain interaction processes, while others are permanent, the temporary relationship is suitable for modeling in the session surface of the workflow, the permanent relationship requires concrete analysis.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.