Dynamic component loading method and system based on plug-in mechanism

A dynamic loading and component technology, applied in the direction of program loading/starting, program control devices, etc., can solve the problems of memory consumption, heavy maintenance workload of middleware or application software, and limitation of general-purpose software, and achieve the effect of improving versatility

Inactive Publication Date: 2015-03-18
INST OF ACOUSTICS CHINESE ACAD OF SCI +1
3 Cites 41 Cited by

AI-Extracted Technical Summary

Problems solved by technology

In an embedded system, there are many business forms of the system. The functions of middleware or application programs are different in different forms, and the components to be loaded are also different. In the prior art, components must be linked when compiling, so for the same middleware Or application programs, it is necessary to link different components for each business form of the system and generate different versions. Using this method makes the subsequent software maintenance workload of middleware or application programs heavy
In addition, embedded systems have ve...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Method used

The interface described in the embodiment of the present invention is the NPAPI interface of standard plug-in, does not link assembly when compiling, does not load unnecessary assembly when application program starts, has saved memory, has avoided the embedded system for different business forms Generate different versions of the applicat...
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Abstract

The invention relates to a dynamic component loading method and system based on a plug-in mechanism. The method comprises the following steps that after an application program or component receives instructions requiring the calling of corresponding functions in other components, the other components are found, the other components provide a standard plug-in interface, and the unique MIME type for identifying the identity is realized; after the components are found, the components are loaded into a memory, an interface for creating the component instance is obtained, and the corresponding function interface of the components is called; when the corresponding functions are not needed, a component unloading interface is called, and the other components are unloaded. The interface adopted in the embodiment of the invention is a standard plug-in interface, the assembly is not linked during the compiling, unnecessary components are not loaded during the application program starting, the memory is saved, and the generation of application programs in different versions by aiming at embedded systems in different service forms is avoided.

Application Domain

Technology Topic

Image

  • Dynamic component loading method and system based on plug-in mechanism
  • Dynamic component loading method and system based on plug-in mechanism

Examples

  • Experimental program(2)

Example Embodiment

[0064] Example 1:
[0065] The embodiment of the present invention includes the following steps:
[0066] Step 1. Configure each component with a "MIME Type" that can uniquely identify its identity.
[0067] Step 2: When the application or other component receives the instruction to call the corresponding function of the other component, it searches for the component by traversing the feature interface of each component library under the designated directory in the system; the traversal means is not restricted in order.
[0068] Step 3. If the component exists, load the component into the memory, obtain the component instance, and call the standard NPAPI interface of the plug-in of the packaged component;
[0069] Step 4. When exiting the corresponding function module, uninstall the component and release the memory.
[0070] Among them, the "MIME Type" that uniquely identifies the component can use the following methods:
[0071] Set the "MIME Type" that uniquely identifies the component to application/x-component name.
[0072] According to the characteristics of the embedded system, the embodiments of the present invention load components only in systems with component functions and when starting component functions, which prevents applications from generating different versions for systems with different business forms, and reduces the loading of components during application startup. Consumed memory.

Example Embodiment

[0073] Example 2
[0074] The method of the embodiment of the present invention will be further described below through a preferred embodiment:
[0075] figure 1 It is a schematic diagram of the process of dynamically searching and loading components in an embedded browser according to an embodiment of the present invention. Take the embedded browser as the specific application. Current web pages have become the mainstream portal navigation in embedded systems due to their cross-platform and easy deployment. Embedded browsers are the core of web page resolution. Different business systems have different requirements and need to load different component functions, such as dual-mode Set-top boxes need to use DVB component library, but Internet set-top boxes do not need DVB component library. Through the method of the embodiment of the present invention, the embedded browser can dynamically discover and load local functional components, without compiling different versions for different business systems, and load the components only when the corresponding function is started.
[0076] The feature interface of the component creation instance in this example is the NPP_New() interface function in the called plug-in standard NPAPI, and the feature interface of the cancelled instance is the NPP_New() interface function in the called plug-in standard NPAPI. In addition, the functional interfaces of the components are all C++ classes, so a base class corresponding to the component interface needs to be defined between the browser and the component library, so that the component C++ instance object can be obtained after the component is loaded and its methods can be used.
[0077] In addition, the system of this example can be based on the Linux operating system, the components are compiled into a dynamic library (.so), and the browser uses the Linux system functions dlopen, dlclose, and dlsym to open and close the component library and execute the component’s interface, which can specifically include the following steps :
[0078] The browser defines a base class, and the methods in the base class correspond to the component interface one by one;
[0079] The component inherits the base class provided by the browser, realizes its derived class, and then uses the plug-in standard NPAPI interface function to encapsulate the component library and compile it into a dynamic library;
[0080] In a system with this component function, add the path of the component library to the configuration file;
[0081] When the page is parsed and the functional interface of the component needs to be called, the browser reads the library directory path in the configuration file, traverses the library under this path, and finds the corresponding component library through the component feature interface "MIME Type". If there is no such interface Returns an error;
[0082] If there is a component library corresponding to the component name, call Dlopen to open the component library corresponding to the component object, and then use the dlsym function to find the NP-initialize() function in the library to call, and call the np-initialize() function to obtain the NPP -new() address, and then call NPP-new() to create an instance.
[0083] Then directly call the method of the component object instance through the method name to realize the corresponding function;
[0084] When leaving the page, call the plug-in standard NPAPI interface function NPP_Destroy to destroy the component object instance, and then call the plug-in standard NPAPI interface function NPP_Shutdown to close the component library.
[0085] In order to show the method of the embodiment of the present invention more clearly, figure 2 A schematic diagram of a method for loading embedded system components in an embodiment of the present invention is shown. From figure 2 It can be seen that the method includes: when the application or component receives the corresponding function instruction in the other component encapsulated by the standard plug-in NPAPI, it searches for the other component, and the other component has a "MIME Type" that uniquely identifies its identity ; After finding the component, load the component into the memory, and obtain the interface for creating the component instance and call the corresponding function interface of the component; when the corresponding function is not needed, call the uninstall component interface To uninstall the other components.
[0086] Preferably, the searching for other components is specifically: traversing the feature interfaces of each component library in the system to find the other components; before loading the other components, the application or component will first obtain all the other components existing on the platform. Component type, save the path and name of the other components, and then when parsing the webpage and encounter the specified plug-in, it will traverse the "MIME Type" value of each component library in the system to find and specify the "MIME Type" of the other components ”The component library with the same value, and then load the correct other components.
[0087] Preferably, the other components are not loaded when the application or component is started.
[0088] Preferably, the application program does not link the other components during the compilation phase.
[0089] Preferably, the other component has a "MIME Type" that uniquely identifies its identity, specifically: different other components have different "MIME Type" types, which is a unique identifier that represents the other component itself. The application or component uses this type of identification to identify a specific plug-in, and then calls the API functions of the other components.
[0090] The interface described in the embodiment of the present invention is the NPAPI interface of a standard plug-in. Components are not linked during compilation, and unnecessary components are not loaded when the application is started. This saves memory and avoids generating different versions for embedded systems of different business forms. s application.
[0091] In a word, the embodiment of the present invention proposes a method for dynamically loading components based on a plug-in mechanism. Aiming at the characteristics of embedded systems, components can only be discovered and loaded in systems with component functions and when component functions are activated, without linking components during compilation. There is no need to compile and generate different versions of the component for different business form systems.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Similar technology patents

Classification and recommendation of technical efficacy words

Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products