Plug-in processing method, device, equipment and storage medium
By generating plug-in interfaces, the plug-in dependency problem in the cross-platform mobile application development framework is solved, the development flexibility and user experience are improved, and the plug-in coupling is reduced.
Patent Information
- Application Number
- CN202010899236.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-31
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2040-11-19
AI Technical Summary
The interdependence between plug-ins in the cross-platform mobile application development framework is high, which affects the flexibility of front-end development, resulting in high development costs and poor user experience.
By obtaining the plug-in reference information of the development project and the preset plug-in container, determine the first plug-in referenced by the development project and the second plug-in it depends on. If the development project does not reference the second plug-in, the second plug-in will be generated in the development project. The plug-in interface allows users to write the function implementation of the second plug-in by themselves, reducing the coupling between plug-ins.
Improves the flexibility of plug-in reference and the flexibility of front-end development, reduces the dependence on plug-in developers that specifies dependencies on plug-ins, and improves the user experience.
Smart Images

Figure CN112052051B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of plug-in technology, and in particular to a plug-in processing method, apparatus, device, and storage medium. Background Art
[0002] The diversity of operating systems and mobile terminals requires project developers to develop and maintain the same product on different platforms. Using different development languages to develop and adapt the same product on different operating systems results in very high development costs. Therefore, in the field of front-end development technology, cross-platform mobile application development frameworks have emerged, such as the Flutter framework and the React Native framework.
[0003] Cross-platform mobile application development frameworks need the underlying capabilities provided by native operating systems (such as Android systems) to implement some functions, such as data persistence, message push, and camera hardware calls. Usually, cross-platform mobile application development frameworks implement the underlying capabilities of native operating systems by calling plug-ins pre-developed by developers.
[0004] However, when plug-ins are introduced into a cross-platform mobile application development framework, different plug-ins may be interdependent. For example, the plug-in that implements the message push function depends on the plug-in that implements the user login function, and the plug-in that implements the user login function needs to depend on the plug-in that obtains device information. The degree of interdependence between plug-ins is high, which affects the flexibility of front-end development. Summary of the invention
[0005] Embodiments of the present disclosure provide a plug-in processing method, apparatus, device, and storage medium to solve the problem that the high degree of mutual dependence between plug-ins affects the flexibility of front-end development.
[0006] In a first aspect, an embodiment of the present disclosure provides a plug-in processing method, including:
[0007] Get plugin reference information for development projects;
[0008] Determining, according to the plug-in reference information and a preset plug-in container, a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends;
[0009] If the development project does not reference the second plug-in, a corresponding plug-in interface is generated for the second plug-in in the development project.
[0010] In a second aspect, an embodiment of the present disclosure provides a plug-in processing device, including:
[0011] The acquisition module is used to obtain the plug-in reference information of the development project;
[0012] A determination module, configured to determine a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends, according to the plug-in reference information and a preset plug-in container;
[0013] A generation module is used to generate a corresponding plug-in interface for the second plug-in in the development project if the development project does not reference the second plug-in.
[0014] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0015] Memory and processor;
[0016] The memory is used to store program instructions;
[0017] The processor is used to call the program instructions in the memory to execute the method as described in the first aspect above.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed, the method described in the first aspect above is implemented.
[0019] In a fifth aspect, an embodiment of the present disclosure provides a program product comprising instructions, wherein the program product comprises a computer program, and when the computer program is executed by a processor, the method as described in the first aspect is implemented.
[0020] The plug-in processing method, apparatus, device and storage medium provided by the embodiments of the present disclosure determine the first plug-in referenced by the development project and the second plug-in on which the first plug-in depends through the plug-in reference information of the development project and the preset plug-in container, and if the development project does not reference the second plug-in, the interface of the second plug-in is generated in the development project. Therefore, by generating a plug-in interface for the second plug-in that is not referenced by the development project but is dependent on by the first plug-in, the user can write the second plug-in according to the generated plug-in interface of the second plug-in without forcing the user to reference the specified second plug-in in the development project, thereby reducing the coupling between plug-ins, improving the flexibility of plug-in references during the development process, and improving the user experience.
[0021] Various feasible embodiments of the present disclosure and their technical advantages are described in detail below. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0023] Figure 1 An example diagram of plugin dependency provided for an embodiment of the present disclosure;
[0024] Figure 2 An example diagram of a network architecture applicable to the plug-in processing method provided in an embodiment of the present disclosure;
[0025] Figure 3 A flowchart of a plug-in processing method provided by an embodiment of the present disclosure;
[0026] Figure 4 A flowchart of a plug-in processing method provided by another embodiment of the present disclosure;
[0027] Figure 5 A flowchart of a plug-in processing method provided by another embodiment of the present disclosure;
[0028] Figure 6 An example diagram of the architecture of a plug-in container provided for an embodiment of the present disclosure;
[0029] Figure 7 A schematic diagram of the structure of a plug-in processing device provided in an embodiment of the present disclosure;
[0030] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure;
[0031] Fig. 9 A block diagram of a plug-in processing device provided by an embodiment of the present disclosure.
[0032] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0034] First, the nouns involved in the embodiments of the present disclosure are explained:
[0035] Plug-in: A program written and encapsulated by plug-in developers in a programming language that can achieve certain functions. A plug-in includes a plug-in interface and a function implementation. The plug-in interface is used to provide an interface for calling the plug-in and to describe the functions that the plug-in can achieve. The function implementation is used to specifically implement the functions of the plug-in.
[0036] When implementing some functions such as data persistence, message push, and camera hardware calls, cross-platform mobile application development frameworks (such as the Flutter framework and the React Native framework) used for front-end development need to call pre-developed plug-ins to call the underlying capabilities of the original operating system (such as the Android system). When referencing pre-developed plug-ins in a cross-platform mobile application development framework, there are dependencies between these pre-developed plug-ins. For example, the plug-in that implements the message push function depends on the plug-in that implements the user login function, and the plug-in that implements the user login function needs to depend on the plug-in that obtains device information. As a result, when project developers reference the plug-in that implements the message push function, they have to reference both the plug-in that implements the user login function and the plug-in that obtains device information, which limits the flexibility of front-end development. Among them, a plug-in depends on another plug-in, which means that the input data required by the plug-in needs to be provided by another plug-in.
[0037] by Figure 1 For example, plugin A depends on plugin B, plugin E depends on plugin B and plugin F, plugin C depends on plugin D, and plugin D depends on plugin G. If the project developer wants to reference plugin A, plugin E, and plugin C when writing the development project, at least plugin B, plugin D, and plugin G must be referenced at the same time to ensure the implementation of the development project.
[0038] Therefore, the degree of mutual dependence between plug-ins is high, which causes project developers to have to introduce the dependent plug-ins provided by the plug-in developers for the plug-in during development when referencing the plug-in, that is, the dependent plug-ins specified by the plug-in developers for the plug-in. For example, when implementing message push, the project developer does not want to log in the user, or wants to log in the user through other means instead of the plug-in for implementing user login provided by the plug-in developer. However, when designing the plug-in for implementing message push, the plug-in developer also specifies the plug-in for implementing user login that the plug-in for implementing message push depends on, causing the project developer to have to reference the plug-in for implementing user login provided by the plug-in developer. It can be seen that the high degree of mutual dependence between plug-ins leads to insufficient flexibility in front-end development.
[0039] The plug-in processing method, apparatus, device and storage medium provided by the embodiments of the present disclosure obtain the plug-in reference information of the development project during the development stage of the development project, and determine the first plug-in referenced by the development project and the second plug-in on which the first plug-in depends based on the plug-in reference information and the preset plug-in container. If the development project does not reference the second plug-in, a corresponding plug-in interface is generated for the second plug-in in the development project. Therefore, when the second plug-in on which the first plug-in depends is not referenced in the development project, a plug-in interface corresponding to the second plug-in is generated so that the project developer can write the functional implementation of the second plug-in according to the plug-in interface, without forcing the development project to apply the second plug-in specified by the plug-in developer, which effectively improves the flexibility of plug-in references in the development process, improves the flexibility of front-end development, and thus improves the user experience.
[0040] The plug-in processing method provided by the embodiment of the present disclosure can be applied to Figure 2 The network architecture example shown in Figure 1 is as follows. Figure 2 As shown, the network architecture includes: a terminal device 201 and a server 202. Project developers can develop projects on the terminal device 201, and the server 202 stores the plug-in container developed by the plug-in developer. Of course, the plug-in container can also be stored on the terminal device 201. The development project on the terminal device 201 can reference the plug-in in the plug-in container, and implement the underlying capabilities of calling the native operating system through the plug-in reference. The above-mentioned terminal device can be a computer, a tablet computer, a smart phone and other devices, and the server 202 can be a single server or a server group.
[0041] The following is a detailed description of the technical solutions of the embodiments of the present disclosure and how the technical solutions of the present application solve the above-mentioned technical problems with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the embodiments of the present disclosure will be described below in conjunction with the accompanying drawings.
[0042] Figure 3 The following is a flow chart of a plug-in processing method provided by an embodiment of the present disclosure, wherein the execution subject of the method is a terminal device. Figure 3 As shown, the method includes:
[0043] S301. Obtain plug-in reference information of a development project.
[0044] Wherein, the development project is, for example, an application development project, and the plug-in reference information may include the plug-in interface of the plug-in referenced by the development project. In order to facilitate the distinguishing description, the plug-in referenced by the development project is called the first plug-in, and the plug-in that the first plug-in depends on is called the second plug-in. The number of first plug-ins is one or more, and the number of second plug-ins is also one or more. The first plug-in and the second plug-in may have the same plug-in. For example, the development project references plug-in A and plug-in B, and plug-in B is the plug-in that plug-in A depends on. Therefore, plug-in B is both the first plug-in and the second plug-in.
[0045] Specifically, when a project developer writes the code for a development project, he needs to declare the plug-ins that the development project needs to reference in the development project, so the plug-in reference information of the development project can be obtained from these declarations of the development project. For example, the plug-in reference information of the development project can be read in the compiler where the development project is located.
[0046] Optionally, you can use the PluginTools tool in the Gradle plugin to read the plugin reference information of the development project in the compiler where the development project is located. The Gradle plugin is a tool that helps developers compile, automate and distribute software.
[0047] S302: Determine, according to the plug-in reference information and the preset plug-in container, a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends.
[0048] The plug-in developer develops the plug-in container in advance, which includes multiple plug-ins. The coupling degree between each plug-in is low, that is, the dependence degree is low. Each plug-in includes a plug-in interface and a function implementation. The plug-in interface is an abstract description of the function of the plug-in, and the function implementation is the specific code implementation of the function of the plug-in.
[0049] As an example, the plugin interface of the login plugin can be represented by the following program code:
[0050] public interface AccountProducer extends DataProducer{String getToken(); String getPhone();}.
[0051] Among them, "String getToken()" is used to obtain "Token", "String getPhone()" is used to obtain the mobile phone number, and "Token" is the token required for user login. Therefore, through this example, it can be understood that "String getToken()" and "String getPhone()" in the plug-in interface are both abstract descriptions of the plug-in's functions, and the plug-in's functions are implemented as codes for the specific implementation process of "String getToken()" and "String getPhone()".
[0052] Specifically, since the plug-in reference information includes the plug-in interface of the first plug-in, the plug-in container includes multiple plug-ins, and each plug-in includes the plug-in interface of the plug-in and the function implementation of the plug-in, the first plug-in can be found in the plug-in container according to the plug-in interface of the first plug-in, and the second plug-in on which the first plug-in depends can be determined.
[0053] S303: If the development project does not reference the second plug-in, generate a corresponding plug-in interface for the second plug-in in the development project.
[0054] Specifically, after determining the second plug-in that the first plug-in depends on, it is possible to determine whether the development project references the second plug-in by determining whether the plug-in reference information includes the plug-in interface of the second plug-in, or by determining whether the first plug-in includes the second plug-in. If the development project does not reference the second plug-in, that is, if there is a second plug-in that is not referenced by the development project, a corresponding plug-in interface is generated in the development project for the second plug-in that is not referenced by the development project. If the number of second plug-ins that are not referenced by the development project is one, a corresponding plug-in interface is generated for the one second plug-in, and if the number of second plug-ins referenced by the development project is multiple, corresponding plug-in interfaces are generated for the multiple second plug-ins, respectively.
[0055] Specifically, the corresponding plug-in interface generated for the second plug-in that is not referenced by the development project describes the functions that the second plug-in needs to implement, that is, an abstract description of the functions of the second plug-in, including a description of the data that the second plug-in can obtain and / or the data that the second plug-in can output. Therefore, project developers can know the functions that the second plug-in needs to implement based on the generated plug-in interface of the second plug-in, provide the functional implementation of the second plug-in by writing code, and then implement their own second plug-in without being forced to use the plug-in provided by the plug-in developer in the plug-in container.
[0056] In the disclosed embodiment, when a development project references a first plug-in but does not reference a second plug-in on which the first plug-in depends, a plug-in interface of the second plug-in is generated in the development project. By providing the plug-in interface of the second plug-in to project developers, the developers are assisted in understanding the functions that need to be implemented by the second plug-in. The project developers can implement the second plug-in by themselves without forcing the development project to introduce the second plug-in developed by the plug-in developer in the plug-in container, which effectively reduces the degree of coupling between plug-ins and improves the flexibility of front-end development.
[0057] In some embodiments, the plug-in interface of each plug-in in the plug-in container includes a data output interface and / or a data input interface, so that the plug-in outputs data or obtains data through the plug-in interface.
[0058] Specifically, when the function of the plug-in includes a data output function and a data acquisition function, the plug-in interface of the plug-in includes both a data output interface and a data input interface. For example, a plug-in whose function is to obtain device information needs to implement both the function of obtaining device information and the function of outputting the obtained device information, so the plug-in includes both a data output interface and a data input interface. Similarly, when the function of the plug-in only includes a data output function, the plug-in interface of the plug-in only includes a data output interface, and when the function of the plug-in only includes a data acquisition function, the plug-in interface of the plug-in only includes a data input interface.
[0059] In some embodiments, the plug-in container also includes configuration information of multiple plug-ins, and the configuration information of each plug-in is used to describe the output data provided by the plug-in and / or the input data that the plug-in depends on, so that the output data provided by the plug-in and / or the input data that the plug-in depends on can be understood through the configuration information of the plug-in, and it is also convenient to determine the dependency relationship between the plug-ins.
[0060] Specifically, the configuration information of the plug-in can be saved in the configuration file of the plug-in. In the plug-in container, multiple plug-ins and the configuration files of each plug-in are saved. The configuration file of the plug-in describes the configuration information of the plug-in, that is, describes the output data provided by the plug-in and / or the input data that the plug-in depends on. According to the configuration information of the plug-in, the plug-in that the plug-in depends on can be determined. When all or part of the input data that the plug-in depends on is the output data of another plug-in, the plug-in depends on the other plug-in.
[0061] As an example, the configuration information of the WebView plug-in can be represented as the following program code:
[0062] in:com.flutter.container.base.producer.AccountProducer;
[0063] in:com.flutter.container.base.producer.DeviceDataProducer;
[0064] in:com.flutter.container.base.producer.LocationDataProducer;
[0065] out:com.flutter.container.base.producer.WebViewProducer.
[0066] Among them, the WebView plug-in is a plug-in that implements the web page view, "in:" indicates the input data that the plug-in depends on, and "out:" indicates the output data provided by the plug-in. The above four lines of code respectively indicate: the WebView plug-in depends on account information, the WebView plug-in depends on device information, the WebView plug-in depends on location information, and the WebView plug-in provides a web page view.
[0067] Based on the configuration information of the plug-in container including multiple plug-ins, Figure 4 The following is a flow chart of a plug-in processing method provided by another embodiment of the present disclosure, wherein the execution subject of the method is a terminal device. Figure 4 As shown, the method includes:
[0068] S401. Obtain plug-in reference information of a development project.
[0069] Specifically, S401 may refer to the specific description of S301 and will not be repeated here.
[0070] S402: Determine a first plug-in according to the plug-in reference information.
[0071] Specifically, since the plug-in reference information includes the plug-in interface of the first plug-in, the plug-in container includes multiple plug-ins, and each plug-in includes the plug-in interface of the plug-in and the function implementation of the plug-in, the first plug-in can be found in the plug-in container according to the plug-in interface of the first plug-in.
[0072] S403: In the plug-in container, obtain input data that the first plug-in depends on.
[0073] Specifically, the configuration information of the first plug-in may be obtained in the plug-in container, and the input data that the first plug-in depends on may be obtained from the configuration information of the first plug-in.
[0074] S404: Determine a second plug-in according to the input data that the first plug-in depends on.
[0075] Specifically, the plug-in that provides the input data may be determined as the second plug-in. For example, the input data that the plug-in that implements user login depends on includes device information, so the plug-in that provides device information is the plug-in that the plug-in that implements user login depends on.
[0076] S405: If the development project does not reference the second plug-in, generate a corresponding plug-in interface for the second plug-in in the development project.
[0077] Specifically, S405 may refer to the specific description of S303, which will not be repeated here.
[0078] In the disclosed embodiment, a first plug-in referenced by a development project is determined, and a second plug-in dependent on the first plug-in is determined through input data on which the first plug-in depends in configuration information of the first plug-in. When the development project does not reference the second plug-in, a plug-in interface of the second plug-in is generated in the development project. By providing the plug-in interface of the second plug-in to project developers, developers are assisted in understanding the functions that need to be implemented by the second plug-in. The project developers can implement the second plug-in by themselves without forcing the development project to introduce the second plug-in developed by the plug-in developer in the plug-in container, thereby effectively reducing the degree of coupling between plug-ins and improving the flexibility of front-end development.
[0079] Based on the configuration information of the plug-in container including multiple plug-ins, Figure 5 The following is a flow chart of a plug-in processing method provided by another embodiment of the present disclosure, wherein the execution subject of the method is a terminal device. Figure 5 As shown, the method includes:
[0080] S501. Obtain plug-in reference information of a development project.
[0081] Specifically, S501 may refer to the specific description of S301, which will not be repeated here.
[0082] S502: Determine a first plug-in according to the plug-in reference information.
[0083] Specifically, since the plug-in reference information includes the plug-in interface of the first plug-in, the plug-in container includes multiple plug-ins, and each plug-in includes the plug-in interface of the plug-in and the function implementation of the plug-in, the first plug-in can be found in the plug-in container according to the plug-in interface of the first plug-in.
[0084] S503: In the plug-in container, obtain input data that the first plug-in depends on.
[0085] Specifically, in the plug-in container, configuration information of the first plug-in is obtained, and input data that the first plug-in depends on is obtained from the configuration information of the first plug-in.
[0086] S504: Determine a second plug-in according to the input data that the first plug-in depends on.
[0087] Specifically, a plug-in that provides input data that the first plug-in depends on may be determined as the second plug-in.
[0088] S505: In the plug-in container, obtain output data provided by the first plug-in.
[0089] Specifically, in the configuration information of the first plug-in, the output data provided by the first plug-in is obtained.
[0090] S506: Determine whether the development project references the second plug-in by comparing the output data provided by the first plug-in with the input data that the first plug-in depends on.
[0091] Specifically, if the development project only references one first plug-in, determine whether the output data provided by the first plug-in includes the input data that the first plug-in depends on. If so, the first plug-in does not depend on other plug-ins, that is, there is no second plug-in that the first plug-in depends on, and the development project does not need to reference the second plug-in. If the development project references multiple first plug-ins, obtain the output data provided by all first plug-ins and the input data that all first plug-ins depend on, and compare the output data provided by all first plug-ins with the input data that all first plug-ins depend on. If the output data provided by all first plug-ins includes the input data that all first plug-ins depend on, determine that the development project references all second plug-ins, otherwise determine that there are second plug-ins that are not referenced by the development project.
[0092] Specifically, if the development project references all the second plug-ins, the compilation process of the development project can be performed, otherwise S507 is executed.
[0093] S507: If the development project does not reference the second plug-in, generate a corresponding plug-in interface for the second plug-in in the development project.
[0094] Specifically, S507 may refer to the specific description of S303, which will not be repeated here.
[0095] In an embodiment of the present disclosure, a first plug-in referenced by a development project is determined, and in a plug-in container, output data provided by the first plug-in and dependent input data are obtained. By comparing the output data provided by the first plug-in with the input data that the first plug-in depends on, it is determined whether the development project references a second plug-in. When the development project does not reference the second plug-in, a plug-in interface of the second plug-in is generated in the development project. By providing the plug-in interface of the second plug-in to project developers, the developers are assisted in understanding the functions that need to be implemented by the second plug-in. The project developers can implement the second plug-in by themselves without forcing the development project to introduce the second plug-in developed by the plug-in developer in the plug-in container, thereby effectively reducing the degree of coupling between plug-ins and improving the flexibility of front-end development.
[0096] In some embodiments, if the development project does not reference the second plug-in, a class including the plug-in interfaces of all second plug-ins not referenced by the development project may be generated, wherein a class is a data type that implements information encapsulation in object-oriented programming (OOP).
[0097] As an example, Figure 1 Taking the above plugin dependency as an example, if plugin A and plugin C are referenced in the development project, but plugin B, plugin D and plugin G are not referenced, a class including the plugin interface of plugin B, the plugin interface of plugin D and the plugin interface of plugin G is generated, and the program code of the class is as follows:
[0098] public abstract class AbsContainerDataProducer implementsBDataProducer, DDataProducer, GDataProducer{
[0099] / / Implement the plugin interface of plugin B, plugin interface of plugin D, and plugin interface of plugin G
[0100] }. Among them, "AbsContainerDataProducer" represents the generated class, BDataProducer, DDataProducer, and GDataProducer are the plug-in interface of plug-in B, the plug-in interface of plug-in D, and the plug-in interface of plug-in G respectively.
[0101] In some embodiments, in addition to the plug-in interface and function implementation, each plug-in in the plug-in container also includes a function implementation index corresponding to the function implementation. During the project compilation process, the function implementation index can be used to establish a one-to-one mapping relationship between the function implementation and the plug-in interface, so that the development project can call the plug-in based on the plug-in interface.
[0102] In some embodiments, the project developer writes the function implementation of the second plug-in according to the plug-in interface of the second plug-in, and can also add a corresponding function implementation index for the function implementation of the second plug-in in the second plug-in. During the compilation process of the development project, the function implementation index is detected in the second plug-in, and the function implementation corresponding to the function implementation index is found according to the function implementation index, and a mapping relationship between the function implementation and the plug-in interface of the second plug-in is established. Therefore, based on the mapping relationship between the function implementation of the second plug-in and the plug-in interface of the second plug-in, the development project can call the function implementation of the second plug-in through the plug-in interface, thereby improving the efficiency of plug-in calling.
[0103] In some embodiments, during the compilation process of the development project, the function implementation index can also be detected in the first plug-in, and the function implementation corresponding to the function implementation index can be found according to the function implementation index, and a mapping relationship between the function implementation and the plug-in interface of the first plug-in can be established. Therefore, based on the mapping relationship between the function implementation of the first plug-in and the plug-in interface of the first plug-in, the development project can call the function implementation of the first plug-in through the plug-in interface, thereby improving the efficiency of plug-in calling.
[0104] Optionally, the function implementation index can be an annotation of the function implementation.
[0105] Optionally, during the compilation of the development project, the annotations in the first plug-in and / or the annotations in the second plug-in can be read through the Drouter tool in the Gradle plug-in, and the functional implementation of the first plug-in and / or the functional implementation of the second plug-in can be obtained according to the read annotations, and the mapping relationship between the plug-in interface of the first plug-in and the functional implementation of the first plug-in and / or the mapping relationship between the plug-in interface of the second plug-in and the functional implementation of the second plug-in can be established by using Javaassist technology. Among them, Javaassist technology is a high-level Java bytecode processing class library that can dynamically generate and modify classes.
[0106] As an example, the annotations and function implementation program code of the plug-in that implements user login are as follows:
[0107] (1)@Service(function=AccountProducer.class)
[0108] (2)public class AccountProducerImpl implements AccountProducer{
[0109] @Override
[0110] public String getToken(){
[0111] return Login.getToken();}
[0112] @Override
[0113] public String getPhone(){
[0114] return Login.getPhone();
[0115] }}.
[0116] Among them, "@Service(function=AccountProducer.class)" in (1) is an annotation, the content in (2) is the function implementation, "AccountProducerImpl" is the function name of the function implementation, and "AccountProducer" is the function name of the plug-in interface. Through the Drouter tool, other plug-ins except the login plug-in can directly call the login plug-in through the following code:
[0117] DRouter.build(AccountProducer.class).getService(new Object[0]).
[0118] To understand the plugin container more clearly, Figure 6 FIG. 1 shows an example of the architecture of a plug-in container. Figure 6 As shown, the plug-in container includes compilation tools (such as Gradle plug-ins, PluginTools tools in Gradle plug-ins, and Drouter tools in Gradle plug-ins), multiple plug-ins and a data bus, and the data bus includes plug-in interfaces of multiple plug-ins. Among them, plug-ins such as login plug-ins, device information plug-ins, web view plug-ins, message push plug-ins, sharing plug-ins, map plug-ins, and payment plug-ins have corresponding plug-in interfaces.
[0119] Figure 7 FIG. 1 is a schematic diagram of a plug-in processing device provided by an embodiment of the present disclosure. Figure 7 As shown, the device comprises:
[0120] Acquisition module 701, used to acquire plug-in reference information of a development project;
[0121] A determination module 702 is used to determine a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends according to the plug-in reference information and a preset plug-in container;
[0122] The generating module 703 is used to generate a corresponding plug-in interface for the second plug-in in the development project if the development project does not reference the second plug-in.
[0123] In a possible implementation, the plug-in container includes a plurality of plug-ins, and the plug-in interface of each plug-in includes a data output interface and / or a data input interface.
[0124] In a possible implementation, the plug-in container further includes configuration information of multiple plug-ins, where the configuration information of each plug-in is used to describe output data provided by the plug-in and / or input data that the plug-in depends on.
[0125] In a possible implementation, the determination module 702 is specifically configured to:
[0126] Determine the first plug-in according to the plug-in reference information;
[0127] In the plug-in container, obtain input data that the first plug-in depends on;
[0128] A second plug-in is determined according to input data that the first plug-in depends on.
[0129] In a possible implementation, the determining module 702 is further configured to:
[0130] In the plug-in container, obtaining output data provided by the first plug-in;
[0131] By comparing output data provided by the first plug-in with input data that the first plug-in depends on, it is determined whether the development project references the second plug-in.
[0132] In a possible implementation, in the plug-in container, each plug-in further includes a function implementation of the plug-in and a function implementation index corresponding to the function implementation.
[0133] In a possible implementation, the device further includes:
[0134] A mapping module is used to detect a function implementation index in a second plug-in during the compilation process of a development project, obtain a function implementation corresponding to the detected function implementation index in the development project, and establish a mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the second plug-in.
[0135] In a possible implementation, the device further includes:
[0136] A mapping module is used to detect a function implementation index in a plug-in interface of a first plug-in during the compilation process of a development project, obtain a function implementation corresponding to the detected function implementation index in a plug-in container, and establish a mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the first plug-in.
[0137] Figure 7 The provided plug-in processing device can execute the above-mentioned corresponding method embodiments, and its implementation principles and technical effects are similar, which will not be repeated here.
[0138] Figure 8 FIG. 1 is a schematic diagram of a structure of an electronic device provided by an embodiment of the present disclosure. Figure 8 As shown, the electronic device may include: a processor 801 and a memory 802. The memory 802 is used to store computer-executable instructions, and the processor 801 implements the method of any of the above embodiments when executing the computer program.
[0139] The processor 801 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc. The memory 802 may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0140] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, and when the computer-readable storage medium is run on a computer, the computer executes a method as described in any of the above embodiments.
[0141] An embodiment of the present disclosure further provides a program product, which includes a computer program. The computer program is stored in a storage medium, and at least one processor can read the computer program from the storage medium. When the at least one processor executes the computer program, the method of any of the above embodiments can be implemented.
[0142] Fig. 9 A block diagram of a plug-in processing device 900 provided in accordance with an embodiment of the present disclosure. For example, the device 900 may be provided as a computer. Fig. 9 The apparatus 900 includes a processing component 901, which further includes one or more processors, and a memory resource represented by a memory 902 for storing instructions executable by the processing component 901, such as an application. The application stored in the memory 902 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 901 is configured to execute instructions to perform the method of any of the above embodiments.
[0143] The device 900 may also include a power supply component 903 configured to perform power management of the device 900, a wired or wireless network interface 904 configured to connect the device 900 to a network, and an input / output (I / O) interface 905. The device 900 may operate based on an operating system stored in the memory 902, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0144] It can be understood that the “first” and “second” involved in the embodiments of the present disclosure are only distinctions made for the convenience of description and are not used to limit the scope of the embodiments of the present disclosure.
[0145] It should be understood that the various numerical numbers involved in the embodiments of the present disclosure are only used for the convenience of description and are not used to limit the scope of the embodiments of the present disclosure.
[0146] It is understandable that in the embodiments of the present disclosure, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0147] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The embodiments of the present disclosure are intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and embodiments are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0148] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A plug-in processing method, characterized in that: The method comprises: Get plugin reference information for development projects; Determining, according to the plug-in reference information and a preset plug-in container, a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends; If the development project does not reference the second plug-in, a corresponding plug-in interface is generated for the second plug-in in the development project. The generated plug-in interface describes the functions that the second plug-in needs to implement to assist in developing a plug-in that implements the functions.
2. The method according to claim 1, characterized in that The plug-in container includes a plurality of plug-ins, and the plug-in interface of each plug-in includes a data output interface and / or a data input interface.
3. The method according to claim 2, characterized in that The plug-in container also includes configuration information of the multiple plug-ins, and the configuration information of each plug-in is used to describe output data provided by the plug-in and / or input data that the plug-in depends on.
4. The method according to claim 3, characterized in that The step of determining, according to the plug-in reference information and a preset plug-in container, a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends includes: Determining the first plug-in according to the plug-in reference information; In the plug-in container, obtaining input data that the first plug-in depends on; The second plug-in is determined according to the input data on which the first plug-in depends.
5. The method according to claim 4, characterized in that The method further comprises: In the plug-in container, obtaining output data provided by the first plug-in; By comparing the output data provided by the first plug-in with the input data that the first plug-in depends on, it is determined whether the development project references the second plug-in.
6. The method according to any one of claims 3 to 5, characterized in that: In the plug-in container, each plug-in further includes a function implementation of the plug-in and a function implementation index corresponding to the function implementation.
7. The method according to claim 6, characterized in that The method further comprises: During the compilation of the development project, detecting a function implementation index in the second plug-in; Obtaining, in the development project, a function realization corresponding to the detected function realization index; A mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the second plug-in is established.
8. The method according to claim 6, characterized in that The method further comprises: During the compilation of the development project, a function implementation index is detected in the first plug-in; Obtaining, in the plug-in container, a function implementation corresponding to the detected function implementation index; A mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the first plug-in is established.
9. A plug-in processing device, characterized in that: The device comprises: The acquisition module is used to obtain the plug-in reference information of the development project; A determination module, configured to determine a first plug-in referenced by the development project and a second plug-in on which the first plug-in depends, according to the plug-in reference information and a preset plug-in container; A generation module is used to generate a corresponding plug-in interface for the second plug-in in the development project if the development project does not reference the second plug-in. The generated plug-in interface describes the functions that the second plug-in needs to implement to assist in developing a plug-in that implements the functions.
10. The device according to claim 9, characterized in that The plug-in container includes a plurality of plug-ins, and the plug-in interface of each plug-in includes a data output interface and / or a data input interface.
11. The device according to claim 10, characterized in that The plug-in container also includes configuration information of the multiple plug-ins, and the configuration information of each plug-in is used to describe output data provided by the plug-in and / or input data that the plug-in depends on.
12. The device according to claim 11, characterized in that The determining module is specifically used for: Determining the first plug-in according to the plug-in reference information; In the plug-in container, obtaining input data that the first plug-in depends on; The second plug-in is determined according to the input data on which the first plug-in depends.
13. The device according to claim 11, characterized in that The determining module is further used for: In the plug-in container, obtaining output data provided by the first plug-in; By comparing the output data provided by the first plug-in with the input data that the first plug-in depends on, it is determined whether the development project references the second plug-in.
14. The device according to any one of claims 11 to 13, characterized in that: In the plug-in container, each plug-in further includes a function implementation of the plug-in and a function implementation index corresponding to the function implementation.
15. The device according to claim 14, characterized in that The device also includes: A mapping module is used to detect a function implementation index in the second plug-in during the compilation process of the development project, obtain the function implementation corresponding to the detected function implementation index in the development project, and establish a mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the second plug-in.
16. The device according to claim 14, characterized in that The device also includes: A mapping module is used to detect a function implementation index in the plug-in interface of the first plug-in during the compilation process of the development project, obtain a function implementation corresponding to the detected function implementation index in the plug-in container, and establish a mapping relationship between the function implementation corresponding to the detected function implementation index and the plug-in interface of the first plug-in.
17. An electronic device comprising: Memory and processor; The memory is used to store program instructions; The processor is used to call the program instructions in the memory to execute the method according to any one of claims 1-8.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program; when the computer program is executed, the method according to any one of claims 1 to 8 is implemented.
