Application Hierarchy & Package Structure Division

Reference from Alibaba's java development manual
4. Engineering specifications
(1) Application layering

In the figure, the upper layer depends on the lower layer by default, and the arrow relationship indicates that it can be directly dependent. For example, the open interface layer can depend on the
Web layer, or can directly depend on the Service layer, and so on:
write picture description here

  • Open interface layer: It can directly encapsulate the Service interface and expose it as an RPC interface; encapsulate it into an http interface through the Web; gateway
    control layer, etc.

  • Terminal display layer: Template rendering and execution of the display layer at each end. Currently, it is mainly velocity rendering, JS rendering, JSP
    rendering , mobile display layer, etc.

  • Web layer: It mainly forwards access control, checks various basic parameters, or simply handles non-multiplexed services.

  • Service layer: relatively specific business logic service layer.

  • Manager layer: general business processing layer, which has the following characteristics:
    1) A layer that encapsulates third-party platforms, preprocesses returned results and converts exception information;
    2) Descends the general capabilities of the Service layer, such as caching solutions, common middleware Processing;
    3) Interact with the DAO layer and encapsulate the general business capabilities of DAO.

  • DAO layer: data access layer, which interacts with the underlying MySQL, Oracle, and Hbase.

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

  • [Reference] (Layered Exception Handling Protocol) In the DAO layer, there are many types of exceptions, and fine-grained exceptions cannot be used to
    catch them. Use the catch(Exception e) method and throw new DAOException(e) without printing logs.
    Because logs must be captured at the Manager/Service layer and logged into log files, if the same server
    logs performance and storage will be wasted. When an exception occurs at the Service layer, log information must be recorded to disk, and parameter
    information , 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 the same as that of the DAO
    layer . If it is deployed separately, the same processing method as that of the Service is adopted. The web layer should never continue to throw exceptions,
    because it is already at the top level, and there is no way to continue to handle exceptions. If you realize that this exception will cause the page to fail to render normally,
    you should jump directly to the friendly error page, and try to be as friendly as possible. error message. The open interface layer should process
    exceptions into error codes and return error messages.

  • [Reference] Hierarchical Domain Model Specification:

  • DO (Data Object): One-to-one correspondence with the database table structure, and the data source object is transmitted upward through the DAO layer.

  • DTO (Data Transfer Object): The data transfer object, the object that the Service and Manager transfer to the outside.

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

  • QUERY: Data query object, each layer receives the query request from the upper layer. Note: For query encapsulation with more than 2 parameters, it is forbidden
    to use the Map class to transmit.

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


Packet structure division

  • General division: com. company name. business line (or project name). business sub-line

  • Open interface layer: It can directly encapsulate the Service interface and expose it as an RPC interface; encapsulate it into an http interface through the Web; gateway
    control layer, etc.
    com.company name.project name.xxx.openapi

  • Terminal display layer: Template rendering and execution of the display layer at each end. Currently, it is mainly velocity rendering, JS rendering, JSP
    rendering , mobile display layer, etc.

  • Web layer: It mainly forwards access control, checks various basic parameters, or simply handles non-multiplexed services.
    com.company name.project name.xxx.web When
    this layer is relatively large, it can be further divided into:
    com.company
    name.project name.xxx.web.admin com.company name.project name.xxx.web.user
    com.company name.project name.xxx.web.bill

  • Service layer: relatively specific business logic service layer.
    com.companyname.projectname.xxx.service
    Generally speaking, this layer will also be larger
    com.companyname.projectname.xxx.service.admin
    com.companyname.projectname.xxx.service.bill

  • Manager layer: general business processing layer, which has the following characteristics:
    1) A layer that encapsulates third-party platforms, preprocesses returned results and converts exception information;
    2) Descends the general capabilities of the Service layer, such as caching solutions, common middleware Processing;
    3) Interact with the DAO layer and encapsulate the general business capabilities of DAO.
    com.companyname.projectname.xxx.manager.wuzhong
    com.companyname.projectname.xxx.manager.cache
    com.companyname.projectname.xxx.manager.dao

  • DAO layer: data access layer, which interacts with the underlying MySQL, Oracle, and Hbase.
    com.company name.project name.xxx.dao

  • External interfaces or third-party platforms: including RPC open interfaces of other departments, basic platforms, and HTTP interfaces of other companies.
    com.company name.project name.xxx.extraapi (we directly call the external layer)

  • [Reference] Hierarchical Domain Model Specification:

  • DO (Data Object): One-to-one correspondence with the database table structure, and the data source object is transmitted upward through the DAO layer.

  • DTO (Data Transfer Object): The data transfer object, the object that the Service and Manager transfer to the outside.

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

  • QUERY: Data query object, each layer receives the query request from the upper layer. Note: For query encapsulation with more than 2 parameters, it is forbidden
    to use the Map class to transmit.

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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324836040&siteId=291194637