当前位置:网站首页>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
边栏推荐
- JS music online playback plug-in vsplayaudio js
- Eight super classic pointer interview questions (3000 words in detail)
- mysqldump数据备份
- 出现Permission denied的解决办法(750权限谨慎使用)
- Differences and application scenarios between resulttype and resultmap
- Performance test method of bank core business system
- BUAA magpie nesting
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
- [slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
- 适合程序员学习的国外网站推荐
猜你喜欢
随机推荐
BUAA magpie nesting
Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
SWC介绍
深入探究指针及指针类型
遥感图像超分辨率论文推荐
Blue style mall website footer code
Cross origin cross domain request
Python implementation of maddpg - (1) openai maddpg environment configuration
11. Container with the most water
Idea push rejected solution
Map sorts according to the key value (ascending plus descending)
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
The solution of permission denied (750 permissions should be used with caution)
Yyds dry inventory what is test driven development
Overview of super-resolution reconstruction of remote sensing images
SD card reports an error "error -110 whilst initializing SD card
[concept] Web basic concept cognition
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
Lua uses require to load the shared library successfully, but the return is Boolean (always true)
出现Permission denied的解决办法(750权限谨慎使用)