In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I. three-tier architecture diagram
II. Responsibilities at all levels of the system
The responsibility of the 1.UI (User Interface) layer is to display and collect the data. The results of data collection are usually submitted to the BL layer by Entity object. The Service Interface side layer is used to publish business or data resources as services (such as WebServices).
The responsibility of the 2.BL (Business Logic) layer is to process requests submitted by the UI layer according to predetermined business logic.
(1) the Business Function sublayer is responsible for the implementation of basic business functions.
(2) the Business Flow sub-layer is responsible for organizing the basic business functions provided by the Business Function sub-layer into a complete business flow. (Transaction can only be opened in the Business Flow sublayer. )
The responsibility of the 3.ResourceAccess layer is to provide comprehensive resource access support and shield the source of resources to the upper layer.
(1) BEM (Business Entity Manager) sublayer uses DataAccess sublayer and ServiceAccess sublayer to provide basic data / resource access capabilities needed by the business.
(2) the DataAccess sublayer is responsible for accessing resources from the database and shielding all SQL statements and database type differences from the BEM sublayer.
The DB Adapter sublayer is responsible for shielding differences in database types.
The ORM sublayer is responsible for providing object-relational mapping.
The Relation sublayer provides Relation-based data access that cannot be accomplished by ORM.
(3) the ServiceAccess sublayer is used to obtain resources from external systems in the way of SOA.
Note: Service Entrance is used to simplify access to Service. It acts as a proxy for Service. Customers can access services published by the system directly using Service Entrance. Service Entrance provides strongly typed interfaces for specific platforms (such as Java, .net), and complex parameter type conversions may be hidden internally.
(4) the ConfigAccess sublayer is used to obtain the configuration object from the configuration file or to save the configuration object inverted configuration file.
The 4.Entity side layer spans the UI/BEM/ResourceManager layers and passes data between these layers. The Entity side layer contains three types of Entity, as shown in the following figure:
III. Aspect
Aspect runs through all layers of the system and is the crosscutting concern of the system. AOP technology is usually used to model and implement crosscutting concerns.
1.Securtiy Aspect: used to support the Security of the entire system.
2.ErrorHandling Aspect: consistent error / exception handling is adopted throughout the system.
3.Log Aspect: used for system exceptions, logging, business operation records, etc.
Four. rules
1. Cross-layer calls are not allowed among all levels of the system and between sub-layers within the layer.
2.Entity object passes data between tiers.
3. The data that needs to be bound to the list at the UI layer is passed using relational DataSet; in addition, Entity object should be used to pass the data.
4. There is a DB Entity class for each database table (Table) and a BEM Class for each Entity class.
5. Some cross-database or cross-table operations (such as complex federated queries) also need to be supported by the corresponding BEM Class.
6. For relatively simple systems, consider merging the Business Function sublayer and the Business Flow sublayer into one.
The 7.UI layer and the BL layer prohibit any SQL statements.
Five. errors and anomalies
Exceptions can be divided into system exceptions (such as sudden disconnection of the network) and business exceptions (such as the user's input value exceeds the maximum range). The business exception must be transformed into the result of business execution.
The 1.DataAccess layer must not hide any exceptions from the upper layer (almost all exceptions thrown by this layer are system exceptions).
2. Make a clear distinction between the results of business execution and system exceptions. For example, to verify the validity of the user, if the corresponding user ID does not exist, you should not throw an exception, but return (or through the out parameter) an enumerated value that represents the verification result, which belongs to the result of business execution. However, if the database connection is suddenly disconnected while extracting user information from the database, a system exception should be thrown.
3. In some cases, the BL layer should catch some system exceptions according to the needs of the business and convert them into the results of business execution. For example, if a business needs to test whether the specified database can be connected, BL needs to convert the system exception that failed to connect to the database into the result of business execution.
The 4.UI layer (including the Service layer) needs to intercept all system exceptions and interpret them as friendly error messages to the user in addition to the return values obtained from the API calling the BL layer to view the execution results of the business.
VI. Project organizational structure
Take BAS system as an example.
1. Home directory structure:
2.Namespace naming: the root namespace of each dll is the name of the dll, for example, the root namespace of EAS.BL.dll is EAS.BL. Subnamespaces can be added under each root namespace according to the classification of requirements. For example, the subspaces EAS.BL.Order and EAS.BL.Permission of EAS.BL handle different business logic.
3. The physical organization of a large project that contains many subprojects:
The location of the core subproject Core:
The Core subproject contains some common infrastructure, such as error handling, permission control, and so on.
Seven. Release services and service callback
Take EAS system as an example.
1. Like the Page in the UI layer, the service is not allowed to throw any exceptions. Instead, it should indicate that there is an error in the service call by returning an error code (int type, 1 indicates success, and other values indicate failure). If the method has a return value, the return value is provided as the out parameter.
two。 If the BAS system provides WebService (Remoting) services, BAS must provide BAS.Entrance.dll. BAS.Entrance.dll encapsulates the communication mechanism for exchanging information with BAS services, and the customer system can easily access the services provided by BAS through BAS.Entrance.dll.
3. If the BAS needs to call back the customer system through WebService (Remoting), you must provide a BAS.CallBack.dll with only defined interfaces. The customer system will reference the dll, implement the interfaces, and publish it as a service for BAS callback.
4. When the parameter or return value of WebService needs to be a complex type-- that is, Service Entity in the architecture diagram-- Service Entity should be defined in the corresponding BAS.EntranceParaDef.dll or BAS.CallBackParaDef.dll. Complex types in methods defined by WebService should be replaced with Xml strings (note that the parameters of the methods of the service corresponding to the Entrance and CallBack interfaces are strongly typed), while the conversion between Xml strings and complex type objects should be implemented in BAS.Entrance.dll or BAS.CallBack.dll.
This article declined to reprint, if there is plagiarism, according to the legal procedure to punish!
Writer: XiuQuanShi
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.