Three-layer application based on Windows DNA
Abstract This paper reviews the development of the application model, introduces the structure and advantages of the current three-layer application model, and how to build this new model application on the Windows platform, and give an instance.
Key words three-layer application 3-Tier Client / Server COM / DCOM
With the development of computer networks and their related technologies, Internet is no longer just a way to communicate and acquire information, and will become a large distributed computing platform. E-commerce and other very developmental applications will be based on this platform. Current / Server applications based on PC or LAN will gradually develop into distributed applications with built-in Internet access capabilities. In order to meet the opportunities and challenges of the development of the Internet, Microsoft proposed Windows DNA (Windows Distributed Internet Application Architecture). Its goal is to create a distributed application framework based on Microsoft Windows platform, integrated Client / Server model, and web applications, providing the underlying basic service for this application, so that developers can use them directly, thereby putting main energy inputs On the real business rules (Business logic) related to the application. Windows DNA unifies Microsoft's operating systems, browser (IE), Web Server (NT, and IIS) SQL Server, Transaction Server, etc. together. The services provided by Windows DNA are implemented through COM / DCOM and related technologies, including plug-and-play software components, directory services, data access, security management, web browsers, transactions, transactions, and messages management, user interface technology. Wait. Through these consistent, unified services, developers can easily develop distributed applications running on the Internet.
First, the development of application model
The initial computer application is a computational model based on host / terminal mode. Almost all calculations in the application are completed by the host, and the terminal is only an output device. In the 1980s, there was no shortcomings for this system structure, and people proposed a wide range of applications. This model has gradually been widely used. As the application system is large, the requirements of the Internet-based application development continue to increase, this two-stage structure (2-tier) defects and incompatient are increasingly obvious, and people have proposed a three-layer (3-tier) Application model.
Any application that consists of three parts: user interface section (representation layer), application logic section (application logic layer), and data access section (data access layer). The function of the layer indicates that the user interacts, the application logic layer, the process, etc., the data access layer maintains and updates the application data. Although any application consists of such three parts, different application developers take different combinations for various factors such as development fees, scalability, and components.
1. Two-story application model
In a Client / Server type 2 (as shown in Figure 1), the representation layer and the application logic layer are combined, run on the client, and access the remote data over the network. With the API interface such as the Industry standard SQL language, the client's application component reads data from the database, executes the program's operational logic, and then send the data back to the database. This application model is more suitable for small-scale, fewer users (<100), single database and safe, fast network environments. Due to most of the current development tools support the development of fast Client / Server applications, it has become the main way of network applications. In multi-user, multi-database, and non-secure network environments (such as Internet), two layers of applications have significant limitations: the server-side database must be kept connected with each active customer, which consumes a lot of operations Resources, the result is that the performance has declined with the increase in the number of customers.
Representation (PRESRNTATION)
Application logic layer (Business logic)
NetWork
Data Service Layer (Data Service)
Figure 1 Two-layer (Client / Server) application model
Multi-user, the connection between the connection of the multi-database has a deadlock and system crash. A data is locked in a large-scale distributed environment such as Internet to prevent other users from accessing to other users for a long time.
Safety management in two-layer mode is not suitable for non-local area network environments. Since the transaction logic resides in the client, this kind of user authorization-based security management can be used for what you want, you can bypass the application logic of the client.
The code in the two-layer application is difficult to reuse, as this application (user interface and program logic together) and the specific data are closely linked together, reuse can only be implemented in the form of a COPY / PASTE source code rather than binary components .
Since the application logic resides in the client, the program on each client needs to be updated when the application environment changes, and the program on each client needs to be updated, and there is a certain difficulty to cause maintenance and management of the system.
As the application system is more and more complex, client applications become increasingly large, and the processing capacity of the client is getting higher and higher, becoming a so-called "fat client."
In order to alleviate the various pressures above, some server-side database systems support writing "stored procedures" such that users can perform a set of SQL statements stored in the remote database server at a time. The client's application can call these stored procedures, pass parameters to it, and retrieve the results of the execution. The stored procedure greatly reduces the overhead of network communications, improves the reusability of security and system code. Compared to two-layer models that represent the layer together with the application logic layer together, this two-layer plotted part of the program logic to the server, thereby improving the scalability, security, and reusability of the system, but These performance improvements are limited, such as different database vendors' stored procedures are incompatible, and lack of the advantages of binary components plug-and-play, and it has been greatly limited.
2. Three-layer application model
Just a year or two, there are few people engaged in multi-layered applications, and there is only a lot of tools to support the development of this model. Now it is gradually become mainstream, two of which plays a key role: scalability requirements and the development of Internet. The two layers are scalable in scalable and the requirements for the client are getting higher and higher. The development requirements of the Internet are running on the "thin client", so the program logic must be separated from the user interface, so that the three-layer application is necessary. Under the three-layer structure, the presentation, the application logic, the data service layer (DataService) is split into three relatively independent units (as shown in Figure 2). The representation is responsible for interacting with the user and transmits the corresponding request by calling the component of the intermediate layer to the application logic layer. The components of the application layer perform specific transaction logic and propose data or other resource requests to the third layer components through SQL. NetWork
Application logic layer (Business logic)
NetWork
Data Services (DATA Service)
Presentation
Figure 2 3-layer application model
The three-layer architecture is often referred to as Server-Centric because the application logic is on the server running in the intermediate layer, which is relatively independent with the user interface and data. Although there is no requirement that these three must be run on different machines, in general, the representation of the layer is running in the client, such as the space, data access is also running on a dedicated database server. This hierarchical manner has brought many advantages:
1 Application logic is placed on the server by all user sharing, making the system maintenance and update simple, when transaction logic changes, simply updating the corresponding application logic components on the server, and then all customers can use new Transaction logic. Avoid the difficulties of client application version control and update.
2 In the application logic layer, developers can develop reusable binary components using commonly used development tools such as VB, VC, rather than writing stored procedures. Moreover, these components can be mirrored to run simultaneously on multiple machines to share multiple users' loads.
3 Application Components can share connections to the database, the database server is no longer a connection to each activity, thereby reducing the burden on the database server, and improves performance.
4 Safety management can be authorized based on components rather than authorizing to users, customers no longer directly access databases, improve security.
Second, the development of the three-layer application of Microsoft
Browser
Ordinary application
SQL Server
Other data sources
Component 1
Component 2
Component 3
NT Server
MTS
IIS
Presentation
Application logic layer (Business logic)
Data Service Layer (Data Service)
Figure 3 Three-layer application structure under the Microsoft platform
On the Windows DNA platform, the development of software is the development of Components based on COM / DCOM. The code of the logic layer exists in the form of reusable binary components. To effectively manage and use these components, Microsoft launches Microsoft Transaction Server (hereinafter referred to as MTS). As shown in Figure 3, MTS provides a Server-end operating environment for building and distributing a three-layer application based on COM / DCOM technology. The components of the application layer in this application are running under the control of the MTS on Server. A component of the layer, including the compiled application or web page and the scripter, to complete the corresponding functionality through the DCOM calling the application layer (existing in the form of a component), and completes the corresponding function. The components of the application layer have access to a variety of different data sources through the MTS, including databases, file systems, and even MAIL systems, MTS provides a variety of automated connections, thread buffering, lock management, transaction management mechanisms. service. Developing a three-layer application based on Windows DNA generally goes through the following steps:
1 understand the application environmental demand, divide it into a representation layer, apply the logic layer, and data service layer. Hierarchical division is a very important step in the design process, which will directly affect its performance and scalability.
Represents the layer mainly completing the interaction with the user, analyzing and responding to user input, mainly written primarily through active pages running in the browser (including HTML DHTML, SCROL, Java, App1Et, and ActiveX Control) or other advanced languages such as VB. The interface program is implemented.
Applying logic layers implement specific transaction logic, by dividing it into multiple relatively independent components (modules), encapsulate internal implementation details, improve its security and reusability. These components can be implemented with a variety of development tools that support COM / DCOM.
Data service layer provides data storage and access, you can select different data sources for different applications.
2 Implement application logic components. In order to divide and run in MTS, various services such as transaction management of MTS is used, and some specific rules are needed, such as timely release resources.
3 Package and install components. These application logic components are not only installed and configured at the Server side, but also register on the client so that the client's application can access them via DCOM. MTS provides tools for packaging and distributing a Server end component.
The development of application layer components can adopt a variety of mature development environments such as Visual Basic, Visual C19, Delphi, Visuai J . Compared with the development of the usual two-layer applications, developers can develop components that can be run in the deletion environment as long as they follow several simple rules. When the layer is to call these components, the client's DCOM will automatically route these requests to the MTS in the application layer, and provide a unified service. These services provided by MTS make developers do not need to master a large number of complex interfaces programmed by the server, as long as writing a single user's component, you can issue directly in the MTS, automatically support multi-user access, so that many desktop applications are very It is easy to convert into a server-side solution.