Analysis of Multi - layer Structure and Its Realization in Delphi

xiaoxiao2021-03-06  32

Abstract: This paper discusses the structure, characteristics and realization of distributed multilayer application systems. The multilayer structure based on MIDAS technology is analyzed by Delphi, and the steps of implementing the multilayer structure are illustrated.

Keywords: multi-layer structure, client, application server, remote database server

1 multi-layer structure application system

1.1 Layer 2 structure

In traditional Layer 2 C / S structural database applications, the client's machine performs an application, connecting to the application system to access the application in the backend database server, because the application system's enterprise logic is written in the client's application, There is a very bloated client, and when the application system needs to change, all the client's applications must change, so that the maintenance cost is too high.

Oracle

MSQL

Client 1 Database Server Sybase, etc.

Figure 12                       

1.2 concept and characteristics of multi-layer structure

In order to solve these problems, the multi-layer structural application system should be born, ie, in the traditional Layer C / S model, put it in the application server. The application server is simply that an application containing corporate logic, developers in a specific component, such as Microsoft COM / DCOM, CORBA object, or Enterprise Java bean, etc., packaged company logic program code, this Package, objects that can perform specific enterprise features are called "corporate objects", distribute these business objects into the application server, and developers can use the services provided by these corporate objects when developing applications.

A typical structure of multi-layer structure is a three-layer structure, and its basic idea is to separate the user interface to the enterprise logic. The overall structure is shown in Figure 2.

Client Application Server Remote Database Server

(Provide user interface) (including corporate logic) (Oracle, MSQL, Sybase, etc. DBMS)

Figure two-three layer structure model

(1) Client application. Provide user interface, main functionality is to guide operator use interface, enter data, and output results, do not have enterprise logic, or only part of the part does not involve the core, confidential application logic. This way, the client is very awkward, called "廋" customers.

(2) Application server. It is the main body of the application, which includes the core and variable enterprise logic (planning, operation method, management model, etc.) in the enterprise (planning, operation method, management model, etc.), and its function is accepted, and the result is returned after processing.

(3) Remote database server. That is, the database management system (DBMS) is responsible for managing reading and writing and maintenance of data.

In a more complex multi-layer architecture, more intermediate servers can be added between the "廋" client and the remote database server, such as adding an intermediate security server or an intermediate conversion server for processing different platform data.

The distributed multi-layer structure divides the entire application system into several different parts and performs in different machines. The application server implements the enterprise logic as an intermediate layer, coordinates the request between multi-layers, and masters all the details of the data set defined and the remote database server for communication, so that the client application focuses on display data and user interaction with users. On the client application, you don't even know the data there.

Specifically, the multilayer structure has the following advantages:

(1) Enterprise logic is encapsulated in a shared intermediate layer, and the different client applications can share the same middle layer without having to implement corporate logic separately by each client application.

(2) The client application can do very much. Because many of the complex work is handled by the application server, the client application simply pays attention to the user interface itself. "廋" client application is easier to publish, install, configure, and maintain. (3) Realize distributed data processing. Distribute an application on several machines to provide the performance of the application, and can guarantee the entire application to crash through the redundancy configuration.

(4) It is conducive to safety. Partial sensitive data function is packaged in the intermediate layer and grant different access rights to ensure access restrictions on the data.

1.3 Techniques for use in multi-layer structures.

At present, the core of the distributed multi-layer structure can be roughly divided into two different industrial standards, namely Microsoft developed COM / DCOM / COM , and CORBA advocated by more than 700 manufacturers. Due to the broad popularity of distributed structures, there is also a distributed technology that is increasingly evolved from these two distributed core technologies, such as EJB (Enterprise Java Bean).

Microsoft's COM / DCOM / COM is a Windows-centric development environment, CORBA is a platform-neutral distributed technology, and CORBA can perform in operating systems such as Windows, UNIX, and Linux. These technologies can enable developers to easily use the services provided by the enterprise object in the application. Both distributed technologies simulate the enterprise objects on the real remote application server in the client machine, so that the client application can call the simulation objects in the client machine, the object Use a specific communication protocol to truly call the corporate object on the remote application server to call the service of the remote business object to meet the requirements of the client.

2 Implementing MIDAS-based multi-layer structure 2.1 Implementation of multi-layer structures in Delphi's multilayer structure in Delphi is the MIDAS (Multi-Tier Distributed Application Service Suite, multi-layer distributed application server group) technology. Midas is a collection of different technologies, whether the application server or client, MIDAS technology requires support for dbclient.dll and midas.dll, these two dynamic link libraries are used to manage packets, and they need to publish this when publishing MIDAS applications. file. MIDAS-based multi-layer structure is still divided into client applications, application servers, and remote database servers, as shown in Figure 3. As can be seen from Figure 3, Midas's database applications require some special components, which are divided into 4 categories: (1) Remote data module. Located on the server side, as a COM server or CORBA server allows client applications to access its interface. Data Module IAPPServer Interface Remote Data Module

User Interface

Connect components

Data source ClientDataSet

DataSetProvider

DataSet components

BDE

Client Application Application Server Remote Database Server

Figure three MIDAS structure

(2) DataSetProvider components. Located on the server, the Iappserver interface is provided, and the client application obtains data through the Iappserve interface. (3) Connecting components. Located in the client, including DCOMCONNECTION, SOCKETCONNECONNECTION, MIDASCONNECTION, OLENTERPRISECONNECTION, MIDASCONNECTION, OLENTERPRISECONNECTION, MIDASCONNECTION, and REMOTSERVER, etc., which positions the application server and Iappserve interface for client applications. (4) ClientDataSet components. Located on the client, access the server-side Iappserve interface, which is inherited from TDataSet. The client application communicates via the Iappserve interface and the application server, the communication protocol is DCOM, TCP / IP, HTTP, Olenterprise, and CORBA. The communication protocol is different from the remote module on the client's MIDAS connection component and the application server. 2.1.1 The client application structure is structured, and the client application interacts with the user through the standard data control component, but it is obtained through the Iappserve interface provided by the application server, and is also updated through the Iappserve interface. The so-called "廋" customer refers to a client application consisting of a Dataset (TclientDataSet component) that does not rely on BDE. TclientDataSet 榧  ? / Span> TDataSet derived client data set components, it plays the same role with TTable or TQuery, but it does not need BDE, which creates a copy in client memory through the Iappserve interface. , Operate the data. Accessing the remote database server directly is the application server. Remote data module

Description

RemoteDataModule

Support for dual interface automation servers, support DCOM, TCP / IP or OLENTERPRISE protocols.

MTSDATAMOUDLE

Support for dual interface automation servers, created application servers are dynamic link libraries, support DCOM, TCP / IP or OLENTERPRIS protocols. CORBADATAMOULE CORBA server supports CORBA protocol

On the client, the MIDAS connection component is very important, and different connection components use different communication protocols, as shown in Table.

Connect components

Protocol

DCOMCONNECTION

DCOM

SocketConnection

TCP / IP

WebConnection

HTTP

Olenterprise

Olenterprise

Corbaconnection

Corba

Table 1 Midas connection method table two support MIDAS data module

2.1.2 The key components of the application server application server are remote data modules, on the remote data module, TTable, TQuery, etc. BDE data set components access the database via the BDE and the remote database server, the DataSetProvider component outputs the Iappserver interface, the DatasetProvider component passed The DataSet property is connected to the data set component so that the client can access the data over the Iappserver interface. Delphi supports three types of remote data modules, as shown in Table. 2.2 Creating a multi-layer structure database application instance with MIDAS Establish a multi-layer structure application, you must first establish an application server and run registration, and then establish a client. Here, a three-layer structure created by the author as an example to describe the steps of triple structures with D ELPHI. (Suppose is set up on the application server, connect to the remote database server.) 2.2.1 Establish an application server. (Create on the application server) (1) Build a new application using the New Application under the File menu. (2) Create a remote module. Open the New Items dialog in the MultiTier option using the New Items dialog box, double-click Remote Data Module, and set ClassName to take default values ​​for RDM, Instancing, and Threading Module properties. (3) Put a query1 (tQueyR component) on the remote module, specified in the DatabaseName property, as you want to access, such as "Press House". Add a DataSetProvider1 (TDataSetProvider component) on this remote module, and the DataSet property is set to query1, and POAALLOCOMMANDTEXT is TRUE. (Set to TRUE, the SQL statement in the TclientDataSet attribute CommandText in the client application can be passed through the Iappserver interface.) To this, the application server has been created, running the application server registered it in the system, in the application The server runs SCKTSRVR.EXE files on the server, so that the client program can call the application server in the future. 2.2.2 Creating a client application. (Create on the client machine) (1) Set a data module. Build a new application using the New Application under the File menu. Double-click Data Module to create a data module (named DM) in New Item, put a connection component socketconnection1 (TSocketConnection component), specify the IP address of the application server in the IP attribute, and take the default value in the port property. 211, set the application server in the ServerName property (here, the application server is the application server called RDM above.) So you can locate the application server and the Iappserver interface. Add a clientDataSet1 (TClientDataSet component) on the DM data module, and its RemoteServer property is set to SocketConnection1, and ProviderName is DataSetProvider1. Save the unit as DM. (2) Create a user interface. Use the New Form under the FILE menu to create a new unit, reference the data module unit DM established above in this unit.

Add Datasource1 (TDataSource Components) on the User Interface Form, which is set to DM.ClientDataSet1, which is the client data set component in the above data module. Add a DBGRID1 (TDBGRID component), the DataSource property is set to DataSource1. Add a BTTON1 component, the CAPTION property is "query", the program code in its Click event is: procedure tform1.button1click (sender: TOBJECT); Begin With DM.ClientDataSet1 Do Begin Close; CommandText: = 'SELECT * FROM book'; Open End; end; to this three-layer structure has been created, save the running client application, click the Query button (ie the BTton1 button), the client application will activate the application server program, and put DM.ClientDataSet1 via the Iappserver interface. The SQL statement is transmitted to Query1, Query1 accesses the database server via the BDE, and the data is found to pass through the Iappserver interface to DM.ClientDataSet1, and displayed on DBGRID1. 3 Conclusion Multi-layer structure is the product that occurs due to the needs of network development, using object-oriented technology, separating user interface and corporate logic, solves the high maintenance cost of two layers of structures, the client bloated, etc., and improves ductility. In Delphi, MIDAS technology is used, using COM / DCOM / COM or CORBA standard, providing powerful functions for multi-layer structures, increasing the productivity of developers.

references

1. Li Wei, Delphi 5.x Distributed Application System, Machinery Industry Press, April 2000.

2. New Zhisheng Studio, Delphi 5 Database Programming, Electronic Industry Press, September 2000.

3. Xu Xinhua, Delphi Advanced Programming - Database and MIDAS Programming, People's Posts and Telecommunications Publishing House, April 2000.

Author: Zhang Yuzhen, Huang posted from: Southeast University

转载请注明原文地址:https://www.9cbs.com/read-76785.html

New Post(0)