MOF principle and implementation of MDA core (Chinese) (Figure)

xiaoxiao2021-03-06  110

MOF principle and implementation

Chen Jianxiang

2004-10-15

Keywords: MDA MOF AOP is known to MOF is the core of the MDA, let's quickly browse what is MOF.

overture

An application system can be divided into a typical 3-layer structure. In "UML Mode and Application" [1], it is called the UI layer, the domain layer, and the data layer. The interface of the UI layer and the domain layer is connected by the application and the application frame; the interface of the domain layer and the data layer is connected by a persistent framework. The implementation of the book on the persistence frame is implemented using a template method mode, the base class defines a persistent basic interface, and each subclass is implemented. The mapping relationship of the field of the subclass and the field of the relational database is encoded directly into the class code. The program will lead to improvement of system complexity and difficulties in system maintenance. In order to solve this problem, the book refers to another book, namely POSA [2] (Pattern-Oriented Software Architecture: a system of pattern) reflection mode.

The reflection mode described above is described in the Reflection section in POSA1, or an image [3] mode. Image modes divide the software system (domain) into basic level and element level. Basic layer implementation of the logic of the program, the meta-level package can be changed, the internal components of the system. The meta-level is composed of a component object (MetaObjects), and each element object encapsulates the selected information on the one aspect of the basic level, behavior, or status, and all element objects provide a self-expressed reply. After the persistence method is encapsulated, the basic hierarchy is serialized and reverse sequencing internal data by calling the persistent components provided by the calling element level. At the same time, it can be changed by the metamorphic protocol (MOP) to affect the persistence behavior of the entire system. The schematic diagram of this mode is as follows:

After independent from the system, the access to the meta-level access is important, which directly leads to interoperability and compatibility issues of metamorphism, that is, the metamorphic levels expressed by different model systems can be accessed each other. compatible. Let's look at the structure of the mapping mode in the mapping mode: the information saved by the meta-level information includes type information (Type_info), stored in the meta-level type library; ExttypeInfo, provides class size, inheritance relationship, and data member information, etc. The relationship between objects and relational databases can be recorded in extended information. Due to the different language, the defined metadata is similar, but the format, the interface is different. In order to solve this problem, you need a unified format and interface to describe and access metadata, which is MOF to do.

MOF architecture

We know that in order to achieve a cross-language and cross-platform object access, OMG proposes a CORBA architecture and defines IDL for unified object access interfaces. The MOF interface is a unified interface that OMG proposed in the element level. Like OMG consistent ideas, it is also accessible across language and cross-platform. In addition, it is noted that the cross-platform access and cross-platform run is different concepts. Sun's Java is running cross-platform, but Eclipse is not necessarily; C programs can be across platform access through CORBA, but do a platform It is more difficult to run.

The MOF architecture is a hierarchical metadata architecture, and the classic frame of the architecture has four modeling hierarchies, as shown below:

The upper layer of each level is the model of the next layer, and the description language of this level is in its previous layer model. For example, a meta-hierarchical stock quotation, STOCKQUOTE is used to describe a quotation object in a software system; the Yuan-Military class class Class is used to describe model layers, such as the modeling elements such as element hierarchies, package, etc. Similar, yuan-yuan -Minal, referred to as a MOF MODEL layer, the class of CLASS is used to describe a metamm-element, also known as the elementary class, package, package, associated of these construction model elements, and the last Mof Model Who is described? The answer is MOF MODEL ourselves: "The upper" MOF MODEL can describe the derived classes of these Model Element classes, including Model Element classes, including Model Element classes; " The upper "MOF MODEL can describe these packages such as MODEL, REFLECTIVE, PRIMTIVES, CORBAIDLTYPES, etc. of the lower MOF MODEL;" The upper layer "MOF MODEL can describe all the associations including generalized MOF MODEL ... more Simply put, it is: Mof Model contains a package called "Model". There are many classes in this package, which uses a tree called "Generalizes" as a tree, the root node is "Model Element" "This Class. The relationship between the element and the basic hierarchy is relative, and the relationship between the elementary hierarchy is similar to the basic hierarchy: the element-element level also functions as the internal variable component of the package element hierarchy. In this way, in the 4-layer structure, Mof Model is a metamodel's metamodes, including metamodel's metammodes, and corresponding MOF interfaces, providing a specific function module access, which is like previously mentioned persistence mentioned The components are the same. The model layer and the metamodel layer are also relative, any model layer, including the metamodel layer, and the last layer is called this level of Metamodel, and Mof Model is its own Metamodel. Mof Metamodels specifically refers to a meta-meta-element of the MOF interface.

In fact, the MOF metadata architecture is not fixed. Although there is a typical 4th floor, it is actually more, depending on how Mof is deployed. The MOF is deployed in the upper layer of Metamodel in the 4 layer structure above, which is purely to facilitate the relationship between the data and metadata. MOF can be used to describe any model layer to define consistent interfaces. Such as: MOF is used to define the unified interface of Model, enabling the client to access the model through the MOF interface; MOF is also used to define the unified interface of Metamodel, enabling the client to access metamodel via the MOF interface; actually uses MOF in the Model layer The MOF interface of Metamodel is obtained when an interface. That is, MOF can provide an interface for each element. In the MOF map discussed below, it is an example of the MOF deployment in the MetAmodel layer. Understand this, I understand what MOF is: define a unified interface for any model. "Any model" can be an information model, a meta model, and a MOF model itself. As shown below:

MOF provides a set of CORBA interfaces that use CORBA IDL to be defined, which is based on the interface between different models, enabling compatibility and visiting. The reason why CORBA IDL is used because object access is a more general access method, while CORBA provides a platform for object access; although MOF is modeling model, MetaObject is also objective, MOF is still object-oriented; In fact, not only MOF is object-oriented, and each element layer includes an information layer (INFORMATION) is an object-oriented; the IDL can be used to implement unbaffected object access. Since MOF has three metamodes; and in the narrative of different hierarchical nouns, some nouns are only distinguished by the version, such as the modeling structure in Mof Model (Construct [4]) Class And usually the difference between the Class in UML is just the first letter capital; at the same time, MOF uses UML to describe, and the element of the UML is not the modeling element of Mof Model, such as the generalization of the association in MOF; At the beginning, its norms and concepts look easily confused. However, with the familiarity of the specification, some rules are known, such as the noun in the first letters such as Class, Package, Association, etc., is a model of the last layer; MOF Metamodel represents the model of the MetAmodel layer that supports the MOF interface. The sequential reading specification will also note that it has been described in the use of some terms, and the proactive front and rear relationships are still close.

episode

The MOF architecture seems to be beautiful, it seems to surpass all modeling languages ​​and is a perfect form system. From a collection perspective, Mof Model Package is a collection: it is a collection of collections, that is, its elements are also collections, such as Class, Package, Association. Remove the "child" element from its element to make a new collection, this new collection is actually MOF. Just like a magician, shred a newspaper and burned it, then removed the little bit from the residual ashes, "" and revert it to the newspaper.

Later, I found that the study similar to MOF has been in other fields. I have been searching for "form system", "Yuan Mathematics" online, will search: Hilbert. D (Hilbert, David, 1862 ~ 1943) Founded in the 1920s. More step: If there is a day of form language to develop into a person's language and computer language to access each other, it is not a man who can generate a running program, just like movie "The Matrix": NEO and Trinity entered Matrix intended to rescue Morpheus. They stood in the system. Neo said: "Guns, Lots of Guns ...", many rows of firearms "唰唰唰" flying ... 胡思 想 想It's far away. However, recent Japanese invented a language translation system. It is said that it is not bad. It seems to be translated by the original "Oriental Express". I don't know if it and the MOF principle: first explain a text in a language. Modeling, then mapped into another text according to the form model of another language. About mapping us to see below.

MOF mapping

The MOF mapping is a process of re-implementing the semantics of MOF in an environment of a given implementation technology. A client can read a model instance in a model (such as a MODEL of Metadata layer), which Package instance, etc., which are read out after reading these elements, and Package instances in the Java model after reading these elements. Or the UML model, the interface and module instances in the IDL, or IDL. By mapping can be reconstituted by specific techniques described by MOF. The most important thing in the mapping is Abstract Mapping, which describes how to enable MOF Metamodel as an abstract information model (INFORMATION MODEL); how to use Metamodel constructs to spell the Metadata logical structure. Abstract mapping gives the semantics and rules of the mapping, all the reference and criteria for all MOF specific maps; any specific mapping If there is a violation of abstract mapping rules, it will not fully interoperate, such as models, and CORBA IDL mapping between. That is, the model that is not legally mapped and the model generated by the correct map cannot be fully interoperable.

Erupted an example of an illustrative of an image of the MOF mapping problem. In the MOF specification, there is an example below. This example is the mapping of MOF to IDL, which is the specification. About the figure need to be described: in the specification, the INFORMATION, MODEL, METAMODEL, MOF MODEL, respectively, respectively, respectively, respectively, respectively, respectively.

The leftmost left side of the figure is a M2 layer that describes the M1 layer model structure: package is a constructure of the M2 layer; P is an example of the package in the M1 layer; similar C and A are M1 layers Class example and an association Collection [5], C generates a self-association via A. If it is a Java model, the element in A is a link (LINK) can be implemented with Attribute, and Attribute is a type, so it is associated with C, we can draw a expanded picture:

So what is the meaning of the left figure is: the M1 layer has a package, there is a class in the package, and the class is connected by association. In order to achieve this concept model, through the rightmost way: a package factory creates a package instance P, a class agent in the package, class agent creates multiple class instances, allocated between class instances All stored in association Example Collection A. Directly understand the P corresponding to the Package and C in Java. The intermediate portion of the figure is five interfaces of the concept model to the result of the mapping, and accesses the specific IDL mapping model. And these five interfaces are also Mof Model's Interface! [6] Each interface of these five interfaces may more than one interface instance. For example, the interface of C, each of the C instances of the M1 layer corresponds to an interface, such as multiple interface instances such as ICLASS1, ICLASS2; P is also, may include iPackage1, iPackage2, iPackage3, etc. .

Model visit

Based on mapping, MOF and specific modeling techniques are combined, let's take a look at the MOF implementation structure. Each model (Model1 and Model2) in the figure provides a MOF interface, and the client program (including the MODEL to other Model, Model1 in the figure) is seen by MOF, and the MOF model of Model1 and Model2, not the specific technology. (Such as UML) special models. At this point, it can be seen that the MOF design idea is actually similar to CORBA. With such a platform, the ambassador level diplomacy can be established between the MOF model and the model. Not only is the MOF MODEL layer and the Model layer, but the Metamodel layer and the Metamodel layer can also be between the Model layer and the MetAmodel layer ... as long as the MOF specification can be visited. At the same time, because MOF is built on Corba, it also has a cross-language and cross-platform. Supplementary Description: Generally, the hierarchical system is not allowed to cross access, each layer can only be built on the layer below it, but the layered hierarchy system like MOF, the layer and the layers are allowed two-way dependencies [7].

end

Go back to this article. Our persistent framework is used in the domain model. In fact, the GUI model can also be persistent, just like many development systems, the user interface defined by the developer and its interface related data often requires persistence, such as Save in a certain format file or saved to the database. When the program compiles these data, then it is static to the executable; or the program is running again to read the data and then load it into the system. Like a method of domain design, we can use image modes to implement it. Of course, if you do this, because the image mode is still its shortcomings.

Highlights 1: Element Element and AOP

The application system uses the meta-metamorphic possibly known, and the function of the meta-element layer is a supplementary description, which is speculated that the speculation is not from known applications. Let's take an example: For example, in the Java environment, the meta-element can store the information of the method (INVOKE) to a "yuan-element object", when a proxy class calls the information of the information. Invoke () can be implemented by a meta-element component INVOKER. Invoker performs operation calls by reading the metadata. For example, the Yuan-Miki may record the log log when the method is called, and the Invoker will record each call to the log; the meta-element may also record the method call through a specific communication protocol, then INVOKER will use the protocol Implement this call. As a result, the metammine can affect the behavior of the entire model and information system. - See it, isn't this a AOP idea? ! At present, AOP Framework has also been implemented with dynamic agents. The above is shown below. In the figure, STOCKQUOTE is a class of a domain; ClassProxy implements a java.lang.Reflect.InvocationHandler interface. This picture is just a schematic, not a standard UML map.

Highlights 2: Cosmic Design Language

The MOF specification 1.2 Software Development Scenarios tells a case: use MOF to define a new modeling language, called the Universe Design Language (UDL: Universal Design Language). A software development system is built around the language. The software model established by the system implements interoperability through MOF ... For details, please refer to the original text. This case has a certain reference value for our constructing a suitable modeling language and approach based on specific areas and business.

[1] The book is the first edition. The second edition of the book made a revision, improved the original method, introduced the concept of Object-Relational (O-R) mapping. [2] Because the written book did not have POSA2 (Pattern-Oriented Software Architecture, Volume 2: Patterns for Concurrent and NetWorked Objects), so POSA is not POSA1. Posa2 is equally exciting, and the pattern language has been described in more detail, it is worth recommending.

[3] Mechanical Industry Press, the reason why the book is translated into a "image" may be because the class and its reflection are like the object in front of the mirror, like the mirror, and the like in the mirror, class Reflection is called "image". Reflection is the verb as a noun, which is called the active action itself, so the use of the name "image".

[4] Temporarhant is constructed because it is an expression unit that can be instanced, and the instantiated process is the process of constructing an object. "Construct" verbs are used as noun, or translated as constructors, structures, components, structures, and the like.

[5] Why is a MOF specification 5.2.1 Meta Object Type overview

[6] See the MOF Specification 3 MOF Model and Interfaces.

[7] See the Reflection section of POSA1.

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

New Post(0)