Application layering


1. [Recommended] By default, the upper layer in the figure depends on the lower layer, and the arrow relationship indicates that it can be directly dependent. For example, the open interface layer can depend on the

Web layer, or it can directly depend on the Service layer, and so on. Analogy:

QQ截图20170211103016.png

  • Open interface layer: The Service interface can be directly encapsulated and exposed into an RPC interface; encapsulated into an http interface through the Web; gateway control layer etc.

  • Terminal display layer: The template of each terminal renders and executes the display layer. Currently, the main ones are velocity rendering, JS rendering, JSP rendering, mobile display layer, etc.

  • #Web layer: mainly for forwarding access control, various basic parameter verification, or simple processing of non-reused services, etc.

  • Service layer: relatively specific business logic service layer.

  • Manager layer: general business processing layer, which has the following characteristics:

1) For the layer encapsulated by the third-party platform, preprocessing returns Result and conversion exception information;

2) sinking the general capabilities of the Service layer, such as caching solutions and middleware general processing;

3) interacting with the DAO layer, common to DAO business Encapsulation of capabilities.

DAO layer: Data access layer, which interacts with underlying MySQL, Oracle, and Hbase for data.

External interface or third-party platform: including RPC open interfaces of other departments, basic platforms, and HTTP interfaces of other companies.

2. [Reference] (Hierarchical Exception Handling Protocol) At the DAO layer, there are many types of exceptions generated. It is impossible to

catch with fine-grained exceptions. Use the catch(Exception e) method and throw new DAOException(e), there is no need to print logs, because the logs must be captured and logged into the log file at the Manager/Service layer. If the same server logs again, Waste of performance and storage. When an exception occurs in the Service layer, the log information must be recorded to the disk, and the parameter information must be included as much as possible, which is equivalent to protecting the crime scene. If the Manager layer and the Service are deployed on the same machine, the logging method is consistent with the DAO layer processing. If it is deployed separately, the logging method is consistent with the Service. The Web layer should never continue to throw exceptions. Because it is already at the top level, there is no way to continue handling exceptions. If you realize that this exception will cause the page to fail to render normally, then you should Jump directly to the friendly error page and try to add friendly error message. The open interface layer should handle exceptions and return them in the form of error codes and error messages. 3. [Reference] Hierarchical Domain Model Specification:

  • DO (Data Object): corresponds to the database table structure one-to-one, and transmits the data source object upward through the DAO layer.

  • DTO (Data Transfer Object): Data transfer object, the object transferred out by Service and Manager.

  • BO (Business Object): Business object. An object that encapsulates business logic that can be output by the Service layer.

  • QUERY: Data query object, each layer receives query requests from the upper layer. Note: Query encapsulation with more than 2 parameters is prohibited from using the Map class for transmission.

  • VO (View Object): Display layer object, usually an object transmitted by the Web to the template rendering engine layer.