(2) From the Perspective of actual projects, the overall design of the MEF plug-in framework and the overall design of mef

Source: Internet
Author: User

(2) From the Perspective of actual projects, the overall design of the MEF plug-in framework and the overall design of mef
1. Introduction to the MEF framework

The full name of MEF is Managed Extensibility Framework (MEF), which is a part of. net4.0 and can also be used in 3.5. People familiar with the spring framework in java should be familiar with several concepts involved in this framework.

Here I will first give a rough description of some basic concepts in the MEF framework involved in a complete plug-in system built using MEF more than two years ago.

1.1 Dependency injection (export, import)

The MEF framework provides the import and export functions, namely, injection and export. In Spring, the concept of dependency injection is similar. After an object is instantiated, It is injected into the object dependent on this instance. This can reduce the coupling between classes. Similarly, similar to injection in spring, MEF also has the concept of Delayed Injection. Normal dependency injection is injected when the entire program starts to run, such delayed injection can be performed only when the object needs to be used.

1.2 Contracts)

Conventions are complementary to dependency injection. The biggest benefit of dependency injection is the decoupling between classes. But here we need to agree on the concept of injecting a class into another class. The class to be injected does not directly reference the class of the other party. Instead, the two use a common interface (or other interfaces such as classes). This interface is a convention, to export and inject data.

1.3 directory and component container (catalog, compositionContainer)

When we use spring, for different applications, we only need to start applicationContext or WebApplicationContext to load the configuration into the IOC container. According to XML configuration or annotation, class dependency injection can be implemented. In the MEF framework, this IOC container requires code for implementation, and the configuration is generally noted.

Two concepts are involved: catalog and compositionContainer. Catalog aggregates all classes that need to be assembled into the IOC container, and then puts the catalog into the componentContainer, so that our IOC container has all the classes that need to be controlled. However, after being put into the container, the container cannot be automatically injected with dependencies. It also requires operations such as ComposeExportedValue and SatisfyImportsOnce to complete the entire process of dependency injection.

1.4 MEF framework

 

2. System Design

Let me give a rough description of the project two years ago. This project is a fully automated project for image processing, which can be divided into automatic image reception, parallel preprocessing using Platform, and then Analysis and Processing of ice, drought, and flood on images using this Platform, after the product is generated, it is released and stored into the database. At that time, it was done by a number of universities and a single organization. I am only one of these participants, but I am not using the DLL language of envi for remote sensing to process images, nor are they using Platform for parallel computing, it is not the background for product release and warehouse receiving. I am mainly working on the following requirements.

2.1 Requirements

(1) present the original images received on a daily basis at the front-end, and display them in a reasonable and beautiful way.

(2) provides the image query function, including time space and other queries.

(3) download images.

(4) query logs.

(5) provides the server listening function.

(6) manage and display the manually processed results.

(7) provide metadata registration for the data processed manually.

(8) The automation module can be extracted into manual and auxiliary modules and can be integrated into the system.

2.2 Requirement Analysis

After reading the requirements, I felt that this system had to make a plug-in system, and finally I selected MEF. Since we have decided to build a plug-in system, we have to divide the requirements into one class, and which are the Host Program and which are the plug-ins. Obviously, from (1) to (6) in the requirement can be done in the Host Program. And (7) and (8) are separate plug-in modules, because the functions (7) and (8) are extracted from the automatic process, it is done by different people. Here I only need to provide their unified interface and the call method they need to make their own plug-ins. In addition, more automated processes may be extracted and made into plug-ins to facilitate expansion.

2.3 Technical Analysis

This section mainly addresses the technical requirements of plug-in systems.

(1) The plug-in can be inserted to the corresponding place, such as the toolbar or the selection bar on the left.

(2) click the button where the plug-in is located and the plug-in will pop up. Here we need the singleton mode.

(3) The plug-in can communicate with the host. For example, if the plug-in completes a function, you must notify the host that the function has been completed.

(4) The plug-in and plug-in should also be able to communicate. For example, after a plug-in completes a function, it can display the parameters on another plug-in.

3. Design Diagram of the plug-in framework

 

In the next section, I will first talk about the core part of the communication mechanism of the plug-in framework. Next, let's talk about the dependency injection and interface Implementation of the entire framework.


Who has Jiang potao's Design and Implementation of plug-in gis application framework-electronic version based on C # And ArcGIS Engine92,

It is outdated. Read the latest book. It is not easy to get started. It is not recommended to use it as a reference book.

A java web Framework for actual projects, such as SSH, SSI, SSH2, or SS + JDBC

Sent, to score !!




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.