Component-based software method and COM support

zhaozj2021-02-11  203

Component-based software method and COM support

Zhang Wei

Huazhong University of Technology Computer College

Summary As the hotspot of the study, it has elapsed in recent years. For the interoperability of each other, there must be a public component

Bottom frame. Analyze a variety of practical factors, COM is a viable option. This article discusses the support and development prospects of the COM specification for component multiplexing.

A COM-based multiplexing idea: the standardization of the serving of the interface, the development and use of the software development and the establishment of the software.

Key words software multiplexing, COM, distribution objects, components, object-oriented

Componentization as a reality and effective software development method is being received more and more attention and research. In recent years, with three layers of DNA, middleware

The system of structure and distributed objects have given a greater connotation for software architecture based on reused components. Thereby us in the evaluation component

When using the meaning, it is not limited to the shorteness of the development cycle, and the reliability of software quality is more important to realize the development of component assembled in system maintenance.

Version updates, feature, deletion, etc.), distributed computing, etc. Due to the maintenance stage accounts for about 67% of the total cost of the software development cycle

Therefore, the components reuse the important significance of the entire software industry will be met. From the perspective of maintenance and distribution calculations, the component multiplexing is to achieve

"Plug and Play".

In the traditional object-oriented programming language, the multiplexing of the inheritance mechanism is only the reuse of the source code level, and in the case where the source code is not available (component production

Under the development trend of industry, this situation is very common), it will become meaningless. More importantly, after the connection, the class components are just a logical

Unreal concepts do not bring any convenience to future possible processing.

Microsoft has developed COM since the 1990s, over the OLE1, VBX component, OLE2, ACTIVEX, COM , is now a phase

When the mature component model, a powerful underlying support is provided for component multiplexing.

CoM object package

COM is a binary standard that specifies a memory structure that COM components should have. The interaction between COM object is based entirely on this memory.

Structure operation. Therefore, it is possible to ignore different programming languages, the difference between application environments, solve the problem of recombination re-issue

The binary code level compatibility requires the support of the operating system, but the COM description object connection is different from the traditional API sharing system service.

After the connection is established, the COM underlying library is no longer needed, stop consuming system resources, compared with the API, the operating system must always manage the connection between components.

The convention of the COM is fully encapsulated on the component's functionality. Communication with the component must be done through an interface. The interface is not only a logical

The concept, and there is also a physical memory structure corresponding to it. An object can correspond to multiple interfaces, and an interface can also be

The object is implemented, showing flexible polymorphism. At the same time, it is also convenient for version management. When using the new version of the component, as long as the old version is replaced

The assembly implements the old version of the interface (by means of inclusion, aggregation), ensuring compatibility with the original software system. New features (new interface

) Can be used naturally.

The interface completely encapsulates internal functions, the specific implementation of the attribute, so that the COM object appears to be "black box" structure, completely matches the object-oriented system requirements.

"Strengthening internal polymerization". However, due to excessive emphasis on the interface, COM components generally do not have a widely advocated "weak coupled" characteristics. However, Microsoft has always been heavy

The invariance of the interface, attempts to use the standardization of the interface standardization, the interface is based on the interface-based, and the software is used to establish a practical framework. Actually

A considerable part of the ActiveX technical specification is determined by defining the standard interface and its logical relationships.

Second automation

When considering the specific implementation of the member functions within the interface, it will be found that this implementation requires a particularly completely different specification due to the particularity of the components.

The problem that needs to be resolved is: How to identify one component in the source program (physical, it is already existing, binary code with a certain function)

For the call of the specific function within the component, the compiler will process, how to perform parameters, and the collection of return values.

In the old programming mode, the above problem needs to be a descriptive file for sufficient definition of the component. Moreover, the format of the illustrative file

The grammar of the programming language used must be fully compliant. This produces some of the following contradictions. First, all different versions are configured for each distribution component.

The document is not feasible in practice; second, even such a header is automatically converted by the type library, this turn is provided for various programming languages.

The tool is also not feasible; third, the data type used in the component does not necessarily correspond to the target, and the fourth, this clumsy implementation method, "plug and play with the components" "The concept is far from, and the programmer is unacceptable.

For the above problems, the COM specification proposes automation technology, and better implementation of dynamic binding of symbol-navigating. Edispatch is achieved

Key interface.

Class IDispatch: Public IUNKNOWN

{

PUBLIC:

Virtual HRESULT GETTYPEINFOCOUNT (UINT * PCTINFO) = 0;

Virtual HRESULT GETTYPEINFO (Uint Itinfo, LCID

LCID, ITYPEINFO ** PPTINFO) = 0;

Virtual HRESULT GETIDSOFNAMES (Refiid Riid, LPolestr *

Rgsznames, Uint CNames, LCID LCID, DISPID * RGDISPID = 0;

Virtual HRESULT Invoke (Dispid Dispidmember, Refiid

RIID, LCID LCID, Word WFLAGS, DISPPARAMS * PDISPAARAMS,

Variant * PvarResult, ExceInfo * pexcepinfo,

UINT * PUARGERR) = 0;

}

In the automation object, each member function corresponds to a distribution ID (Dispid), the service navigator Invoke is established and targets through this distribution ID.

The function is connected. You can use the getIdSOfName to implement symbol (function name) to ID mapping. Therefore, the application has a unified interface to use

The various services provided by components.

For compatibility issues for data types, Microsoft provides a hard solution. Define a large data structure that "incorporate"

Variant

Typedef struct tagvariant

{

VARTYPE VT; // Type Tag

union

{// pass value type

Short Ival;

Long Lval;

BYTE BVAL;

Float fltval;

......

// Reference type

Short * pival;

......

Iunknown ** PPunkVal;

Idispatch ** ppdispval;

Variant * pvarval;

Void * byref;

}

}

Passages between automated objects and their callers and return values ​​must be performed within the range of Variant. Various variety of Variant

The conversion between numbers can be implemented in Invoke. Provides programmers with more intelligent programming interfaces (such as VB implementation).

COM specifies a basic interface IUNKNOWN that must be implemented in all component objects, which not only defines the most basic public services, but also makes one

Pointer to the IUNKNOWN interface objectively becomes an object label of the component instance. Except for the management of the object survival, this object is still enabled COM components.

Have self-explanatory features: all interfaces that object implementations can be queried by calling the member function QueryInterface for the iUnknown interface.

.

However, the various advantages of the above automation are at the expense of the restrictions and performance of its data type. Although the compiler can be in type

Front Binding (Parameter Type Check, Symbol-to Distribution ID), but the most time consuming invoke is difficult to optimize. For this purpose, the dual interface mechanism is specified

To provide programmers, providing freedoms between dynamic binding and static associations. At the same time, the existence of automation technology is also a scripting language (VBScript,

JavaScript provides a vitality.

Three inclusive and aggregation

As an important feature of object-oriented systems, COM supports two reuse models: Containment and aggregation (AGGREGATION) their ideas

This is the same, but it is only different in realization.

Considering the inclusive situation, assume that there is already a COM object A that implements interface IreuseInterface, because of the new needs, we have to achieve a new

COM object B, which is to implement interface IreuseInterface, but also to implement interface INEWINTERFACE, and the services provided by IreuseInterface are basically consistent with the interface of object A, and as long as the newly added features can complete the development of object B. The most intuitive The idea is in the interior of the object B

An instance of an object A. All the calls of the interface IreuseInterface member function are simply forwarded to the object A, for

B customer, there is no need to know the existence of A. This inclusive relationship can be represented by the following figure:

The inclusive model is more flexible when implementing, and then forwards the call to the internal object, and some localization processes are made to make up for each of A and B.

The IreUseInterface interface is functional in functional tiny differences.

Still considering the above example, if the IreUseInterface interface of B is fully consistent with A implementation, do not need to do any changes. Now use

The aggregation model is implemented B. Object B itself is not implemented interface IreuseInterface, which only implements the interface inewinterface. When B customer request

When the IreUseInterface interface, the object B passes the IreUseInterface interface pointer of the object A to the client, so the customer is directly related to A.

Interaction (although it doesn't know the existence of object a). The implementation of the polymeric model is shown in the following figure:

Of course, the aggregation model is more complicated than the inclusive model of the IUNKNOWN pointer. It is not necessary to carry out the cooperation between the object, is not every object.

Supports polymerization. But aggregation reflects the true multiplexing of component software, and the reuse of inclusion is only reflected in the customer server model.

On the basis of sex. The actual is also the nesting relationship between the client and component program. This is the essence of inclusion and aggregation.

Four unified data transmission and message delivery

In an application system based on software multiplexing, the individual components objects are collaborate to work together to complete a particular task logic. To support various

Can complex collaborative relationships, only passage of parameter information is far less than enough, and must provide standard schemes and events for application data exchange, and messages

Know the mechanism.

In both ways, COM provides a mature specification. That is, unified data transmission (UDT, Uniform Data Transfer) and MSMQ.

The well-known OLE program uses the clipboard to transmit connection object information, which is a typical application of UDT. Unified data transmission is built in structured storage

On the basis, including two aspects: first is the unity of data format, followed by the establishment of the transfer protocol. Unified data transmission mechanism uses "data object

"As an information entity, expose its internal information via the iDataObject interface. Since the data object itself is a COM object, it can not only express

General structured information, can also express some unstructured information.

The transfer protocol task is to pass the data objects provided by one component, the iDataObject interface pointer to another. Receiver gets

After the iDataObject interface pointer, you can use its member function to obtain the required data. The specific implementation and data exchange of the transfer protocol are completely separated.

Therefore, it can be easily expanded with the original system to maintain compatibility with the original system. The more common transmission protocols include clipboards, "drag-put" technology

Surgery. In addition, in order to adapt to some real-time applications, COM also provides the "Data Change Notification" mechanism to expand data objects and customer programs.

Bidirectional communication. Microsoft Message Queue (MSMQ) version 1 is a new feature of the Windows NT operating system. MSMQ provides

Reliable key task information communication on the network. With most modern applications with closely coupled and synchronous communication, MSMQ is based on one

Intersection queuing models to provide an asynchronous, loosely coupled, reliable network communication. For functional multiplexing and standardization, MSMQ uses a message

MOM Message_oriented MiddleWare. Mom provides a queue and message communication infrastructure. Application writes to the team

Into the message, the message middleware passes the message to the requested queue, another application (or another component of the same application) reads from the target queue

Take a message and process. The content of the message is completely controlled by the application of the read and write queue. MSMQ supports a wide range of queue types. Public application team

Columns are visible to MSMQ customers because they are published on a naming server, namely MQIS (Message Queue Information Store, Message

Queue Information Storage). MSMQ Customer can query MQIS to determine if there is a public application queue and which computer is host. On the other hand, the private application queue is not published in MQIS. So I want to send a private queue Message, you must know the host of this queue in detail.

Five summary

Component reuse in the field of enterprise applications, it becomes clear and clear due to the support of the three-layer architecture. Application in the Windows DNA framework

The system is divided into a layer, a business layer, and a data layer. The business layer of which can be divided into multiple sub-layers as needed. The reuse of the performance layer and the data layer have been

Quite standardized, such as various types of libraries that support GUI development, ActiveX controls, OLEDB, ODBC, etc .. The focus of component multiplexing is in the business processing layer. I believe

In order to clearly divide the services in the business world, the definition of the East Service interface can effectively realize the reuse of architecture and components.

.

With the release of Windows 2000, COM , which is about to float the water as a COM, DCOM, MTS's integration, and more closely combined with the operating system.

Com provides better support for load balancing, security, message event model, and MTS services. At the same time, part of COM will be next-generation compiler

(Visual Studio 7.0) is reflected in the design of the components more natural, friendly. With the com published, from now to future, COM will

Become a software development path based on Windows-oriented object-oriented object.

references

1 Stephen R.Schach, Software Engineering with Java, McGraw-Hill

2 Component Object Model Specification, Microsoft Corp., 1993

3 Pan Aimin, COM principle and application, Tsinghua University Publishing House

4 Yuan Xiaoling, Component Technology - New Dawn, Computer Engineering and Application of Enterprise Management Information System Development

1999, 9

5 Xu Zhengquan, Luo Ting, heterogeneous reuse soft means attribute model, computer application research, 2000, 3

6. 集, 清 清, 集,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

1999, 7

7 Rogerson Dale, INSIDE COM, Microsoft Press, 1997.isbn 1572313498.

8 DON BENAGE AZAM MIRZA, BUILDING Enterprise Solutions with Visual Studio

6.0, Macillan Computer Publishing u.s.a

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

New Post(0)