Multi-host shared plug-in management and execution method, system, device and medium
By using global plugin service instances and an intelligent data merging engine, the problems of resource waste and data conflicts in the plugin system are solved, enabling plugin sharing across multiple hosts and consistency of data processing results, thereby improving system stability and resource utilization.
Patent Information
- Application Number
- CN202511555039.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2045-10-29
AI Technical Summary
Existing plugin systems suffer from resource waste and data conflicts in complex business scenarios, especially when multiple hosts need to share the same plugin, resulting in excessive memory consumption and inconsistent data processing results.
By employing a globally unique plugin service instance and a namespace-based plugin management mechanism, plugins can be shared as a singleton across multiple hosts. Furthermore, an intelligent data merging engine selects an appropriate merging strategy based on data type and business scenario to avoid data conflicts.
It effectively reduces memory usage, improves system resource utilization, ensures the consistency of data processing results and the correctness of business logic, and reduces development and maintenance costs.
Smart Images

Figure CN121029272B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, more particularly, to a multi-host shared plug-in management and execution method, system, device and medium. BACKGROUND
[0002] Currently, plug-in architecture as an effective means to improve the flexibility and scalability of software systems, has been widely used in modern web applications, client applications and other fields. Through plug-in, developers can modularize and plug-in non-core functions, thereby reducing the coupling degree between modules of the system, facilitating independent development, testing and deployment.
[0003] However, the existing plug-in system still has some problems in complex business scenarios. First, the problem of resource waste. In a complex application interface (such as a CRM system), there may be multiple functionally similar components (referred to as "hosts" herein), such as multiple forms, multiple lists, etc. If these hosts all need to use the same plug-in (such as a data validation plug-in, a formatting plug-in), the traditional implementation is to load and instantiate a copy of the plug-in for each host. When the number of hosts is large, a large number of duplicate plug-in instances will exist in memory, causing serious waste of memory and computing resources.
[0004] Second, the problem of data conflict and loss. When multiple plug-ins need to chain or cooperate to process the same data, the simple implementation is to let the plug-in executed later directly overwrite the processing result of the previous plug-in. This rough handling method will cause business logic errors or data loss in many scenarios. For example, one plug-in adds attribute A to the data object, and another plug-in adds attribute B. If the overwriting method is used, the final result will only retain the operation of the last plug-in, which obviously does not meet the expectations.
[0005] Therefore, how to provide a plug-in management and execution scheme that can realize plug-in sharing to save system resources and intelligently merge the processing results of multiple plug-ins to avoid data conflicts has become a technical problem that needs to be solved in the field. SUMMARY
[0006] The purpose of the present application is to provide a multi-host shared plug-in management and execution method, system, device and medium to solve the problem of resource waste caused by repeated instantiation of plug-ins and logic errors caused by data results being overwritten when multiple plug-ins cooperate as described in the background.
[0007] The first aspect of the present application discloses a multi-host shared plug-in management and execution method; the method comprises:
[0008] Step S1: In a host application, initialize a globally unique plug-in service instance for unified management of multiple host plug-ins in the host application;
[0009] Step S2: The plug-in service instance receives plug-in registration information, which includes an event name and a processing function corresponding to the event name;
[0010] Step S3: The plug-in service instance creates a plug-in management instance for each namespace in the event name, and registers the processing function in the plug-in management instance corresponding to the event name for caching, to realize sharing of plug-ins under the same namespace by multiple hosts;
[0011] Step S4: When any host triggers a target event through the plug-in service instance, the plug-in service instance locates the corresponding plug-in management instance according to the namespace of the target event, and obtains multiple processing functions associated with the target event from the plug-in management instance;
[0012] Step S5: The plug-in service instance executes the multiple processing functions and obtains multiple result data returned by the multiple processing functions respectively;
[0013] Step S6: The plug-in service instance calls a data merging engine, merges the multiple result data into a final result data according to a preset data merging strategy, and returns the final result data to the host triggering the target event.
[0014] Preferably, after step S4 and before step S5, the method further comprises:
[0015] Step S40: Filtering the multiple processing functions according to the identity of the host triggering the target event and the target host attribute configured for each of the multiple processing functions, to screen executable processing functions;
[0016] The target host attribute is used to specify which hosts can execute the processing function.
[0017] Preferably, in step S5, the manner of executing the multiple processing functions includes at least one of the following:
[0018] Synchronous execution mode: sequentially traversing and executing each processing function, and waiting for the execution of the current processing function to be completed before executing the next processing function;
[0019] Asynchronous execution mode: using an iterator and a Promise mechanism to execute each processing function in order, and waiting for the asynchronous logic inside the processing function to be completed before executing the next processing function;
[0020] Concurrent execution method: The Promise.allSettled mechanism is used to execute all processing functions simultaneously.
[0021] Preferably, in step S6, the data merging strategy includes:
[0022] When merging the previous result data returned by the previous processing function and the current result data returned by the current processing function, the data types of the current result data and the previous result data are first determined.
[0023] If the data types are different, the previous result data is directly replaced with the current result data;
[0024] If the data types are the same, the corresponding merge mode will be selected based on the data type for merging.
[0025] Preferably, when the data type is an object, the merging is performed using the extend mode, which involves: traversing the attributes of the current result data; if the same attribute exists in the preceding result data, the attribute value is recursively merged; if not, the attribute and its value are added to the preceding result data.
[0026] Preferably, when the data type is an array, the merging mode includes one of the following: replace, concat, or extend.
[0027] When the data type is a function, the merging pattern includes either replace or pipe pattern;
[0028] Specifically, the pipeline mode involves: creating a new pipeline event, registering the preceding result data and the current result data as the processing functions of the pipeline event, and generating a new merge function; when the merge function is called, the pipeline event is triggered through the plugin service instance, thereby executing the functions represented by the preceding result data and the current result data in sequence.
[0029] Preferably, the execution modes of the plugin include an event-driven Hook mode and a command-based call mode;
[0030] Commands in the Command mode are registered and managed through a dedicated command namespace and invoked through a dedicated command execution interface.
[0031] A second aspect of this invention discloses a plugin management and execution system for multi-host sharing; the system includes:
[0032] The plugin service module is configured to be initialized as a globally unique instance in the host application, and is used to uniformly manage plugins of multiple hosts within the host application;
[0033] The plugin registration management module, connected to the plugin service module, is used to receive plugin registration information containing event names and processing functions, create a plugin management instance based on the namespace in the event name, and register the processing function to the corresponding plugin management instance to achieve plugin sharing.
[0034] The plugin execution module is used to, upon receiving a target event triggered by the host, retrieve multiple associated processing functions from the plugin registration management module according to the namespace of the target event, and execute the multiple processing functions to obtain multiple result data.
[0035] The data merging engine module is used to merge the multiple result data into a final result data according to a preset data merging strategy after the plugin execution module has finished executing.
[0036] The plugin execution module is further configured to filter the multiple processing functions based on the host identity identifier of the triggering event and the target host attribute of the processing function before executing the processing function, and select the executable processing functions.
[0037] A third aspect of this invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of a multi-host shared plug-in management and execution method according to any one of the first aspects of this disclosure.
[0038] A fourth aspect of this invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a multi-host shared plug-in management and execution method according to any one of the first aspects of this disclosure.
[0039] According to the technical content disclosed in this invention, the following beneficial effects are achieved:
[0040] By establishing globally unique plugin service instances and a namespace-based plugin management mechanism, singleton sharing of plugins across multiple hosts is achieved, significantly reducing memory consumption and improving system resource utilization, especially in complex pages containing numerous repetitive components. Simultaneously, by introducing an intelligent data merging engine, when multiple plugins collaboratively process the same data, the system can automatically select the optimal merging strategy (such as expansion, joining, pipeline, etc.) based on data type and business scenario, rather than simply overwriting. This effectively avoids data conflicts and information loss, ensuring the correctness of business logic and the consistency of data processing results, significantly enhancing system stability and maintainability.
[0041] Other features and advantages of the invention will become clear from the following detailed description of exemplary embodiments of the invention with reference to the accompanying drawings. Attached Figure Description
[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the invention and, together with their description, serve to explain the principles of the invention.
[0043] Figure 1 This is a flowchart illustrating a multi-host shared plugin management and execution method according to an embodiment;
[0044] Figure 2 A flowchart illustrating the architecture and execution method of a multi-host shared plugin;
[0045] Figures 3a-3d A flowchart illustrating the operation process in a specific embodiment of the multi-host shared plugin architecture and execution method;
[0046] Figure 4 This is a structural diagram of a multi-host shared plug-in management and execution system according to an embodiment of the present invention;
[0047] Figure 5 This is a structural diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0048] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the invention.
[0049] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0050] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0051] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0052] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0053] Example 1:
[0054] This invention discloses a multi-host shared plugin management and execution method. This method is based on multi-host sharing and intelligent data merging, and aims to solve the problems of resource waste caused by repeated plugin instantiation and data overwriting when multiple plugins collaborate in the existing plugin architecture. Figure 1 A flowchart of a multi-homed shared plugin management and execution method according to an embodiment of the present invention is shown below. Figure 1 As shown, the method includes:
[0055] Step S1: In the host application, initialize a globally unique plugin service instance to uniformly manage multiple host plugins within the host application;
[0056] The host obtains plugin configuration information, including plugin name and plugin resource address, by requesting interfaces and reading configuration files, and then provides the plugin information to the plugin service instance.
[0057] Plugin service instances load plugin code asynchronously or synchronously by sending requests or reading plugin configuration information.
[0058] Step S2: The plugin service instance receives plugin registration information, which includes an event name and a processing function corresponding to the event name;
[0059] Step S3: The plugin service instance creates a plugin management instance for each namespace according to the namespace in the event name, and registers the processing function to the plugin management instance corresponding to the event name for caching, so as to realize the sharing of plugins under the same namespace by multiple hosts;
[0060] Step S4: When any host triggers a target event through the plugin service instance, the plugin service instance locates the corresponding plugin management instance according to the namespace of the target event, and obtains multiple processing functions associated with the target event from the plugin management instance;
[0061] After step S4 and before step S5, the following is also included:
[0062] Step S40: Based on the identity of the host that triggered the target event and the target host attributes configured in each of the multiple processing functions, filter the multiple processing functions to select executable processing functions;
[0063] The target host attribute is used to specify which hosts can execute the processing function.
[0064] Step S5: The plug-in service instance executes the multiple processing functions to obtain multiple result data returned by the multiple processing functions respectively;
[0065] In step S5, the execution of the multiple processing functions includes at least one of the following:
[0066] Synchronous execution method: Iterate through and execute each processing function in turn, and wait for the current processing function to finish executing before executing the next processing function;
[0067] Asynchronous execution method: Using iterators and Promise mechanisms, each processing function is executed sequentially, and the next processing function is executed only after the asynchronous logic inside the processing function has completed.
[0068] Concurrent execution method: The Promise.allSettled mechanism is used to execute all processing functions simultaneously.
[0069] Step S6: The plugin service instance calls the data merging engine, merges the multiple result data into a final result data according to the preset data merging strategy, and returns it to the host that triggered the target event.
[0070] In step S6, the data merging strategy includes:
[0071] When merging the previous result data returned by the previous processing function and the current result data returned by the current processing function, the data types of the current result data and the previous result data are first determined.
[0072] If the data types are different, the previous result data is directly replaced with the current result data;
[0073] If the data types are the same, the corresponding merge mode will be selected based on the data type for merging.
[0074] When the data type is an object, the merging is performed using the extend mode. Specifically, the attributes of the current result data are traversed. If the same attribute exists in the preceding result data, the attribute value is recursively merged. If it does not exist, the attribute and its value are added to the preceding result data.
[0075] When the data type is an array, the merging mode includes one of the following: replace, concat, or extend.
[0076] When the data type is a function, the merging pattern includes either replace or pipe pattern;
[0077] Specifically, the pipeline mode involves: creating a new pipeline event, registering the preceding result data and the current result data as the processing functions of the pipeline event, and generating a new merge function; when the merge function is called, the pipeline event is triggered through the plugin service instance, thereby executing the functions represented by the preceding result data and the current result data in sequence.
[0078] The execution modes of the plugin include event-driven Hook mode and command-based command mode.
[0079] Commands in the Command mode are registered and managed through a dedicated command namespace and invoked through a dedicated command execution interface.
[0080] In summary, the solution proposed in this invention can:
[0081] 1. Addressing resource waste: In existing plugin systems, each host object needs to maintain an independent plugin instance. In a complex CRM page, multiple form components may require the same data validation plugin, causing the same plugin to be loaded repeatedly, resulting in significant memory resource waste.
[0082] 2. Resolving data conflict issues: When multiple plugins process the same data, the traditional approach is for the later-executed plugin to directly overwrite the processing results of the earlier plugins, leading to data loss and business logic errors. This data conflict problem is particularly severe in complex business scenarios where multiple plugins need to work collaboratively.
[0083] 3. Reduce development complexity: Traditional plugin systems lack a unified management mechanism, requiring developers to handle complex issues such as plugin dependencies, execution order, and error handling. Furthermore, cross-platform development necessitates the repeated implementation of similar plugin logic.
[0084] 4. Improve system maintainability: As the number of plugins increases, the management complexity of the system grows exponentially, requiring a unified management architecture to simplify plugin registration, configuration, monitoring, and debugging.
[0085] 5. Singleton shared architecture: A global PluginService singleton was designed as the unified management center for all plugins. Plugins are grouped and managed according to business domains through a namespace mechanism, realizing plugin sharing between multiple hosts.
[0086] 6. Intelligent Data Merging: A data merging engine has been built that automatically selects the merging strategy based on the data type (object, array, string, function, etc.) and supports four merging modes: replace, concat, extend, and pipe, ensuring data integrity when multiple plugins work together.
[0087] 7. Support for multiple execution modes: It provides three execution modes: run() asynchronous execution, runSync() synchronous execution, and runFalls() concurrent execution, to adapt to the performance requirements of different business scenarios.
[0088] 8. Dual-track plugin mode: The system simultaneously supports both Hook mode and Command mode for plugin execution.
[0089] 9. Unified cross-platform adaptation: Through the adapter pattern, the same set of plugin code can run uniformly in multiple platform environments such as Web, H5, and mini-programs, without relying on the front-end framework.
[0090] 10. Fine-grained control mechanism: Supports plugin loading and execution based on conditions, dynamic enabling / disabling, and dynamic registration / removal.
[0091] Example 2:
[0092] According to Embodiment 1, a multi-host shared plugin management and execution method is provided, such as... Figures 3a-3d As shown, in some specific embodiments, the specific methods are as follows:
[0093] I. Multi-host shared plugin architecture and execution process
[0094] Reference Figure 2 The specific process of the plugin management and execution method in this embodiment of the invention is as follows:
[0095] Step S101: Start the host application and initialize the plugin service instance. When a web application or H5 application starts, the system first creates a globally unique plugin service instance (PluginService). This instance exists throughout the application's lifecycle, serving as the entry point and scheduling center for all plugin management.
[0096] Step S102: The plugin service instance receives plugin registrations. The host application obtains the plugin's configuration information through API requests, reading local configuration files, or dynamically loading scripts. This configuration information typically includes the plugin name, the resource address of the plugin code, and the events defined by the plugin. The plugin service instance loads the plugin code based on this information.
[0097] Step S103: Create management instances by namespace and cache processing functions. Once the plugin code loads successfully, its entry method is executed. The plugin declares the names of the events it listens for and their corresponding processing functions in its entry method. A key design feature of this invention is that the event names follow the format "namespace:event name", for example, "form-validator.check-required".
[0098] When a plugin service instance receives a registration request, it resolves the namespace (e.g., "form-validator") in the event name. If the plugin management instance (PluginManage) for that namespace does not yet exist, a new plugin management instance is created. Then, the event name and its corresponding handler function are cached as key-value pairs (e.g., {'check-required':[handler1,handler2,...]}) in the plugin management instance for that namespace. In this way, all plugin logic belonging to the "form-validator" namespace is centrally managed, and any host that needs to use form validation can invoke it through this shared management instance.
[0099] Step S104: Host triggers event. When a user interacts with the interface, or when the business process reaches a certain point, the host (such as a form component) needs to execute a plugin function. At this time, the host will call the execution method of the plugin service instance (such as run('form-validator.check-required', data)) and pass in the event name and the data to be processed.
[0100] Step S105: Locate the management instance and obtain the processing functions. After receiving the event, the plugin service instance parses the namespace in the event name again and immediately locates the plugin management instance created and cached in step S103. Then, from this management instance, it obtains a list of all registered processing functions based on the event name (e.g., "check-required").
[0101] In this step, an optional filtering mechanism can be introduced. When registering its handler function, the plugin can attach a `target` attribute to declare which hosts the handler function applies to. For example, `target:['form-A','form-B']` means it only applies to hosts with IDs 'form-A' and 'form-B', while `target:'*'` is a wildcard, applicable to all hosts. When a host triggers an event, it carries its own identity (e.g., `from:'form-A'`). The plugin service instance uses the host's identity to match the `target` attribute of the handler function, thereby filtering out the handler functions that can be executed by the current host.
[0102] Step S106: Execute the processing function. The plugin service instance will execute the list of executable processing functions selected in the previous step, using different modes according to different business requirements.
[0103] Synchronous execution (runSync): Iterates through the list of processing functions and executes them sequentially. The execution of a later function must wait for the previous function to complete. This mode is suitable for scenarios where the processing flow has strict dependencies.
[0104] Asynchronous execution (run): Also executes sequentially, but it utilizes iterators and Promises. When a processing function contains asynchronous operations (such as network requests), the system awaits the completion of that asynchronous operation before executing the next processing function. This guarantees the sequential nature of asynchronous tasks.
[0105] Concurrent execution (runFalls): Using Promise.allSettled, all processing functions are placed into the execution queue simultaneously for concurrent execution. This is suitable for scenarios where multiple processing functions have no dependencies and the highest execution efficiency is desired.
[0106] Step S107: Merge Result Data. After all processing functions have completed execution, the system will obtain a list of result data. At this point, the intelligent data merging engine is invoked to merge the data in this list. See Example 2 for detailed merging strategies.
[0107] Step S108: Return the final result. Return the merged final result data to the host that initially triggered the event.
[0108] II. Intelligent Data Merging Strategy
[0109] Reference Figure 2 When an event triggers multiple handler functions, the data merging engine's workflow is as follows:
[0110] Suppose the engine needs to merge the result returned by the previous processing function (PreviousResult, PR) and the result returned by the current processing function (CurrentResult, CR).
[0111] Step S201: Obtain the previous result PR and the current result CR. Initially, PR can be an empty value or a preset initial value.
[0112] Step S202: Determine if CR is undefined. If it is, it means the current processing function has not returned a valid result, so no operation is performed, and PR is simply retained. Otherwise, proceed to the next step.
[0113] Step S203: Determine whether the data types of PR and CR are the same.
[0114] If the data types are different (e.g., PR is an object, CR is an array), then a fundamental change in the data structure is considered to have occurred. In this case, the default strategy is to directly replace PR with CR. That is, proceed to step S204.
[0115] If the data types are the same, proceed to step S205 and select a refined merging mode based on the specific type.
[0116] Step S204: Return directly to CR.
[0117] Step S205: Select the merge mode according to the data type.
[0118] Both are of type Object: the default mode is "extend". The engine iterates through all properties of the CR. For each property K in the CR, it checks if it exists in the PR. If property K also exists in the PR, the merge logic is recursively called to merge the values of PR[K] and CR[K]. If property K does not exist in the PR, the property and its value are added directly to the PR. This ensures that the properties of the two objects are completely merged, rather than simply overwritten.
[0119] Both are of type Array: They support multiple modes, which developers can specify according to business needs. The default is "replace".
[0120] Replace mode: Directly replace PR with CR.
[0121] concat mode: appends all elements of the CR array to the end of the PR array.
[0122] Extend mode: This is a smarter index-based merging. If the length of CR is greater than that of PR, first extend the length of PR to be the same as that of CR. Then iterate through CR, and for each index I, if CR[I] is not undefined, overwrite the value of PR[I] with the value of CR[I]; otherwise, retain the original value of PR[I].
[0123] Both are of the Function type: support multiple modes, with "replace" as the default.
[0124] Replace mode: Directly replace PR (old function) with CR (new function).
[0125] Pipe Pattern: This is an innovative design. When two functions need to be chained together for execution, the engine registers both functions, PR and CR, under a new, temporary event with the PIPE namespace. It then generates and returns a new wrapper function, E. When external code calls function E, E's internal logic triggers this temporary PIPE event, thus executing PR and CR functions sequentially (synchronously, asynchronously, or concurrently). This achieves function-level chaining.
[0126] Step S206: Merging complete, return the merged PR. This process will continue until the results of all processing functions have been merged.
[0127] III. Dual-track plug-in mode
[0128] In addition to the event-driven Hook pattern mentioned above, this system also supports the command pattern.
[0129] Registration: Plugins can register a command and its handler function using the `registerCommand` method. Internally, the system automatically adds a special namespace, such as `COMMAND`, to all commands to distinguish them from Hook-based events.
[0130] Execution: The host can directly invoke a registered command using the executeCommand or executeCommandSync methods.
[0131] Management: The processing functions for both command mode and Hook mode share the same set of plugin instance management and caching logic, and are only distinguished by namespaces.
[0132] This dual-track design offers greater flexibility. The Hook pattern is suitable for decoupled, responsive scenarios, while the Command pattern is suitable for scenarios that require proactive and precise invocation of specific functions.
[0133] The core subject of this invention comprises three key technical elements:
[0134] Multi-host sharing: This refers to a situation where multiple business components (hosts) in an application system can share the same plugin instance, instead of each component loading and maintaining the plugin independently. This solves the resource waste problem caused by the repeated instantiation of the same plugin in traditional plugin systems.
[0135] Intelligent data merging: When multiple plugins process the same data, the system can automatically select an appropriate merging strategy (replace, concat, extend, pipe) based on the data type and business scenario to ensure the correctness and consistency of the data processing results.
[0136] Plugin Management and Execution System: This refers to a complete plugin-based architecture solution that includes full lifecycle management of plugins, such as registration, management, execution, and monitoring, and supports multiple execution modes and cross-platform deployment.
[0137] Multi-host shared architecture: Enables plugin sharing across multiple hosts, solving the fundamental problem of repeated plugin instantiation in traditional plugin systems, and significantly improving memory usage efficiency in complex pages containing multiple identical components.
[0138] Intelligent data merging engine: Based on data type, it employs intelligent merging strategies, supporting four merging modes: replace, concat, extend, and pipe, and automatically handles data conflicts; ensuring data integrity and consistency when multiple plugins work together.
[0139] Unified architecture with multiple execution modes: Integrates asynchronous, synchronous, and concurrent execution modes within the same framework. Technological breakthrough: The run(), runSync(), and runFalls() methods adapt to different performance requirements, allowing developers to choose the optimal execution method based on their business scenarios.
[0140] Dual-track command mode: The dual-track design, which runs in parallel with Hook mode and Command mode, supports both event-driven and command-driven plugin execution methods, providing a more flexible plugin invocation method to adapt to different business models.
[0141] Key architectural design features include automatic namespace management, automatic creation and management of PluginManage instances based on event names, a clear plugin grouping and isolation mechanism, and simplified plugin management complexity in complex systems.
[0142] Refined control mechanism:
[0143] The target filter supports both exact matching and wildcard matching;
[0144] The disabled configuration supports conditional plugin disabling;
[0145] The optional plugin mechanism provides more flexible plugin control.
[0146] Unified cross-platform adaptation: The same plugin code runs on multiple platforms such as Web, H5, and mini-programs, significantly reducing repetitive work in cross-platform development. Multiple loading methods are supported, including synchronous loading, asynchronous loading, CDN loading, and functional loading. Development and debugging support includes complete plugin lifecycle management, rich error handling, and logging, facilitating development, debugging, and problem localization.
[0147] High scalability: The plug-in system itself supports plug-in extensions, and the open architecture design facilitates feature enhancement and good backward compatibility.
[0148] In summary, this invention, through a series of designs including a multi-host shared architecture, an intelligent data merging engine, support for multiple execution modes, and a dual-track plug-in mode, constructs a highly efficient, stable, and scalable plug-in management and execution system. This system not only solves the resource waste and data conflict problems of traditional plug-in solutions but also significantly reduces the development and maintenance costs of complex applications.
[0149] Example 3:
[0150] This invention discloses a multi-host shared plugin management and execution system. The structural diagram of the plugin management and execution system is shown below. Figure 4 As shown, the system 100 includes:
[0151] The plugin service module 101 is configured to be initialized as a globally unique instance in the host application, and is used to uniformly manage plugins of multiple hosts within the host application;
[0152] The plugin registration management module 102 is connected to the plugin service module and is used to receive plugin registration information containing event names and processing functions, create a plugin management instance according to the namespace in the event name, and register the processing function to the corresponding plugin management instance to realize plugin sharing.
[0153] The plugin execution module 103 is used to, after receiving a target event triggered by the host, obtain multiple associated processing functions from the plugin registration management module according to the namespace of the target event, and execute the multiple processing functions to obtain multiple result data;
[0154] The data merging engine module 104 is used to merge the multiple result data into a final result data according to a preset data merging strategy after the plug-in execution module has finished executing.
[0155] The plugin execution module is further configured to filter the multiple processing functions based on the host identity identifier of the triggering event and the target host attribute of the processing function before executing the processing function, and select the executable processing functions.
[0156] Example 4:
[0157] This invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of a multi-host shared plug-in management and execution method according to any one of the embodiments of this invention.
[0158] Figure 5 This is a structural diagram of an electronic device according to an embodiment of the present invention, such as... Figure 5 As shown, the electronic device includes a processor, memory, communication interface, display screen, and input device connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, Near Field Communication (NFC), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input device can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the device's casing, or an external keyboard, touchpad, or mouse.
[0159] Those skilled in the art will understand that Figure 5 The structure shown is merely a structural diagram of the part related to the technical solution of this disclosure and does not constitute a limitation on the electronic device to which the solution of this application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0160] Example 5:
[0161] This invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a multi-host shared plug-in management and execution method according to any one of Embodiment 1 of this invention.
[0162] Please note that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. The above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
[0163] The embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing apparatus or for controlling the operation of a data processing apparatus. Alternatively or additionally, the program instructions may be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by the data processing apparatus. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
[0164] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0165] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.
[0166] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. Processors and memory may be supplemented by or incorporated into dedicated logic circuitry.
[0167] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0168] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0169] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0170] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
[0171] While specific embodiments of the invention have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.
Claims
1. A method for managing and executing plugins in a multi-host shared manner, characterized in that, The method includes: Step S1: In the host application, initialize a globally unique plugin service instance to uniformly manage multiple host plugins within the host application; Step S2: The plugin service instance receives plugin registration information, which includes an event name and a processing function corresponding to the event name; Step S3: The plugin service instance creates a plugin management instance for each namespace according to the namespace in the event name, and registers the processing function to the plugin management instance corresponding to the event name for caching, so as to realize the sharing of plugins under the same namespace by multiple hosts; Step S4: When any host triggers a target event through the plugin service instance, the plugin service instance locates the corresponding plugin management instance according to the namespace of the target event, and obtains multiple processing functions associated with the target event from the plugin management instance; Step S5: The plug-in service instance executes the multiple processing functions to obtain multiple result data returned by the multiple processing functions respectively; Step S6: The plugin service instance calls the data merging engine, merges the multiple result data into a final result data according to the preset data merging strategy, and returns it to the host that triggered the target event; The data merging strategy includes: When merging the previous result data returned by the previous processing function and the current result data returned by the current processing function, the data types of the current result data and the previous result data are first determined. If the data types are different, the previous result data is directly replaced with the current result data; If the data types are the same, the corresponding merge mode will be selected based on the data type for merging.
2. The multi-host shared plugin management and execution method according to claim 1, characterized in that, After step S4 and before step S5, the following is also included: Step S40: Based on the identity of the host that triggered the target event and the target host attributes configured in each of the multiple processing functions, filter the multiple processing functions to select executable processing functions; The target host attribute is used to specify which hosts can execute the plurality of processing functions.
3. The multi-host shared plugin management and execution method according to claim 1, characterized in that, In step S5, the execution of the plurality of processing functions includes at least one of the following: Synchronous execution method: Iterate through and execute each processing function in turn, and wait for the current processing function to finish executing before executing the next processing function; Asynchronous execution method: Using iterators and Promise mechanisms, each processing function is executed sequentially, and the next processing function is executed only after the asynchronous logic inside the processing function has completed. Concurrent execution method: The Promise.allSettled mechanism is used to execute all processing functions simultaneously.
4. The multi-host shared plugin management and execution method according to claim 1, characterized in that, When the data type is an object, the merging is performed using the extended mode, which involves: traversing the attributes of the current result data; if the same attribute exists in the preceding result data, the attribute value is recursively merged; if not, the attribute and its value are added to the preceding result data.
5. The multi-host shared plugin management and execution method according to claim 1, characterized in that, When the data type is an array, the merging mode includes one of the replacement, concatenation, or expansion modes; When the data type is a function type, the merging mode includes replacement or pipeline mode; Specifically, the pipeline mode involves: creating a new pipeline event, registering the preceding result data and the current result data as the processing function of the pipeline event, and generating a new merge function; when the merge function is called, the pipeline event is triggered through the plugin service instance, thereby executing the functions represented by the preceding result data and the current result data in sequence.
6. The multi-host shared plugin management and execution method according to claim 1, characterized in that, The plugin's execution modes include an event-driven Hook mode and a command-based call mode; Commands in the Command mode are registered and managed through a command namespace and invoked through a command execution interface.
7. A plugin management and execution system for multi-host sharing, said system employing the method described in any one of claims 1-6, characterized in that, The system includes: The plugin service module is configured to be initialized as a globally unique instance in the host application, and is used to uniformly manage plugins of multiple hosts within the host application; The plugin registration management module, connected to the plugin service module, is used to receive plugin registration information containing event names and processing functions, create a plugin management instance based on the namespace in the event name, and register the processing function to the corresponding plugin management instance to achieve plugin sharing. The plugin execution module is used to, upon receiving a target event triggered by the host, retrieve multiple associated processing functions from the plugin registration management module according to the namespace of the target event, and execute the multiple processing functions to obtain multiple result data. The data merging engine module is used to merge the multiple result data into a final result data according to a preset data merging strategy after the plugin execution module has finished executing.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the multi-host shared plug-in management and execution method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the multi-host shared plug-in management and execution method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Dynamic management system and method for C++ application program version
CN102073520A
Easily-extensible data sharing system and method based on data sharing plug-in
CN115237631A