当前位置:网站首页>Microkernel structure understanding
Microkernel structure understanding
2022-07-06 03:36:00 【m0_ sixty million seven hundred and twenty-five thousand two hu】
Catalog
The basic structure
Microkernel architecture consists of two types of components : The core system (core system) And plug-in modules (plug-in modules). The core system is responsible for general functions unrelated to specific business functions , For example, module loading 、 Inter module communication, etc ; The plug-in module is responsible for implementing specific business logic .
The architectural essence of microkernel is Encapsulate the changes in the plug-in , So as to achieve the purpose of rapid and flexible expansion , Without affecting the stability of the overall system .
Key points of design
The key technologies of the core system design of microkernel are : Plug-in management 、 Plug in connection and plug-in communication
Plug-in management
The core system needs to know which plug-ins are currently available , How to load these plug-ins , When to load the plug-in . The common implementation method is the plug-in registry mechanism , The core system provides plug-in registry ( It can be a configuration file , It can also be code , It can also be a database ), The plug-in registry contains information about each plug-in module , Including its name 、 Location 、 Loading time ( Start loading , Load on demand ) etc. .
The plug-in connection
Generally speaking , The core system must formulate the connection specifications between plug-ins and core systems , Then the plug-in is implemented according to the specification , The core system can be loaded according to the specification .
Common connection mechanisms are OSGi(Eclipse Use )、 Message schema 、 Dependency injection (Spring Use ), Even using distributed protocols is possible , such as RPC perhaps HTTP Web The way .
Plug in communication
Plug ins are completely decoupled when designing , But in the process of actual business operation , There will be a business process that requires the cooperation of multiple plug-ins , So the core system needs to provide plug-in communication mechanism .
OSGI
OSGi Is a plug-in standard , Instead of a working framework ,Eclipse Adopted OSGi The framework is called Equinox, Similar implementations include Apache Of Felix、Spring Of Spring DM.

Plug-in management
The module layer implements the plug-in management function .OSGi in , The plug-in is called Bundle, Every Bundle It's a Java Of JAR file , Every Bundle It contains a metadata file MANIFEST.MF, This file contains Bundle Basic information of .
Such as ,Bundle The name of 、 describe 、 developers 、classpath, And the packages that need to be imported and exported ,OSGi The core system will load this information into the system for subsequent use :
// MANIFEST.MF
Bundle-ManifestVersion: 2
Bundle-Name:UserRegister
Bundle-SymbolicName: com.test.userregister
Bundle-Version: 1.0
Bundle-Activator: com.test.UserRegisterActivator
Import-Package: org.log4j;version="2.0",
.....
Export-Package: com.test.userregister;version="1.0",
The plug-in connection
The life cycle layer implements the plug-in connection function , Provides execution time module management 、 Module to the bottom OSGi Framework access . The lifecycle layer precisely defines Bundle Life cycle operations ( install 、 to update 、 start-up 、 stop it 、 uninstall ),Bundle Each operation must be implemented according to the specification .
public class UserRegisterActivator implements BundleActivator {
public void start(BundleContext context) {
UserRegister.instance = new UserRegister ();
}
public void stop(BundleContext context) {
UserRegister.instance = null;
}
}
Plug in communication
The service layer realizes the function of plug-in communication .OSGi It provides a function of service registration , It is used by plug-ins to register the services they can provide to OSGi Core service registry , If a service wants to use other services , Then you can search the available service centers directly in the service registry .
// Registration service
public class UserRegisterActivator implements BundleActivator {
// stay start() of use BundleContext.registerService() Registration service
public void start(BundleContext context) {
context.registerService(UserRegister.class.getName(), new UserRegisterImpl(), null);
}
// No need to stop() Log out of service , because Bundle When it stops, it will automatically log out of the Bundle Registered services in
public void stop(BundleContext context) {
}
}
// Retrieval service
public class Client implements BundleActivator {
public void start(BundleContext context) {
// 1. Retrieve indirect from the service registry “ The service reference ”
ServiceReference ref = context.getServiceReference(UserRegister.class.getName());
// 2. Use “ The service reference ” To access the instance of the service object
((UserRegister) context.getService(ref)).register();
}
public void stop(BundleContext context) {
}
}
The service registration here is not the plug-in registration in the plug-in management function , In fact, it is the mechanism of communication between plug-ins .
Rules engine
The rule engine also belongs to a specific implementation of micro kernel architecture from the perspective of structure , The execution engine can be regarded as a microkernel , The execution engine parses the configured business flow , Implement the conditions and rules , In this way to support the flexibility of the business .
The rule engine is charging 、 insurance 、 Promotion and other business areas are widely used .
Open source JBoss Drools
Compare the design key points of micro kernel architecture :
Plug-in management
The rules in the rule engine are the plug-ins of the microkernel architecture , The engine is the kernel of the microkernel architecture . Rules can be loaded and executed by the engine . Rule engine architecture , Rules are generally saved in the rule base , A database is usually used to store .
The plug-in connection
The rule engine specifies the language of rule development , Business people need to write rule files based on rule language , Then the rule engine loads and executes the rule file to complete the business function , therefore , The plug-in connection implementation mechanism of rule engine is actually rule language .
Plug in communication
The rules of the rule engine communicate with each other through data flow and event flow , Because a single rule does not need to rely on other rules , Therefore, there is no active communication between rules , Rules only need to output data or events , The engine passes data or events to the next rule .
-------- source 《 Geek course 》∙ Study summary
边栏推荐
- Pytorch load data
- NR modulation 1
- Precautions for single chip microcomputer anti reverse connection circuit
- Getting started with applet cloud development - getting user search content
- Differences and application scenarios between resulttype and resultmap
- Erreur de la carte SD "erreur - 110 whilst initialisation de la carte SD
- Leetcode problem solving -- 99 Restore binary search tree
- Idea push rejected solution
- [concept] Web basic concept cognition
- Image super resolution using deep revolutionary networks (srcnn) interpretation and Implementation
猜你喜欢

Research on cooperative control of industrial robots

canvas切积木小游戏代码

Crazy, thousands of netizens are exploding the company's salary

pytorch加载数据

MySQL Server层四个日志

Performance analysis of user login TPS low and CPU full

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Brush questions in summer -day3
![[risc-v] external interrupt](/img/9d/eb1c27e14045d9f1f690f4a7f5c596.jpg)
[risc-v] external interrupt

Schnuka: 3D vision detection application industry machine vision 3D detection
随机推荐
Esbuild & SWC: a new generation of construction tools
Edcircles: a real time circle detector with a false detection control translation
Python implementation of maddpg - (1) openai maddpg environment configuration
JS Vanke banner rotation chart JS special effect
BUAA喜鹊筑巢
Shell 传递参数
SD card reports an error "error -110 whilst initializing SD card
Eight super classic pointer interview questions (3000 words in detail)
BUAA magpie nesting
Quartz misfire missed and compensated execution
适合程序员学习的国外网站推荐
EDCircles: A real-time circle detector with a false detection control 翻译
JS音乐在线播放插件vsPlayAudio.js
These are not very good
指针笔试题~走近大厂
How to write compile scripts compatible with arm and x86 (Makefile, cmakelists.txt, shell script)
1.16 - 校验码
Pelosi: Congress will soon have legislation against members' stock speculation
Erreur de la carte SD "erreur - 110 whilst initialisation de la carte SD
施努卡:视觉定位系统 视觉定位系统的工作原理