CN112748905A - Method and device for initializing and calling basic library, electronic equipment and storage medium - Google Patents

Method and device for initializing and calling basic library, electronic equipment and storage medium Download PDF

Info

Publication number
CN112748905A
CN112748905A CN201911039418.2A CN201911039418A CN112748905A CN 112748905 A CN112748905 A CN 112748905A CN 201911039418 A CN201911039418 A CN 201911039418A CN 112748905 A CN112748905 A CN 112748905A
Authority
CN
China
Prior art keywords
configuration
library
target
configuration file
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911039418.2A
Other languages
Chinese (zh)
Other versions
CN112748905B (en
Inventor
方旭楷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201911039418.2A priority Critical patent/CN112748905B/en
Publication of CN112748905A publication Critical patent/CN112748905A/en
Application granted granted Critical
Publication of CN112748905B publication Critical patent/CN112748905B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses an initialization calling method, device, storage medium and electronic equipment of a basic library, wherein the initialization calling method of the basic library comprises the steps of obtaining a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries; determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library; and generating a corresponding configuration class according to the configuration items of the target basic library in the configuration file, and performing initialization calling on the configuration class.

Description

Method and device for initializing and calling basic library, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to an initialization calling method and apparatus for a base library, an electronic device, and a storage medium.
Background
The modular technology can reduce coupling and realize effective division of labor. When the componentization is carried out, the related art generally adopts a hard coding mode to realize the encapsulation and the calling of the basic library. Namely: when a new base library needs to be accessed, a developer needs to manually write template codes. However, in actual project development, the number of similar basic libraries can reach several tens, a developer is required to manually write similar template codes for accessing each basic library, and the similar template codes need to be repeatedly written every time a new project is developed, so that the calling efficiency of the basic libraries is low.
Therefore, how to improve the efficiency of the initial call of the base library is a technical problem that needs to be solved by those skilled in the art at present.
Disclosure of Invention
The application aims to provide an initialization calling method of a basic library, an initialization calling device of the basic library, an electronic device and a storage medium, and the initialization calling efficiency of the basic library can be improved.
To achieve the above object, a first implementation manner of a first aspect of the present application provides an initial calling method for a base library, where the initial calling method for the base library includes:
acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
With reference to the first implementation manner of the first aspect of the present application, in a second implementation manner of the first aspect of the present application, the configuration item includes a function enabling field, and accordingly, determining, according to the configuration file, a target base library that needs to be injected in the base library includes:
determining the base bank with the function enabling field being true as the target base bank.
With reference to the first implementation manner of the first aspect of the present application, in a third implementation manner of the first aspect of the present application, after the initializing call is performed on the configuration class, the method further includes:
and loading the target basic library so as to realize the corresponding function of the target basic library.
In combination with the first implementation manner of the first aspect of the present application, in a fourth implementation manner of the first aspect of the present application, declaring the dependency of the target base library comprises:
the code of the help project (': A') is added into the dependent files, wherein A is the name of the target basic library.
With reference to the first implementation manner of the first aspect of the present application, in a fifth implementation manner of the first aspect of the present application, the configuration file further includes a base library version number.
With reference to the first embodiment of the first aspect of the present application, in a sixth embodiment of the first aspect of the present application, the method further includes: and adding the configuration class after the initialization call as an access code into the target project code.
With reference to the first embodiment of the first aspect of the present application, in a seventh embodiment of the first aspect of the present application, the method further includes: and when a basic library removing instruction is received, modifying the configuration file according to the basic library removing instruction, and generating and initializing a new configuration class according to the modified configuration file so as to delete the configuration information to be removed in the android Manifest.
With reference to the first implementation manner of the first aspect of the present application, in an eighth implementation manner of the first aspect of the present application, the configuration file is a script file generated in a manner that a new Extension is registered by using Gradle.
With reference to the first implementation manner, the second implementation manner, the third implementation manner, the fourth implementation manner, the fifth implementation manner, the sixth implementation manner, the seventh implementation manner, and the eighth implementation manner of the first aspect of the present application, in a ninth implementation manner of the first aspect of the present application, the generating a corresponding configuration class according to the configuration item of the target base library in the configuration file includes:
determining a configuration field of the target base library and a configuration value corresponding to the configuration field in the configuration file;
and generating the configuration class according to the configuration value corresponding to the configuration field based on the standard configuration code corresponding to the configuration field.
With reference to the ninth implementation manner of the first aspect of the present application, in a tenth implementation manner of the first aspect of the present application, the initializing and calling the configuration class includes:
and creating the configuration class in an initialization calling class, and performing initialization calling on the configuration class by using a target function.
To achieve the above object, a second aspect of the present application provides an initialization calling apparatus for a base library, the initialization calling apparatus including:
the file acquisition module is used for acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
a basic library determining module, configured to determine, according to the configuration file, a target basic library to be injected in the basic library, and declare a dependency of the target basic library;
and the basic library calling module is used for generating a corresponding configuration class according to the configuration items of the target basic library in the configuration file and carrying out initialization calling on the configuration class.
To achieve the above object, a third aspect of the present application provides an electronic device comprising:
a processor and a memory;
wherein the processor is configured to execute a program stored in the memory;
the memory is to store a program to at least:
acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
To achieve the above object, a fourth aspect of the present application provides a storage medium having a computer program stored thereon, where the computer program is executed to implement the steps executed by the method for initiating and calling the base library.
Therefore, the configuration file acquired by the method comprises the basic libraries and the configuration files, and the configuration files comprise the configuration items of the plurality of basic libraries, so that the target basic libraries to be injected can be determined according to the configuration items recorded in the configuration files, and corresponding configuration classes can be generated according to the configuration items of the target basic libraries so as to assign values to the configuration items of the target basic libraries. After the configuration class of the target base library is obtained, the method and the device realize the corresponding function of the target base library by initializing and calling the configuration class. In the mode, manual repeated writing of template codes is not needed, the corresponding configuration classes can be flexibly generated according to the configuration items in the configuration files, further, the initialization calling of the foundation can be realized, and the initialization calling efficiency of the foundation library can be improved. The application also provides an initialization calling device of the basic library, a storage medium and electronic equipment, which have the beneficial effects and are not repeated herein.
Drawings
In order to more clearly illustrate the embodiments of the present application, the drawings needed for the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a schematic diagram of a component architecture of an initialization calling system of a base library according to an embodiment of the present application;
fig. 2 is a schematic flowchart of an initial calling method of a base library according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating another method for initializing and calling a base library according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of a basic library initialization calling method in practical application according to an embodiment of the present application;
fig. 5 is a schematic diagram illustrating an architecture of a basic library initialization calling method in practical application according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an initialization calling apparatus for a base library according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the related art, the basic library initialization call is mainly realized in a hard coding mode, but in actual project development, a large number of basic libraries are often involved. If the basic library is called in a hard coding mode, developers need to manually write template codes with extremely high repetition degree, and the calling efficiency of the basic library is low. Based on the various defects in the related art, the present application provides a new method for initializing and calling a base library by the following embodiments, which can improve the efficiency of initializing and calling the base library.
In order to facilitate understanding of the basic library initialization calling method of the present application, a system to which the basic library initialization calling method of the present application is applied will be described below. Referring to fig. 1, a schematic diagram of a component architecture of an initialization calling system of a base library according to an embodiment of the present application is shown.
As shown in fig. 1, the system for initializing and calling a base library provided in the embodiment of the present application includes: a remote code database 10 and a terminal device 20. The remote code database 10 is a remote repository for storing codes, and the remote code database 10 may be used by a plurality of terminal devices to download base library codes. The terminal device 20 may be a device for constructing a modular framework, and each functional module in the modular framework may include a plurality of functional modules 30, which may be compiled and executed independently, or may be arbitrarily combined into another new functional module. The communication connection between the terminal device 20 and the remote code database 10 can be realized by a network.
In this embodiment, the remote code database 10 may be a database in a cloud server, and may provide a code download service for a plurality of clients, the number and the type of codes in the remote code database 10 are not limited in this embodiment, and an operation of maintaining codes in the remote code database 10 may also be performed in this embodiment to implement version update of the codes. The terminal device 20 may download the corresponding basic library code from the remote code database 10 according to actual requirements, thereby implementing the initial call of the basic library. Terminal device 20 may first obtain a configuration file that includes a base library and a configuration file; determining a target basic library required to be injected in all basic libraries according to configuration items recorded in a configuration file, and declaring the dependence of the target basic library; and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class. In this way, the terminal device 20 does not need to repeatedly write a code for calling the basic library according to the requirement, but automatically generates the configuration class according to the configuration items in the configuration file to further implement the initial calling of the basic library to be called. Therefore, in the embodiment provided by the application, template codes do not need to be written repeatedly manually, the corresponding configuration classes can be generated flexibly according to the configuration items in the configuration files, further the initialization calling of the foundation is realized, and the initialization calling efficiency of the foundation library can be improved.
The following describes in detail an initialization calling process of a base library in a terminal device, and referring to fig. 2, it shows a flowchart of an initialization calling method of a base library according to an embodiment of the present application, where the method of this embodiment may include the following steps:
s101: acquiring a configuration file;
the configuration file obtained in this step may include configuration items of a plurality of base libraries, that is, in this embodiment, the dependencies of the plurality of base libraries are unified into one configuration file, and the configuration item corresponding to each base library can be known according to the configuration file. For example, for a download base library for implementing the download function, the corresponding configuration items may include a download path, a maximum thread number, and a maximum download speed, and the download path, the maximum thread number, and the maximum download speed in the configuration file may all have their corresponding values, so that when the download function is implemented by using the base library, according to the three configuration items, a thread within the maximum thread number is called to download data to a folder corresponding to a specified download path at a speed less than or equal to the maximum download speed.
It can be understood that, in this embodiment, the configuration items of all the base libraries may be written into the configuration file, and the corresponding relationship between the base libraries and the configuration items is recorded in the configuration file. Before this step, there may be an operation of assigning values to the configuration items in the configuration file, so as to implement flexible invocation and flexible configuration for each base library. Specifically, the configuration file in this embodiment is a script file generated by registering new Extension using a Gradle, which is a project automation building open source tool and may declare a project setting using a specific domain language based on Groovy.
Further, in this embodiment, an original configuration file may be set, where the original configuration file may include all configuration items of the base library that may be called, and values of all configuration items in the original configuration file are default values. When a specific project needs to be developed, the original configuration file may be called, and the default value of each configuration item in the original configuration file may be changed according to actual requirements, so as to obtain the configuration file mentioned in S101. As a feasible implementation manner, since the template code of the base library does not need to be written locally, the compiled base library can be directly called.
S102: determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
the purpose of this step is to determine the target base library to be enabled, and each base library may have its corresponding implementation function, so the operation of determining the target base library in this embodiment is equivalent to determining the function to be implemented. For example, if the network function, the storage function and the query function need to be implemented, the network function basic library, the storage function basic library and the query function basic library need to be used as target basic libraries to be injected, and the dependency on the target basic libraries is declared. Specifically, when the function corresponding to the basic library is implemented, a system permission matched with the function to be implemented may be allocated to the basic library, for example, the basic library for implementing the download function requires a network access permission and a file storage permission, and the configuration of the permission of the basic library may be declared in an android manifest. Further, when the function corresponding to the base library is implemented, the base library may be allowed to start a specific background service, and a < service > tag for starting the background service may be generated for the base library.
As a possible implementation manner, the configuration file mentioned in this embodiment may include a function enabling field corresponding to each basic library setting, for describing whether to enable the function of the corresponding basic library. For example, if the function enable field of the network function base is 1, it indicates that the network function base is a target base to be injected, and if the function enable field of the storage function base is 0, it indicates that the network function base is not the target base to be injected, that is, it can be determined that the current system needs to implement the network function without implementing the storage function according to the configuration file. As another possible implementation, the configuration file may further include a base library enabling directory, and a base library in the base library enabling directory may be used as a target base library to be injected. It should be noted that the basic library injection mentioned in this embodiment may enable the componentized framework to have the corresponding function of the basic library.
After determining the target base library, the present embodiment may add a dependency declaration for the target base library so that the target base library may be used. The specific method of declaring the dependency of the target base library may be: the code of the help project (': A') is added into the dependent files, wherein A is the name of the target basic library. For example, when a declaration of the download function base is required, the code of the component project (': download') may be added to the dependent files.
S103: and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
The purpose of this step is to make an initialization call to the target base library, so that the system has the function corresponding to the target base library. The step is established on the basis of performing dependency declaration on the target base library, and the target base library needs to be initialized and configured, so that normal realization of corresponding functions of the target base library is ensured. On the basis of determining the target base libraries, the present embodiment may determine, according to the configuration file, the configuration item corresponding to each target base library, generate the corresponding configuration class according to the configuration item, and perform an initialization call operation on the generated configuration class, so as to assign the configuration class to the corresponding base library code, thereby implementing initialization of the target base libraries, and the function of the target base libraries may be normally implemented.
It can be seen that the configuration file obtained in this embodiment includes a base library and a configuration file, and since the configuration file includes configuration items of a plurality of base libraries, a target base library to be injected can be determined according to the configuration items recorded in the configuration file, and a corresponding configuration class can be generated according to the configuration items of the target base library, so as to assign values to the configuration items of the target base library. After the configuration class of the target base library is obtained, the embodiment calls the configuration class by initialization to realize the function corresponding to the target base library. In the mode, manual repeated writing of template codes is not needed, the corresponding configuration classes can be flexibly generated according to the configuration items in the configuration files, further, the initialization calling of the foundation can be realized, and the initialization calling efficiency of the foundation library can be improved. After the initialization call is made, the configuration class after the initialization call can be added to the target project code as an access code, so that the automatic access of the code is realized.
As a further description of the embodiment corresponding to fig. 2, a configuration item in the configuration file may include a function enabling field, specifically, the configuration file may include a function enabling field corresponding to each basic library, and when a value corresponding to the function enabling field is true, it indicates that the basic function library is a target basic library to be injected; when the value corresponding to the function enable field is false, the function base library is indicated as a target base library which does not need to be injected. Correspondingly, in the embodiment corresponding to fig. 2, the operation of determining, by the S201 according to the configuration file, the target base library that needs to be injected in the base library may be: determining the base bank with the function enabling field being true as the target base bank.
For example, the configuration item in the configuration file about the Download base library may include the following configuration fields:
UseDownload:true;
Path:sdcard/debug/path;
maxTreadNum:5;
maxSpeedLimit:200;
UseDownload is the above mentioned function enable field, in the above example, the function enable field is true, which illustrates that the Download basic library is the target basic library to be injected. Further, in other fields, a value of Path is used to indicate a storage Path of the download data, a value of maxtaradnum is used to indicate a maximum number of threads, and a value of maxseedlimit is used to indicate a maximum download speed.
Further, the configuration items in the configuration file in this embodiment may further include a base library version number, and in order to avoid a situation that the versions of the called base libraries are inconsistent, this embodiment may detect whether all the base library version numbers are consistent, and if not, generate a prompt message, and suspend the call to the base library with the abnormal base library version number. The basic library version number exception mentioned above refers to the exception of most basic library version numbers, for example, the configuration file includes 100 basic library version numbers, wherein 98 basic library version numbers are OS12.3, and two basic library version numbers are OS12.2, and it can be determined that the basic library version number is OS12.2, at this time, the exception exists. That is, the embodiment may use the ratio of the number of each base library version number to all base library version numbers as a basis for determining whether the base library version number is the abnormal version number, and if the ratio is smaller than the preset value, determine that the base library version number is the abnormal version number.
By way of further introduction to the embodiment corresponding to fig. 2, after the initial call is made to the configuration class, the target base library may also be loaded, so as to implement a function corresponding to the target base library.
As a further supplement to the corresponding embodiment of fig. 2, when a base library removal instruction is received, the configuration file is modified according to the base library removal instruction, and a new configuration class is generated and initialized according to the modified configuration file, so as to delete the configuration information to be removed in the android manifest. Taking the configuration item related to the Download base library in the configuration file as an example, if the Download base library needs to be removed, the configuration field UseDownload in the configuration file can be set to false, and an information configuration item is generated according to the modified configuration file, and a new configuration item is initialized and called.
Referring to fig. 3, which shows a flowchart of another method for initializing and calling a base library according to an embodiment of the present application, for further description of operations of S102 and S103 in the embodiment corresponding to fig. 2, the method of the present embodiment may include the following steps:
s201: acquiring a configuration file;
s202: determining a target basic library to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
s203: determining a configuration field of the target base library and a configuration value corresponding to the configuration field in a configuration file;
the configuration file may include configuration fields and configuration values corresponding to the configuration fields, each target base library may have a configuration field corresponding thereto, and the configuration values corresponding to the configuration fields are equivalent to the configuration parameters of the target base library.
For example, the configuration fields and the configuration values of the log base in the configuration file may include a log function enabling field, a log storage path field, and a log reporting field, where the configuration values corresponding to the log function enabling field are used to describe whether the log function is enabled, the log storage path field is used to describe the location of log storage, and the log reporting field is used to describe the log reporting period and object.
S204: and generating a configuration class according to the configuration value corresponding to the configuration field based on the standard configuration code corresponding to the configuration field.
Each configuration field may have a standard configuration code corresponding thereto, and after determining a configuration value corresponding to the configuration field, a corresponding configuration class may be generated according to the configuration value, where the configuration class carries the configuration value of the configuration field.
S205: and creating a configuration class in the initialization calling class, and performing initialization calling on the configuration class by using the target function.
In this step, the same configuration class is created in the initialization call class with further reference to the previously generated configuration class, and the initialization call is performed on the configuration class by using the related function. To illustrate the above operation, for example, if the logFilePath of the Log module configured in the configuration file app-config. Further, an initialization call class appconfiginitial may be generated so as to call initialization of all interfaces, and the configuration class falclologconfig () { this. Through the implementation mode, the automatic initialization calling of the basic library can be realized, and each project only needs to copy one file.
The flow described in the above embodiment is explained below by an embodiment in practical use. Referring to fig. 4 and 5, fig. 4 shows a flowchart of a basic library initialization calling method in practical application according to an embodiment of the present application, and fig. 5 shows an architecture diagram of the basic library initialization calling method in practical application according to the embodiment of the present application. The embodiment writes the AppConfig class first, then registers new Extension to Gradle, and injects new base library dependency to project's dependencies. Registering the afterevaluation with project implements the annotation callback interface, parsing the configuration to generate a file. The GenerateFileTask may also be executed through a callback process to generate a configuration file and make an initialization call.
In this embodiment, all the base library dependencies are unified into a configuration file app-config. For example, the configuration items of the Download base library may include three configuration items, namely, a Download path, a maximum thread number, and a maximum Download speed, for implementing initial configuration of the Download function. After the configuration file is used, the Gradle plug (a plug-in for realizing the modular construction script function) used by the componentized framework can automatically realize the full process of taking over access, if the Gradle plug needs to be migrated to another componentized framework, the configuration file only needs to be copied to another componentized framework, and the removal function can also be realized by removing the configuration file. Because the Gradle plug used by the componentization framework can automatically generate corresponding access codes to project codes according to the configuration content, the embodiment can apply for any content in android manifest without needing developers to write any codes. The 0 intrusion is guaranteed since no more code needs to be manually added to the item. The access personnel also need not be concerned with any detailed content, only the configuration information related to the project that should be delivered. In order to realize that all access matters can be automatically completed by one configuration file, the embodiment realizes automatic injection dependence and automatic generation initialization logic. Wherein, automatically injecting the dependency means automatically injecting the dependency according to the configuration written in the Gradle, namely adding "complex xxx" to the project. The automatic generation initialization logic refers to code for automatically generating initialization according to the configuration written in the Gradle, and simultaneously needs to support extension to add different configurations. Of course, the configuration file in this embodiment may also be a json-format configuration file, and during compiling, Gradle is used for parsing, and a code is generated in a JavaPoet manner.
Specifically, in this embodiment, a method of registering new Extension by using Gradle is used to implement basic initialization call: firstly, a configuration script is generated, and according to the analyzed configuration item, project dependence and production codes are automatically injected. The version number of the unified base library may be controlled by the version field falcomsdkversion, with all base libraries using the same version number. The configuration items of each basic library may be declared within config [ ], for example, three basic configuration items of the Download basic library exist, and in addition to this, there is a useDownload at the beginning: and if the latter value is true, the dependency on the basic library can be automatically injected at the compiling time, so that the dependency which needs to be manually written and declared for each module is omitted. The other three configuration segments automatically generate corresponding configuration classes during compiling, then are assigned as corresponding fields, and finally are transmitted to the initialization interface.
For example, if the logFilePath of the Log module configured in the configuration file app-config. The embodiment may also generate the appliglnitiation class, which may call initialization of all interfaces and assign the configuration class generated just before. For example, a new falclologconfig () is created on line 14 and then passed into the initdefaultlog () which initializes the log function module, telling it to save the log to the "demo/path" path. Through the process, the problem of initialization calling of the basic library can be solved in an automatic and non-invasive manner, and each project only needs to copy one file.
The embodiment provides a more flexible, more convenient and non-invasive decoupling scheme, and is very convenient for expanding new configuration and migration. By the scheme, template codes do not need to be written manually and repeatedly, injection service and writing templatized interface initialization codes do not need to be concerned, and the problem of configuration updating synchronization caused by base library upgrading can be avoided. If the function needs to be removed, only the configuration file needs to be deleted, so that the situation that part of the content is not completely removed from the project when the function is removed is avoided.
Referring to fig. 6, fig. 6 is a schematic structural diagram of an initialization calling device of a base library according to an embodiment of the present disclosure;
the apparatus may include:
a file obtaining module 401, configured to obtain a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
a basic library determining module 402, configured to determine, according to the configuration file, a target basic library that needs to be injected in the basic library, and declare a dependency of the target basic library;
a basic library calling module 403, configured to generate a corresponding configuration class according to the configuration items of the target basic library in the configuration file, and perform initialization calling on the configuration class.
It can be seen that the configuration file obtained in this embodiment includes a base library and a configuration file, and since the configuration file includes configuration items of a plurality of base libraries, a target base library to be injected can be determined according to the configuration items recorded in the configuration file, and a corresponding configuration class can be generated according to the configuration items of the target base library, so as to assign values to the configuration items of the target base library. After the configuration class of the target base library is obtained, the embodiment calls the configuration class by initialization to realize the function corresponding to the target base library. In the mode, manual repeated writing of template codes is not needed, the corresponding configuration classes can be flexibly generated according to the configuration items in the configuration files, further, the initialization calling of the foundation can be realized, and the initialization calling efficiency of the foundation library can be improved.
Further, the configuration item includes a function enable field;
accordingly, basic library determining module 402 is specifically a module for determining the basic library with the function enabling field being true as the target basic library, and declaring the dependency of the target basic library.
Further, the method also comprises the following steps:
and the basic library loading module is used for loading the target basic library so as to realize the function corresponding to the target basic library.
Further, the method also comprises the following steps:
and the code adding module is used for adding the configuration class after the initialization calling as an access code into the target project code.
Further, the method also comprises the following steps:
and the base library removing module is used for modifying the configuration file according to the base library removing instruction when the base library removing instruction is received, and generating and initializing a new configuration class according to the modified configuration file so as to delete the configuration information to be removed in the android Manifest.
Further, the configuration file is a script file generated by using a manner of Gradle registration for new Extension.
Further, the base library determining module 402 comprises:
a target basic library determining unit, configured to determine, according to the configuration file, a target basic library to be injected in the basic library
And the dependency declaration unit is used for adding the code of the help project (': A') into the dependent files, wherein A is the name of the target base library.
Further, the configuration file further includes a base library version number.
Further, the configuration item includes a configuration field;
accordingly, the basic library calling module 403:
a configuration information determining unit, configured to determine, in the configuration file, a configuration field of the target base library and a configuration value corresponding to the configuration field;
a configuration class generating unit, configured to generate the configuration class according to the configuration value corresponding to the configuration field based on the standard configuration code corresponding to the configuration field;
and the initialization calling unit is used for creating the configuration class in the initialization calling class and performing initialization calling on the configuration class by using a target function.
Since the embodiments of the apparatus portion and the method portion correspond to each other, please refer to the description of the embodiments of the method portion for the embodiments of the apparatus portion, which is not repeated here.
On the other hand, the present application also provides an electronic device, as shown in fig. 7, which shows a schematic structural diagram of an electronic device according to an embodiment of the present application, where the electronic device 2100 according to the embodiment may include: a processor 2101 and a memory 2102.
Optionally, the server may further comprise a communication interface 2103, an input unit 2104 and a display 2105 and a communication bus 2106.
The processor 2101, the memory 2102, the communication interface 2103, the input unit 2104, the display 2105, and the like communicate with each other via the communication bus 2106.
In the embodiment of the present application, the processor 2101 may be a Central Processing Unit (CPU), an application specific integrated circuit (asic), a digital signal processor, an off-the-shelf programmable gate array (fpga) or other programmable logic device.
The processor may call a program stored in the memory 2102. Specifically, the processor may perform the operations performed on the server side in the following embodiments of the method for initial invocation of a base library.
The memory 2102 stores one or more programs, which may include program code including computer operating instructions, and in this embodiment, at least one program for implementing the following functions is stored in the memory:
acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
It can be seen that the configuration file obtained in this embodiment includes a base library and a configuration file, and since the configuration file includes configuration items of a plurality of base libraries, a target base library to be injected can be determined according to the configuration items recorded in the configuration file, and a corresponding configuration class can be generated according to the configuration items of the target base library, so as to assign values to the configuration items of the target base library. After the configuration class of the target base library is obtained, the embodiment calls the configuration class by initialization to realize the function corresponding to the target base library. In the mode, manual repeated writing of template codes is not needed, the corresponding configuration classes can be flexibly generated according to the configuration items in the configuration files, further, the initialization calling of the foundation can be realized, and the initialization calling efficiency of the foundation library can be improved.
In one possible implementation, the memory 2102 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a topic detection function, etc.), and the like; the storage data area may store data created according to the use of the computer.
Further, the memory 2102 may include high speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid state storage device.
The communication interface 2103 may be an interface of a communication module, such as an interface of a GSM module.
The present application may also include an input unit 2104 and a display 2105, among others.
Of course, the structure of the electronic device shown in fig. 7 does not constitute a limitation of the electronic device in the embodiment of the present application, and in practical applications, the server may include more or less components than those shown in fig. 7, or some components may be combined.
On the other hand, the embodiment of the present application further provides a storage medium, in which a computer program is stored, and when the computer program is loaded and executed by a processor, the computer program is used to implement the method for initializing and calling the base library as described in any one of the above embodiments.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (13)

1. An initial calling method of a basic library, comprising:
acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
2. The method of claim 1, wherein the configuration item includes a function enabling field, and accordingly, determining the target base library to be injected from the base library according to the configuration file includes:
determining the base bank with the function enabling field being true as the target base bank.
3. The method of claim 1, wherein after the initial call to the configuration class, the method further comprises:
and loading the target basic library so as to realize the corresponding function of the target basic library.
4. The method of claim 1, wherein declaring dependencies of the target base library comprises:
the code of the help project (': A') is added into the dependent files, wherein A is the name of the target basic library.
5. The initial call method as recited in claim 1 wherein said configuration file further comprises a base library version number.
6. The method of claim 1, further comprising:
and adding the configuration class after the initialization call as an access code into the target project code.
7. The method of claim 1, further comprising:
and when a basic library removing instruction is received, modifying the configuration file according to the basic library removing instruction, and generating and initializing a new configuration class according to the modified configuration file so as to delete the configuration information to be removed in the android Manifest.
8. The method of claim 1, wherein the configuration file is a script file generated by means of Gradle registration for new Extension.
9. The method of any one of claims 1 to 8, wherein the configuration item includes a configuration field, and accordingly, generating the corresponding configuration class according to the configuration item of the target base library in the configuration file includes:
determining a configuration field of the target base library and a configuration value corresponding to the configuration field in the configuration file;
and generating the configuration class according to the configuration value corresponding to the configuration field based on the standard configuration code corresponding to the configuration field.
10. The method of claim 9, wherein making an initialization call to the configuration class comprises:
and creating the configuration class in an initialization calling class, and performing initialization calling on the configuration class by using a target function.
11. An apparatus for initializing and calling a base library, comprising:
the file acquisition module is used for acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
a basic library determining module, configured to determine, according to the configuration file, a target basic library to be injected in the basic library, and declare a dependency of the target basic library;
and the basic library calling module is used for generating a corresponding configuration class according to the configuration items of the target basic library in the configuration file and carrying out initialization calling on the configuration class.
12. An electronic device, comprising:
a processor and a memory;
wherein the processor is configured to execute a program stored in the memory;
the memory is to store a program to at least:
acquiring a configuration file; wherein the configuration file comprises configuration items of a plurality of base libraries;
determining a target basic library required to be injected in the basic library according to the configuration file, and declaring the dependence of the target basic library;
and generating a corresponding configuration class according to the configuration items of the target base library in the configuration file, and carrying out initialization calling on the configuration class.
13. A storage medium having stored thereon computer-executable instructions which, when loaded and executed by a processor, carry out the steps of a method for initiating a call to a base library as claimed in any one of claims 1 to 10.
CN201911039418.2A 2019-10-29 2019-10-29 Method and device for initializing and calling basic library, electronic equipment and storage medium Active CN112748905B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911039418.2A CN112748905B (en) 2019-10-29 2019-10-29 Method and device for initializing and calling basic library, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911039418.2A CN112748905B (en) 2019-10-29 2019-10-29 Method and device for initializing and calling basic library, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112748905A true CN112748905A (en) 2021-05-04
CN112748905B CN112748905B (en) 2023-12-08

Family

ID=75640130

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911039418.2A Active CN112748905B (en) 2019-10-29 2019-10-29 Method and device for initializing and calling basic library, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112748905B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114154026A (en) * 2021-11-12 2022-03-08 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN114327655A (en) * 2021-12-27 2022-04-12 云南腾云信息产业有限公司 Component initialization processing method and device and electronic equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090125879A1 (en) * 2005-09-15 2009-05-14 Miloushev Vladimir I Apparatus, Method and System for Building Software by Composition
CN103544005A (en) * 2013-09-10 2014-01-29 Tcl集团股份有限公司 Expansion developing method and device for Android custom control

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090125879A1 (en) * 2005-09-15 2009-05-14 Miloushev Vladimir I Apparatus, Method and System for Building Software by Composition
CN103544005A (en) * 2013-09-10 2014-01-29 Tcl集团股份有限公司 Expansion developing method and device for Android custom control

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114154026A (en) * 2021-11-12 2022-03-08 北京达佳互联信息技术有限公司 Data processing method and device, electronic equipment and storage medium
CN114327655A (en) * 2021-12-27 2022-04-12 云南腾云信息产业有限公司 Component initialization processing method and device and electronic equipment

Also Published As

Publication number Publication date
CN112748905B (en) 2023-12-08

Similar Documents

Publication Publication Date Title
US11853774B2 (en) Dynamically loaded plugin architecture
CN108027722B (en) Dynamically updating applications in compilation and deployment
US10146515B1 (en) Live code updates
CN108319460B (en) Method and device for generating application program installation package, electronic equipment and storage medium
US9274768B2 (en) Runtime code hooking for print driver and functionality testing
US20200183683A1 (en) Application architecture generation
CN112162753A (en) Software deployment method and device, computer equipment and storage medium
CN111897570A (en) Multi-dependency file extraction method and device based on Maven plug-in
CN112748905B (en) Method and device for initializing and calling basic library, electronic equipment and storage medium
CN111176722A (en) Method and device for detecting file version of third-party library and storage medium
CN108132832B (en) Application program starting method and device
CN108595656B (en) Data processing method and system
CN108279905B (en) Method and device for introducing library file into assembly
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN117707543A (en) Application installation package manufacturing and installation method, computing device and storage medium
CN107092472B (en) Dynamic publishing method and device
WO2022222626A1 (en) Incremental source code acquisition method and apparatus, electronic device and storage medium
CN113032004B (en) Method, apparatus and program product for managing development jobs in a development environment
CN114588638A (en) Method for developing game based on Lua language and program development device
CN112612474A (en) Product transplanting method and device, storage medium and electronic equipment
CN111880775A (en) Multi-module layered architecture implementation method and device, electronic equipment and storage medium
CN107632934B (en) Function copying method and device in C-sharp
CN113326184B (en) Interface testing method and device, storage medium and electronic equipment
CN113722538B (en) Interface dynamic rendering method and device
CN112558975B (en) Method and device for switching codes of components, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant