Plug-in, application program implementation method and system, computer system and storage medium

By splitting the classes, C libraries and resources that are publicly dependent on by multiple plug-ins in Android applications into independent public plug-ins and loading them only when business plug-ins are needed, the problems of resource redundancy and huge application size in the existing technology are solved, and the effect of reducing application size and resource consumption is achieved.

CN111427579BActive Publication Date: 2025-03-18BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910022287.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-01-09
Publication Date
2025-03-18
Estimated Expiration
2039-01-09

AI Technical Summary

Technical Problem

When existing Android applications use plug-in technology, multiple plug-ins may publicly rely on the same classes, C libraries and resources, resulting in these resources being redundantly packaged in the host program, increasing the application's size and resource consumption.

Method used

Split the classes, C libraries and resources used by multiple plug-ins that may be publicly dependent on are split from the host program, develop them into independent public plug-ins, and load them only when the application's business plug-ins publicly depend on these public plug-ins, otherwise they will not be loaded.

Benefits of technology

Through this method, the application size is reduced, the number of methods and resource consumption is reduced, and the application performance and efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111427579B_ABST
    Figure CN111427579B_ABST
Patent Text Reader

Abstract

The present disclosure provides a plug-in implementation method, including: obtaining the source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins for common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by the host program of the target application when implementing the target application; and compiling the source code and outputting the common plug-in and the corresponding AAR package, wherein the AAR package is used to provide the dependency relationship between the business plug-in and the common plug-in when compiling multiple business plug-ins. The present disclosure also discloses an application implementation method, a plug-in implementation system, an application implementation system, a computer system, and a computer-readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a plug-in, an application implementation method and system, a computer system, and a storage medium. Background Art

[0002] Android plug-in technology is relatively mature at present. Through the plug-in framework, plug-in programs (referred to as plug-ins) are dynamically loaded, which can decouple the business logic of the application, reduce the number of application methods and resource consumption, and reduce the size of the application.

[0003] However, in the process of implementing the embodiments of the present disclosure, the inventors found that: in existing applications using Android plug-in technology, multiple plug-ins may have common dependencies on the same classes, C libraries, and resources, and each plug-in may repeatedly reference the same classes, C libraries, and resources multiple times. Usually, these classes, C libraries, and resources that may be used by common dependencies or repeatedly referenced will be packaged in the public library part of the host program of the application (also called the host project). However, if some classes, C libraries, and resources in the host program are not referenced by any plug-in of the application at all, these classes, C libraries, and resources are redundant to the host program. Summary of the invention

[0004] In view of this, the present disclosure provides a plug-in, an application implementation method and system, a computer system, and a storage medium.

[0005] One aspect of the present disclosure provides a plug-in implementation method, including: obtaining source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application; and compiling the source code and outputting the common plug-in and a corresponding AAR package, wherein the AAR package is used to provide a dependency relationship between the business plug-in and the common plug-in when compiling the multiple business plug-ins.

[0006] According to an embodiment of the present disclosure, the method also includes: obtaining corresponding source code for each of the multiple business plug-ins; compiling the corresponding source code and outputting the corresponding business plug-in; and in the process of compiling the corresponding source code, adding the dependency relationship to the configuration file of the corresponding business plug-in based on the AAR package.

[0007] According to an embodiment of the present disclosure, the common plug-in can also be reused within each business plug-in; the method also includes: for a business plug-in that needs to reuse the common plug-in within the plug-in, during the process of compiling the source code of the business plug-in, based on the number of times the AAR package and the common plug-in are repeatedly referenced, adding the dependency relationship to the configuration file of the business plug-in.

[0008] One aspect of the present disclosure provides an application implementation method, including: obtaining multiple business plug-ins and common plug-ins for implementing the application, wherein the common plug-in can be used by at least two common dependencies of the multiple business plug-ins or can be reused within a plug-in by at least one of the multiple business plug-ins; obtaining a host program for implementing the application; starting the multiple business plug-ins using the host program; and in the process of starting the multiple business plug-ins, loading the common plug-in according to a predetermined loading logic.

[0009] According to an embodiment of the present disclosure, in the process of starting the multiple business plug-ins, the common plug-in is loaded according to a predetermined loading logic, including: for each of the multiple business plug-ins, during the startup process, checking whether there is a dependency relationship between the corresponding business plug-in and the common plug-in; and if so, loading the common plug-in.

[0010] According to an embodiment of the present disclosure, the application includes a loading object; the method further includes: loading the loading object through a loader of a business plug-in; or loading the loading object through a loader of a common plug-in; or loading the loading object through a loader of a host program.

[0011] According to an embodiment of the present disclosure, the loading object includes at least one of the following: a class, a C library, and a resource.

[0012] Another aspect of the present disclosure provides a plug-in implementation system, including: a first acquisition module, used to acquire source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application; and a first compilation module, used to compile the source code and output the common plug-in and a corresponding AAR package, wherein the AAR package is used to provide a dependency relationship between the business plug-in and the common plug-in when compiling the multiple business plug-ins.

[0013] According to an embodiment of the present disclosure, the system also includes: a second acquisition module, used to acquire the corresponding source code for each of the multiple business plug-ins; a second compilation module, used to compile the corresponding source code and output the corresponding business plug-in; and a first adding module, used to add the dependency relationship to the configuration file of the corresponding business plug-in based on the AAR package during the process of compiling the corresponding source code.

[0014] According to an embodiment of the present disclosure, the common plug-in can also be reused within each business plug-in; the system also includes: a second adding module, which is used to add the dependency relationship to the configuration file of the business plug-in based on the number of times the AAR package and the common plug-in are repeatedly referenced during the process of compiling the source code of the business plug-in for the business plug-in that needs to reuse the common plug-in within the plug-in.

[0015] Another aspect of the present disclosure provides an application implementation system, including: a third acquisition module, used to acquire multiple business plug-ins and common plug-ins for implementing the application, wherein the common plug-in can be used by at least two common dependencies of the multiple business plug-ins or can be reused within the plug-in by at least one of the multiple business plug-ins; a fourth acquisition module, used to acquire a host program for implementing the application; a startup module, used to start the multiple business plug-ins using the host program; and a first loading module, used to load the common plug-in according to a predetermined loading logic during the process of starting the multiple business plug-ins.

[0016] According to an embodiment of the present disclosure, the first loading module includes: a checking unit, used to check whether there is a dependency relationship between the corresponding business plug-in and the common plug-in during the startup process for each of the multiple business plug-ins; and a loading unit, used to load the common plug-in when the dependency relationship exists.

[0017] According to an embodiment of the present disclosure, the application includes a loading object; the system also includes a second loading module, which is used to: load the loading object through a loader of a business plug-in; or load the loading object through a loader of a common plug-in; or load the loading object through a loader of a host program.

[0018] According to an embodiment of the present disclosure, the loading object includes at least one of the following: a class, a C library, and a resource.

[0019] Another aspect of the present disclosure provides a computer system, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0020] Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the above method when executed.

[0021] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and the instructions are used to implement the method described above when executed.

[0022] According to the embodiments of the present disclosure, because the classes, C libraries and resources that may be commonly used by multiple plug-ins are split out from the host program, developed into independent public plug-ins, and loaded only when the business plug-ins of the application program commonly depend on certain public plug-ins, otherwise they are not loaded. Therefore, the technical means are at least partially overcome that for the application program, there is no distinction between business plug-ins and public plug-ins in the related art, only between plug-ins and host programs, resulting in classes, C libraries and resources that are not commonly used by any plug-in in the application program are also pre-packaged in the public library of the host program, resulting in defects such as large application size, large number of methods, and serious resource consumption, thereby achieving the technical effect of reducing the size of the application program and reducing the number of methods and resource consumption of the application program. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0024] Figure 1 Schematically illustrates an exemplary system architecture to which the plug-in, application program implementation method and system of the present disclosure can be applied;

[0025] Figure 2 A flowchart of a plug-in implementation method according to an embodiment of the present disclosure is schematically shown;

[0026] Figure 3 The following schematically shows a plug-in implementation principle diagram according to an embodiment of the present disclosure;

[0027] Figure 4 A schematic diagram of a plug-in implementation principle according to another embodiment of the present disclosure is shown;

[0028] Figure 5 A flowchart schematically shows a method for implementing an application program according to an embodiment of the present disclosure;

[0029] Figure 6 A flowchart of running an application according to an embodiment of the present disclosure is schematically shown;

[0030] Figure 7 A block diagram of a plug-in implementation system according to an embodiment of the present disclosure is schematically shown;

[0031] Figure 8 A block diagram schematically shows an application implementation system according to an embodiment of the present disclosure; and

[0032] Fig. 9 A block diagram of a computer system suitable for implementing plug-ins and applications according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0033] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0034] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0035] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0036] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0037] The embodiments of the present disclosure provide a plug-in, an application implementation method, a plug-in and an application implementation system that can reduce the size of an application, reduce the number of application methods and resource consumption, and decouple the business logic of an application. The plug-in implementation method includes obtaining the source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by the host program of the target application when implementing the target application; and compiling the source code and outputting the common plug-in and the corresponding AAR package, wherein the AAR package is used to provide the dependency relationship between the business plug-in and the common plug-in when compiling multiple business plug-ins.

[0038] Figure 1 The following schematically shows an exemplary system architecture to which the plug-in, application program implementation method and system of the present disclosure can be applied. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0039] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0040] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).

[0041] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0042] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0043] It should be noted that the plug-in and application implementation provided by the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the plug-in and application system provided by the embodiment of the present disclosure can generally be set in the server 105. The plug-in and application method provided by the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and / or the server 105. Correspondingly, the plug-in and application system provided by the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal device 101, 102, 103 and / or the server 105. Alternatively, the plug-in and application method provided by the embodiment of the present disclosure can also be executed by the terminal device 101, 102, or 103, or can also be executed by other terminal devices different from the terminal device 101, 102, or 103. Accordingly, the plug-in and application system provided by the embodiments of the present disclosure may also be set in the terminal device 101 , 102 , or 103 , or in other terminal devices different from the terminal device 101 , 102 , or 103 .

[0044] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0045] In addition, the embodiments of the present disclosure can be applied to applications with the following characteristics: that is, the application contains multiple plug-ins, and at least two of these plug-ins use certain classes, C libraries, and resources in common dependency. In this case, using the technical solution provided by the embodiments of the present disclosure, it is no longer necessary to pre-package these classes, C libraries, and resources used by common dependencies in the host program of the application, but these classes, C libraries, and resources can be developed separately into corresponding public plug-ins for use. In this way, the application can load and use the corresponding public plug-in only during the running stage, thereby reducing the number of methods and resource consumption of the application, and reducing the size of the application, so that the business logic of the application is decoupled to a greater extent.

[0046] Among them, the embodiment of the present disclosure mainly improves the host program part of the application in the related technology. Specifically, all the classes, C libraries and resources in the common library of the host program that are commonly used by multiple plug-ins of the application are separated from the host program, and the original multiple plug-ins are used as multiple business plug-ins. At the same time, according to the common dependency relationship of multiple business plug-ins on these classes, C libraries and resources, multiple public plug-ins are developed for loading when the application is running, and when developing the business plug-in, the corresponding dependency relationship is added to its configuration file, so that the corresponding public plug-in can be loaded when the host program starts the business plug-in.

[0047] It should be noted that in the present disclosure, the implementation and use of each plug-in includes the following stages: plug-in source code integration stage, plug-in source code compilation stage, and application running stage using common plug-ins and business plug-ins.

[0048] Figure 2 The flowchart of the plug-in implementation method according to the embodiment of the present disclosure is schematically shown.

[0049] like Figure 2 As shown, the method includes operations S210 to S220.

[0050] In operation S210, source code of a common plug-in is obtained, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application.

[0051] It should be noted that a common plug-in can be a class, C library or resource that can be commonly relied upon by business plug-ins. For example, class 1, C library 1, and resource 1 are often commonly relied upon by business plug-ins A, B, and C. In this case, a section of common plug-in source code can be written for class 1, another section of common plug-in source code can be written for C library 1, and another section of common plug-in source code can be written for resource 1. Each section of source code can be compiled to generate a common plug-in.

[0052] Based on the above example, for an application, assume that it contains business plug-ins A, B, and D~G, among which business plug-ins A and B commonly depend on class 1, C library 1, and resource 1, and business plug-ins D~G do not commonly depend on any class, C library, or resource. In this case, when implementing the application, not only business plug-ins A, B, and D~G need to be loaded, but also the public plug-in corresponding to class 1, the public plug-in corresponding to C library 1, and the public plug-in corresponding to resource 1 will be loaded according to the dependency relationship between business plug-ins A and B on class 1, C library 1, and resource 1.

[0053] In operation S220 , source code is compiled and a common plug-in and a corresponding AAR package are output, wherein the AAR package is used to provide a dependency relationship between a service plug-in and a common plug-in when compiling multiple service plug-ins.

[0054] In the disclosed embodiment, compiling the source code of a common plug-in can generate two products at the same time, one is the corresponding common plug-in, and the other is an AAR package associated with the common plug-in. Among them, the AAR package is essentially an Android archive file, which is mainly used to provide the dependency relationship between the business plug-in and the common plug-in when compiling related business plug-ins. For example, assuming that in a certain application, business plug-in A needs to rely on common plug-in 1, and AAR package 1 is generated at the same time when compiling and generating common plug-in 1. In this case, in the process of compiling the source code of business plug-in A to generate business plug-in A, the dependency relationship between business plug-in A and common plug-in 1 can be added to the configuration file of business plug-in A based on AAR package 1.

[0055] Specifically, the development of a public plug-in can be generally divided into two stages, namely, the public plug-in source code integration stage and the public plug-in source code compilation stage.

[0056] Among them, in the embodiment of the present disclosure, the purpose of developing a common plug-in is to separate the classes, C libraries and resources that are only used by multiple plug-ins for common dependency from the host program and develop and run them separately as plug-ins.

[0057] Through the disclosed embodiment, during the compilation period of the public plug-in, two products are generated by compiling the source code, namely, the public plug-in and the AAR package associated with the public plug-in. The public plug-in is provided to the host program for loading and integration, and the AAR package is provided to other business plug-ins for compilation, that is, the business plug-in saves the dependency relationship with the corresponding public plug-in when compiling. In this way, during the application runtime, the classes, C libraries and resources of the public plug-in can be loaded and used through the dependency relationship.

[0058] It can be seen that the embodiments of the present disclosure adopt a technical means of splitting the classes, C libraries and resources that may be commonly relied on by multiple plug-ins from the host program, developing them into independent public plug-ins, and loading them only when the business plug-ins of the application program commonly depend on certain public plug-ins, otherwise they are not loaded. Therefore, it at least partially overcomes the problem that in the related art, for the application program, no business plug-ins and public plug-ins are distinguished, only plug-ins and host programs are distinguished, resulting in classes, C libraries and resources that are not commonly relied on by any plug-in in the application program are also pre-packaged in the public library of the host program, resulting in defects such as large application size, large number of methods, and serious resource consumption, thereby achieving the technical effect of reducing the size of the application program and reducing the number of methods and resource consumption of the application program.

[0059] Reference below Figure 3 and Figure 4 , combined with specific embodiments Figure 2 The method shown is further explained.

[0060] As an optional embodiment, the method may also include: obtaining the corresponding source code for each of multiple business plug-ins; compiling the corresponding source code and outputting the corresponding business plug-in; and in the process of compiling the corresponding source code, adding a dependency relationship to the configuration file of the corresponding business plug-in based on the AAR package.

[0061] Similar to the aforementioned process of implementing a public plug-in, the implementation of a business plug-in is also divided into two stages, namely the business plug-in source code integration stage and the business plug-in source code compilation stage. Unlike the public plug-in source code compilation stage, compiling the business plug-in source code only produces one product, the business plug-in code. In addition, if a business plug-in has a dependency relationship with one or several public plug-ins, then when compiling the business plug-in, it is necessary to add the dependency relationship between the business plug-in and this or these public plug-ins in its configuration file based on the corresponding AAR package. Of course, if a business plug-in has no dependency relationship with any public plug-in, that is, it does not need to rely on any public classes, C libraries and resources, then when compiling the business plug-in, it is sufficient to directly compile the source code to generate the business plug-in, and there is no need to add any dependencies in its configuration file.

[0062] Specifically, in the disclosed embodiment, adding the dependency relationship with the public plug-in in the configuration file can be achieved by adding a meta tag in AndroidManifest.xml to save the dependency relationship. Of course, the disclosed embodiment can also save the dependency relationship through a json file or other methods.

[0063] In addition, in the embodiments of the present disclosure, the service plug-in can be compiled by a plug-in compilation tool, and different plug-in solutions can use different compilation tools, which are not limited here.

[0064] In addition, it should be noted that in the disclosed embodiment, after directly compiling the public plug-in source code and generating an AAR package, the AAR package can be uploaded to a Maven private server / warehouse for use in compiling business plug-ins. Of course, the storage method of the AAR package includes but is not limited to uploading a Maven private server / warehouse.

[0065] Through the embodiments of the present disclosure, in order to facilitate runtime loading, the dependency relationship between the service plug-in and the public plug-in may be added to the configuration file of the service plug-in.

[0066] Figure 3 A plug-in implementation principle is provided, that is, in an application, business plug-in 1 and business plug-in 2 are commonly dependent on public plug-in 1, and AAR package 1 is an AAR package generated simultaneously when compiling public plug-in 1, then the implementation principles of business plug-in 1 and business plug-in 2 are shown in the figure.

[0067] As an optional embodiment, the common plug-in may also be reused within each business plug-in. Correspondingly, the method may also include: for a business plug-in that needs to reuse the common plug-in within the plug-in, during the process of compiling the source code of the business plug-in, based on the number of times the AAR package and the common plug-in are repeatedly referenced, adding a dependency relationship to the configuration file of the business plug-in.

[0068] In the embodiments of the present disclosure, the common plug-in can be a class, C library, and resource commonly used by multiple business plug-ins, or a common class, C library, and resource repeatedly referenced by each business plug-in. Both the former and the latter can be separated from the host program to reduce the size, number of methods, and resource consumption of the application.

[0069] Figure 4 Another plug-in implementation principle is provided, that is, in an application, business plug-in 1 repeatedly references public plug-in 1 twice, and AAR package 1 is an AAR package generated simultaneously when compiling public plug-in 1, then the implementation principle of business plug-in 1 is shown in the figure.

[0070] Through the embodiments of the present disclosure, classes, C libraries and resources repeatedly referenced within a single business plug-in can also be separated from the common library of the host program and developed into a common plug-in for loading when the application is running. This can greatly reduce the size of the application, the number of methods and resource consumption.

[0071] Figure 5 The flowchart of the application implementation method according to the embodiment of the present disclosure is schematically shown.

[0072] like Figure 5 As shown, the method includes operations S510 to S540.

[0073] In operation S510, a plurality of business plug-ins and common plug-ins for implementing an application are acquired, wherein the common plug-in can be used by at least two common dependencies of the plurality of business plug-ins or can be reused within the plug-in by at least one of the plurality of business plug-ins.

[0074] It should be noted that the business plug-ins and public plug-ins mentioned in the embodiments of the present disclosure can be implemented through the solutions provided in the above embodiments, which will not be described in detail here.

[0075] In the embodiment of the present disclosure, for an application, it is assumed that the application contains business plug-ins A, B, C and D~G, among which business plug-ins A and B both have common dependencies on class 1, C library 1 and resource 1, business plug-in C repeatedly references class 2, C library 2 and resource 2, and business plug-ins D~G do not have common dependencies and do not repeatedly reference any class, C library or resource. In this case, when implementing the application, it is necessary not only to load business plug-ins A, B, C and D~G, but also to load the common plug-in corresponding to class 1, the common plug-in corresponding to C library 1 and the common plug-in corresponding to resource 1 according to the dependency relationship between business plug-ins A and B on class 1, C library 1 and resource 1, and to load the common plug-in corresponding to class 2, the common plug-in corresponding to C library 2 and the common plug-in corresponding to resource 2 according to the dependency relationship between business plug-in C on class 2, C library 2 and resource 2.

[0076] In operation S520, a host program for implementing an application program is acquired.

[0077] The host program of the application can load both the business plug-ins of the application and the public plug-ins of the application.

[0078] In operation S530, a plurality of service plug-ins are started using a host program.

[0079] In operation S540, in the process of starting multiple service plug-ins, a common plug-in is loaded according to a predetermined loading logic.

[0080] During the running phase of the host program, how to load and use public plug-ins is the work of the plug-in framework. Figure 6 , explains how to use public plug-ins by looking up the process of a class.

[0081] When the host program wants to start a business plug-in and load a class, if the class loader inside the business plug-in can find the class, the loading is successful, and then continue to find the next class until the end. If the loading fails, proceed to the next step, that is, to find out whether there is a public plug-in.

[0082] Specifically, when the class loader of the business plug-in cannot find a class, it can parse the AndroidManifest.xml of the business plug-in to find out whether the business plug-in depends on the public plug-in. If it does, the plug-in framework will first load the public plug-in, and then use the class loader of the public plug-in to find out whether the class exists. If it exists, the loading is successful, and the search continues until the next class ends. If it does not exist, the loading fails, and the host program's class loader is used to continue the search.

[0083] Similarly, the host program's class loader continues to search for the existence of the class. If it exists, the loading is successful, and the next class is searched until the end. If it is still unsuccessful, the class is considered to have failed to load and an exception is thrown.

[0084] It can be seen that during the running stage of the host program, the classes, C libraries and resources of the public plug-in need to be loaded and used through the dependency relationship between the business plug-in and the public plug-in.

[0085] In addition, during the application running phase, the order of checking classes / C libraries / resources includes but is not limited to the order shown in the above exemplary scheme, and the search logic can be adjusted accordingly according to different dependencies.

[0086] Through the embodiments of the present disclosure, an improved application implementation solution is provided on the basis of the common plug-in and business plug-in implementation solutions, by splitting the classes, C libraries and resources that are only commonly used among multiple business plug-ins and / or the classes, C libraries and resources that are only repeatedly referenced within each business plug-in from the host program to form one or more common plug-ins, which are dynamically loaded, so that multiple business plug-ins can be prevented from repeatedly referencing related classes, C libraries and resources, and the number of methods and resource consumption of the host program can be further reduced, code redundancy can be reduced, the size of the application can be reduced, and the installation and startup of the application can be accelerated.

[0087] As an optional embodiment, in the process of starting multiple business plug-ins, a common plug-in is loaded according to a predetermined loading logic, including: for each of the multiple business plug-ins, during the startup process, checking whether there is a dependency relationship between the corresponding business plug-in and the common plug-in; and if so, loading the common plug-in.

[0088] Specifically, when each service plug-in is started, the AndroidManifest.xml of the service plug-in can be parsed to find out whether the service plug-in depends on the public plug-in. If it depends on the public plug-in, the plug-in framework can be used to load the public plug-in first. If it does not exist, there is no need to load it.

[0089] Through the embodiments of the present disclosure, when an application is running, only public plug-ins that have dependencies on the business plug-ins of the application are loaded, and those without dependencies are not loaded, which can reduce the number of methods and resource consumption of the application and reduce the size of the application.

[0090] As an optional embodiment, the application includes a loading object; the method may also include: loading the loading object through a loader of a business plug-in; or loading the loading object through a loader of a common plug-in; or loading the loading object through a loader of a host program.

[0091] As an optional embodiment, the loading object includes at least one of the following: a class, a C library, and a resource.

[0092] In the embodiment of the present disclosure, if the loading object is commonly dependent on or repeatedly referenced by the service plug-in, it can be loaded through the loader of the common plug-in, otherwise it can be loaded through the loader of the service plug-in or the host program.

[0093] Figure 7 The block diagram of a plug-in implementation system according to an embodiment of the present disclosure is schematically shown.

[0094] like Figure 7 As shown, the plug-in implementation system 700 includes a first acquisition module 710 and a first compilation module 720 .

[0095] A first acquisition module 710 is used to acquire source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application; and

[0096] The first compiling module 720 is used to compile source code and output a common plug-in and a corresponding AAR package, wherein the AAR package is used to provide a dependency relationship between a service plug-in and a common plug-in when compiling multiple service plug-ins.

[0097] Through the embodiments of the present disclosure, because the classes, C libraries and resources that may be commonly used by multiple plug-ins are separated from the host program, developed into independent public plug-ins, and loaded only when the business plug-ins of the application program commonly depend on certain public plug-ins, otherwise they are not loaded. Therefore, the technical means of not distinguishing between business plug-ins and public plug-ins, but only between plug-ins and host programs, is at least partially overcome in the related art that for applications, there is no distinction between business plug-ins and public plug-ins, and only between plug-ins and host programs, resulting in classes, C libraries and resources that are not commonly used by any plug-in in the application program are also pre-packaged in the public library of the host program, resulting in defects such as large application size, large number of methods, and serious resource consumption, thereby achieving the technical effect of reducing the size of the application and reducing the number of methods and resource consumption of the application.

[0098] As an optional embodiment, the system also includes: a second acquisition module, used to obtain the corresponding source code for each of the multiple business plug-ins; a second compilation module, used to compile the corresponding source code and output the corresponding business plug-in; and a first adding module, used to add dependencies to the configuration file of the corresponding business plug-in based on the AAR package during the process of compiling the corresponding source code.

[0099] Through the embodiments of the present disclosure, in order to facilitate runtime loading, the dependency relationship between the service plug-in and the public plug-in may be added to the configuration file of the service plug-in.

[0100] As an optional embodiment, the common plug-in can also be reused within each business plug-in; the system also includes: a second adding module, which is used to add a dependency relationship in the configuration file of the business plug-in based on the number of times the AAR package and the common plug-in are repeatedly referenced during the process of compiling the source code of the business plug-in for the business plug-in that needs to reuse the common plug-in within the plug-in.

[0101] Through the embodiments of the present disclosure, classes, C libraries and resources repeatedly referenced within a single business plug-in can also be separated from the common library of the host program and developed into a common plug-in for loading when the application is running. This can greatly reduce the size of the application, the number of methods and resource consumption.

[0102] Figure 8 The block diagram of the application program implementation system according to the embodiment of the present disclosure is schematically shown.

[0103] like Figure 8 As shown, the application implementation system 800 includes a third acquisition module 810 , a fourth acquisition module 820 , a startup module 830 and a first loading module 840 .

[0104] A third acquisition module 810 is used to acquire multiple business plug-ins and common plug-ins for implementing an application, wherein the common plug-in can be used by at least two common dependencies of the multiple business plug-ins or can be reused by at least one of the multiple business plug-ins within the plug-in;

[0105] A fourth acquisition module 820 is used to acquire a host program for implementing the application program;

[0106] A startup module 830 is used to start multiple service plug-ins using a host program; and

[0107] The first loading module 840 is used to load a common plug-in according to a predetermined loading logic during the process of starting multiple service plug-ins.

[0108] Through the disclosed embodiments, an improved application implementation scheme is provided based on the common plug-in and business plug-in implementation scheme. By separating the classes, C libraries and resources that are only commonly used between multiple business plug-ins and / or the classes, C libraries and resources that are only repeatedly referenced within each business plug-in from the host program, one or more common plug-ins are formed and dynamically loaded, so that multiple business plug-ins can be prevented from repeatedly referencing related classes, C libraries and resources, and the number of methods and resource consumption of the host program can be further reduced, code redundancy can be reduced, the size of the application can be reduced, and the installation and startup of the application can be accelerated.

[0109] As an optional embodiment, the first loading module includes: a checking unit, used to check whether there is a dependency relationship between the corresponding business plug-in and the common plug-in during the startup process for each of the multiple business plug-ins; and a loading unit, used to load the common plug-in if there is a dependency relationship.

[0110] Through the embodiments of the present disclosure, when an application is running, only public plug-ins that have dependencies on the business plug-ins of the application are loaded, and those without dependencies are not loaded, which can reduce the number of methods and resource consumption of the application and reduce the size of the application.

[0111] As an optional embodiment, the application includes a loading object; the system also includes a second loading module, which is used to: load the loading object through the loader of the business plug-in; or load the loading object through the loader of the public plug-in; or load the loading object through the loader of the host program.

[0112] As an optional embodiment, the loading object includes at least one of the following: a class, a C library, and a resource.

[0113] According to the modules and units of the embodiments of the present disclosure, any multiple or at least part of the functions of any multiple thereof can be implemented in one module. According to the modules and units of the embodiments of the present disclosure, any one or more can be split into multiple modules for implementation. According to the modules and units of the embodiments of the present disclosure, any one or more can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, according to the modules and units of the embodiments of the present disclosure, one or more can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0114] For example, any multiple of the first acquisition module 710 and the first compilation module 720 can be combined in one module / unit / sub-unit for implementation, or any one of the modules / units / sub-units can be split into multiple modules / units / sub-units. Alternatively, at least part of the functions of one or more of these modules / units / sub-units can be combined with at least part of the functions of other modules / units / sub-units and implemented in one module / unit / sub-unit. According to an embodiment of the present disclosure, at least one of the first acquisition module 710 and the first compilation module 720 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the first acquisition module 710 and the first compilation module 720 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0115] It should be noted that the system implementation methods in the embodiments of the present disclosure are the same or similar to the method implementation methods in the embodiments of the present disclosure. For the description of the system implementation methods, please refer to the description of the method implementation methods, which will not be repeated here.

[0116] Fig. 9 A block diagram of a computer system suitable for implementing plug-ins and applications according to an embodiment of the present disclosure is schematically shown. Fig. 9 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0117] like Fig. 9 As shown, the computer system 900 according to the embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage part 908 to the random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.

[0118] In RAM 903, various programs and data required for the operation of system 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other through bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0119] According to an embodiment of the present disclosure, the system 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The system 900 may further include one or more of the following components connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0120] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0121] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0122] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0123] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 902 and / or the RAM 903 described above and / or one or more memories other than the ROM 902 and the RAM 903 .

[0124] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0125] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0126] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A plug-in implementation method, comprising: Obtaining source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application; and The source code is compiled and the common plug-in and a corresponding AAR package are output, wherein the AAR package is used to provide a dependency relationship between the service plug-in and the common plug-in when the plurality of service plug-ins are compiled.

2. The method according to claim 1, wherein: The method further comprises: For each of the plurality of service plug-ins, obtaining a corresponding source code; Compiling the corresponding source code and outputting the corresponding service plug-in; and In the process of compiling the corresponding source code, the dependency relationship is added to the configuration file of the corresponding service plug-in based on the AAR package.

3. The method according to claim 1 or 2, wherein: The common plug-in can also be reused internally by each business plug-in; The method further comprises: For a business plug-in that needs to reuse the common plug-in within the plug-in, during the process of compiling the source code of the business plug-in, based on the number of times the AAR package and the common plug-in are repeatedly referenced, the dependency relationship is added to the configuration file of the business plug-in.

4. A method for implementing an application, comprising: Acquire multiple business plug-ins and common plug-ins for implementing the application, wherein the common plug-in can be used by at least two common dependencies of the multiple business plug-ins or can be reused within a plug-in by at least one of the multiple business plug-ins; Obtain a host program for implementing an application; Using the host program to start the multiple service plug-ins; and In the process of starting the multiple service plug-ins, loading the common plug-in according to a predetermined loading logic; The step of loading the common plug-in according to a predetermined loading logic includes: Checking the dependency relationship between the service plug-in and the common plug-in; In the case where the dependency relationship exists between the service plug-in and the common plug-in, the common plug-in is loaded.

5. The method according to claim 4, wherein: The step of loading the common plug-in according to a predetermined loading logic during the process of starting the plurality of service plug-ins includes: For each of the plurality of service plug-ins, during the startup process, checking whether the corresponding service plug-in has a dependency relationship with the common plug-in; and If it exists, the common plugin is loaded.

6. The method according to claim 4, wherein: The application includes a loading object; The method further comprises: Load the loading object through a loader of a service plug-in; or Load the loading object through a loader of a public plug-in; or The load object is loaded through the loader of the host program.

7. The method according to claim 6, wherein: The loading object includes at least one of the following: a class, a C library, and a resource.

8. A plug-in implementation system, comprising: A first acquisition module is used to acquire source code of a common plug-in, wherein the common plug-in can be used by multiple business plug-ins as a common dependency, and at least two of the multiple business plug-ins and the common plug-in can be used to implement a target application and can be loaded by a host program of the target application when implementing the target application; and The first compiling module is used to compile the source code and output the common plug-in and a corresponding AAR package, wherein the AAR package is used to provide a dependency relationship between the service plug-in and the common plug-in when compiling the multiple service plug-ins.

9. The system according to claim 8, wherein: The system further comprises: A second acquisition module, configured to acquire a corresponding source code for each of the plurality of service plug-ins; A second compiling module, used to compile the corresponding source code and output a corresponding service plug-in; and The first adding module is used to add the dependency relationship to the configuration file of the corresponding business plug-in based on the AAR package during the process of compiling the corresponding source code.

10. The system according to claim 8 or 9, wherein: The common plug-in can also be reused internally by each business plug-in; The system further comprises: The second adding module is used to add the dependency relationship in the configuration file of the business plug-in based on the number of times the AAR package and the common plug-in are repeatedly referenced during the process of compiling the source code of the business plug-in for the business plug-in that needs to reuse the common plug-in within the plug-in.

11. An application implementation system, comprising: A third acquisition module, configured to acquire a plurality of service plug-ins and a common plug-in for implementing the application, wherein the common plug-in can be used by at least two common dependencies of the plurality of service plug-ins or can be reused within a plug-in by at least one of the plurality of service plug-ins; A fourth acquisition module, used to acquire a host program for implementing the application program; A startup module, used to start the multiple service plug-ins using the host program; and A first loading module, configured to load the common plug-in according to a predetermined loading logic during the process of starting the multiple service plug-ins; The step of loading the common plug-in according to a predetermined loading logic includes: Checking the dependency relationship between the service plug-in and the common plug-in; In the case where the dependency relationship exists between the service plug-in and the common plug-in, the common plug-in is loaded.

12. The system according to claim 11, wherein: The first loading module includes: a checking unit, configured to check, for each of the plurality of service plug-ins, whether a dependency relationship exists between the corresponding service plug-in and the common plug-in during startup; and The loading unit is used to load the common plug-in when the dependency relationship exists.

13. The system of claim 11, wherein: The application includes a loading object; The system further comprises a second loading module, configured to: Load the loading object through a loader of a service plug-in; or Load the loading object through a loader of a public plug-in; or The load object is loaded through the loader of the host program.

14. The system according to claim 13, wherein: The loading object includes at least one of the following: a class, a C library, and a resource.

15. A computer system comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

16. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Program updating method and device ad program operation method and device

    CN107273142A

  • Application program update method based on common plug-in, electronic equipment and storage medium

    CN108037941A