CN110928548B - Data processing method and device - Google Patents

Data processing method and device Download PDF

Info

Publication number
CN110928548B
CN110928548B CN201911115023.6A CN201911115023A CN110928548B CN 110928548 B CN110928548 B CN 110928548B CN 201911115023 A CN201911115023 A CN 201911115023A CN 110928548 B CN110928548 B CN 110928548B
Authority
CN
China
Prior art keywords
module
target
file
class
information
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.)
Active
Application number
CN201911115023.6A
Other languages
Chinese (zh)
Other versions
CN110928548A (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 Music Entertainment Technology Shenzhen Co Ltd
Original Assignee
Tencent Music Entertainment 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 Music Entertainment Technology Shenzhen Co Ltd filed Critical Tencent Music Entertainment Technology Shenzhen Co Ltd
Priority to CN201911115023.6A priority Critical patent/CN110928548B/en
Publication of CN110928548A publication Critical patent/CN110928548A/en
Application granted granted Critical
Publication of CN110928548B publication Critical patent/CN110928548B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a data processing method and equipment, wherein the method comprises the following steps: acquiring a target module containing annotation information through path information of at least one module to be processed, and acquiring module name information of the target module and path information of the target module; generating a first function class according to the module name information of the target module and the path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. By adopting the application, the registration accuracy can be ensured, the working efficiency can be improved, and the development cost can be saved.

Description

Data processing method and device
Technical Field
The present application relates to the field of electronic technologies, and in particular, to a data processing method and apparatus.
Background
In the Android development process, as services are continuously increased, project source codes are more and more, and projects are increasingly huge, in order to solve the problems of serious coupling, large alteration risk and difficult maintenance of different service codes, a modularized scheme is generally adopted to solve the problems, the projects are divided according to service types, and different services are placed into independent sub-projects (module projects) for development. When each Android Application program is started, an Application class is called by the system, and some Application initialization operations, such as third-party SDK initialization, are realized in the Application class. For an Application, the Application class exists only in the shell engineering, and the Application class cannot exist in the module engineering. The module engineering is isolated from the shell engineering, and the initialization logic of the module cannot be directly put into the Application of the shell engineering. In order to enable the modules to execute unique initialization logic in Application, the prior method is to abstract a life cycle interface, enable each module to realize the interface, add the initialization logic of the module in the implementation class to obtain a plurality of life cycle implementation classes, and then call the life cycle implementation classes of all module engineering in a unified way in the Application class of shell engineering, so that the initialization logic of the module is executed in the Application class.
In the above module lifecycle management scheme, since the lifecycle implementation classes of all module projects need to be invoked and registered one by one in the Application class of the shell project. The developer needs to know which modules are integrated, register the life cycle implementation class manually, find out the life cycle implementation class of all the modules, and manually instantiate all the life cycle implementation classes in the Application class of the shell engineering, so that each time one module is added or deleted, the code of the shell engineering needs to be modified again, if omission occurs in the registration process, the omitted module is abnormal in the running process, and the registration process is easy to make mistakes, has large workload and is unfavorable for code maintenance.
Disclosure of Invention
The embodiment of the application provides a data processing method and equipment, which can ensure the accuracy of registration, improve the working efficiency and save the development cost.
In one aspect, an embodiment of the present application provides a data processing method, which may include:
acquiring a target module containing annotation information through path information of at least one module to be processed, and acquiring module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
Generating a first function class according to the module name information of the target module and the path information of the target module;
generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module;
when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file;
and generating a second function class according to the module list, and calling the second function class to initialize the target module.
The method comprises the steps of obtaining a target module containing annotation information through path information of at least one module to be processed, and before obtaining module name information of the target module and path information of the target module, further comprising:
creating a life cycle interface aiming at a module to be processed, adding module initialization logic of the module to be processed to the life cycle interface, and generating a life cycle implementation class;
and adding annotation information matched with the module to be processed in the life cycle implementation class according to the annotation template.
The obtaining, by the path information of at least one module to be processed, the target module including annotation information, obtaining module name information of the target module and path information of the target module includes:
acquiring path information of at least one module to be processed, and inquiring the life cycle implementation class of the module to be processed according to the path information;
if the life cycle implementation class comprises annotation information matched with the module to be processed, determining the module to be processed as a target module;
and acquiring the module name information of the target module and the path information of the target module.
The generating a first function class according to the module name information of the target module and the path information of the target module includes:
generating a class name of a first function class according to the module name information of the target module by adopting a class name template;
generating a method instruction in the first function class according to the path information; the method instructions are for returning an instance of a lifecycle implementation class of the target module.
Generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library, wherein the method comprises the following steps:
Compiling the first function class and codes in the target module corresponding to the first function class to generate a compiled file;
generating a target file with a first format from the compiled file and the resource data of the target module, generating file name information of the target file by adopting module name information and a file name template of the target module, and storing the target file into a file library.
When receiving a file acquisition request, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file, wherein the module list comprises:
when a file acquisition request is received, detecting file name information of all files in a file library, wherein all files contain the target file;
if the file name information of the file is matched with the file name template, determining the matched file as the target file;
and acquiring module name information corresponding to the target file from the file name information of the target file, and generating a module list according to the module name information of the target file.
Generating a second function class according to the module list, and calling the second function class to initialize the target module, wherein the method comprises the following steps:
Acquiring module name information of all target files in the module list, and acquiring a first function class corresponding to the target files according to the module name information;
and generating a second function class according to the first function class by adopting a second class template, and calling the second function class to initialize a module corresponding to the target file through a registration instruction.
In one aspect, an embodiment of the present application provides a data processing apparatus, which may include:
the information acquisition unit is used for acquiring a target module containing annotation information through path information of at least one module to be processed and acquiring module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
the function class generating unit is used for generating a first function class according to the module name information of the target module and the path information of the target module;
the file generation unit is used for generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module;
The list generation unit is used for acquiring the target file from the file library according to the file acquisition request when receiving the file acquisition request, and generating a module list according to the file name information of the target file;
and the initialization unit is used for generating a second function class according to the module list, and calling the second function class to initialize the target module.
Wherein, still include:
the annotation adding unit is used for creating a life cycle interface aiming at a module to be processed, adding module initialization logic of the module to be processed to the life cycle interface and generating a life cycle implementation class; and adding annotation information matched with the module to be processed in the life cycle implementation class according to the annotation template.
The information acquisition unit is specifically configured to:
acquiring path information of at least one module to be processed, and inquiring the life cycle implementation class of the module to be processed according to the path information;
if the life cycle implementation class comprises annotation information matched with the module to be processed, determining the module to be processed as a target module;
and acquiring the module name information of the target module and the path information of the target module.
The function class generating unit is specifically configured to:
generating a class name of a first function class according to the module name information of the target module by adopting a class name template;
generating a method instruction in the first function class according to the path information; the method instructions are for returning an instance of a lifecycle implementation class of the target module.
The file generation unit is specifically configured to:
compiling the first function class and codes in the target module corresponding to the first function class to generate a compiled file;
generating a target file with a first format from the compiled file and the resource data of the target module, generating file name information of the target file by adopting module name information and a file name template of the target module, and storing the target file into a file library.
Wherein, the list generation unit is specifically configured to:
when a file acquisition request is received, detecting file name information of all files in a file library, wherein all files contain the target file;
if the file name information of the file is matched with the file name template, determining the matched file as the target file;
and acquiring module name information corresponding to the target file from the file name information of the target file, and generating a module list according to the module name information of the target file.
The initialization unit is specifically configured to:
acquiring module name information of all target files in the module list, and acquiring a first function class corresponding to the target files according to the module name information;
and generating a second function class according to the first function class by adopting a second class template, and calling the second function class to initialize a module corresponding to the target file through a registration instruction.
In one aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-described method steps.
In one aspect, an embodiment of the present application provides a data processing apparatus, including a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
In the embodiment of the application, a target module containing annotation information is obtained through the path information of at least one module to be processed, and the module name information of the target module and the path information of the target module are obtained; generating a first function class according to the module name information of the target module and the path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. By adopting the method, all the module life cycle realization classes can be automatically identified and found, registration is automatically completed in Application of shell engineering, a developer does not need to manually find out what module is quoted, and the life cycle realization class of each module is not required to be modified, so that the problems that manual registration is easy to make mistakes, large in workload and unfavorable for code maintenance are solved, the registration accuracy can be ensured, the working efficiency is improved, and the development cost is saved.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a system architecture diagram for data processing according to an embodiment of the present application;
FIG. 2 is a schematic flow chart of a data processing method according to an embodiment of the present application;
FIG. 3 is a schematic flow chart of a data processing method according to an embodiment of the present application;
fig. 4 is a schematic view of a scenario of a data processing method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a data processing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Fig. 1 is a system architecture diagram for data processing according to an embodiment of the present application. The server 10f establishes a connection with a cluster of user terminals through the switch 10e and the communication bus 10d, which may include: user terminal 10a, user terminal 10b, user terminal 10c. The database 10g stores a plurality of modules to be processed, and the server 10f obtains a target module containing annotation information through path information of at least one module to be processed, and obtains module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program; the to-be-processed module is a sub-project divided according to different services in a software development project, the sub-project comprises program codes corresponding to the services, the path information is address information of the to-be-processed module, and particularly can be all-level directory information of the to-be-processed module, and the server 10f generates a first function class according to module name information of the target module and path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module; any user terminal in the user terminal cluster can send a file acquisition request, when the server 10f receives the file acquisition request, the server 10f acquires the target file from the file library according to the file acquisition request, and generates a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. The data processing device according to the embodiment of the present application may include a server having data transmission and storage, and the user terminal includes: terminal devices such as tablet computers, smart phones, personal Computers (PCs), notebook computers, palm computers, and the like.
Referring to fig. 2, a flow chart of a data processing method is provided in an embodiment of the application. As shown in fig. 2, the method according to the embodiment of the present application may include the following steps S101 to S103.
S101, obtaining a target module containing annotation information through path information of at least one module to be processed, and obtaining module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
specifically, the data processing device acquires a target module containing annotation information through path information of at least one module to be processed, and acquires module name information of the target module and path information of the target module; the at least one to-be-processed module is used for combining and realizing the service functions of the application program, and it can be understood that the to-be-processed module is a sub-project divided according to different services in a software development project, the sub-project comprises program codes corresponding to the services, the path information is address information of the to-be-processed module, and can be specifically all levels of directory information of the to-be-processed module, the annotation information can be specifically a section of character string, the data processing equipment traverses all to-be-processed modules through the path information of the at least one to-be-processed module, if the module contains the annotation information, the to-be-processed module is determined as a target module, and the module name information of the target module and the path information of the target module are acquired.
S102, generating a first function class according to the module name information of the target module and the path information of the target module;
specifically, the data processing device generates a first function class according to the module name information of the target module and the path information of the target module, and it can be understood that the first function class is a section of program code, and includes a method instruction, where the method instruction is used to return an instance of a life cycle implementation class of the target module, the first function class has a fixed format, the naming of the first function class is according to the module name information of the target module, for example, the generic naming of the first function class is "moduleprovider_xxx" and "xxx" is the module name information of the target module, and specifically, if the module name information of the target module is a, the first function class of the target module a is named moduleprovider_a, and the data processing device generates a method instruction, specifically may be a method get (), and the method get () may return an instance of the life cycle implementation class of the target module.
S103, generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module;
Specifically, the data processing device generates a target file with a first format according to the first function class and the resource data of the target module, and stores the target file in a file library, and it can be understood that the resource data of the target module is data for initializing the target module, specifically, a picture, a dynamic graph, a video, and the like, the target file is a file with the first format generated according to the first function class and the resource data of the target module, the first format is a preset fixed format, specifically, an Android Archive (AAR) file, the target file has a fixed naming format, and is commonly named as "module-xxx. AAR", and specifically, if the module name information of the target module is a, the target file of the target module a is module-a. AAR, and the data processing device stores the generated target file in the file library, where the file with the first format is stored.
S104, when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file;
specifically, when a file acquisition request is received, the data processing device acquires the target file from the file library according to the file acquisition request, and generates a module list according to file name information of the target file, it can be understood that the file acquisition request can be an acquisition instruction for the target file, specifically can be a click instruction or a touch instruction, the file library comprises files with a first format and files with various other formats, the files with the first format comprise files named by the target module and files with other naming rules, when the file acquisition request is received, the data processing device acquires the target file with the first format from the file library according to the file acquisition request, and generating a module list according to the file name information of the target file, wherein the module list stores the module names of at least one target module, specifically, if the target file is an AAR file and the general name is "module-xxx.aar", the data processing device firstly collects all the AAR files, filters the files named as module-xxx.aar from the AAR files, extracts the names "xxx" of the target modules from the file names, for example, the AAR files extracted by the data processing device comprise "module-A.aar", "module-B.aar" and "module-C.aar", and the module names of the three modules corresponding to the three AAR files are "A", "B" and "C", respectively, and the data processing device generates a module list according to the module names of the three modules, wherein the module list comprises "A", "B" and "C".
S105, generating a second function class according to the module list, and calling the second function class to initialize the target module.
Specifically, the data processing device generates a second function class according to the module list, calls the second function class to initialize the target module, and it can be understood that the data processing device generates a second function class with a fixed format according to a first function class corresponding to the module name information of the target module in the module list, the second function class is a section of program code, the second function class includes a method instruction, the method instruction is used for creating the first function class through the first function class, and completing the life cycle registration logic of the module by calling the registration method, the second function class has a fixed format, the method instruction in the second function class can be specifically an init method, the first function class of the target module is obtained through the init method, and the life cycle registration logic of the module is completed by calling the registration method, so as to initialize the target module.
In the embodiment of the application, a target module containing annotation information is obtained through the path information of at least one module to be processed, and the module name information of the target module and the path information of the target module are obtained; generating a first function class according to the module name information of the target module and the path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. By adopting the method, all the module life cycle realization classes can be automatically identified and found, registration is automatically completed in Application of shell engineering, a developer does not need to manually find out what module is quoted, and the life cycle realization class of each module is not required to be modified, so that the problems that manual registration is easy to make mistakes, large in workload and unfavorable for code maintenance are solved, the registration accuracy can be ensured, the working efficiency is improved, and the development cost is saved.
Referring to fig. 3, a flow chart of a data processing method is provided in an embodiment of the present application. As shown in fig. 3, the method according to the embodiment of the present application may include the following steps S201 to S202.
S201, creating a life cycle interface aiming at a module to be processed, adding module initialization logic of the module to be processed to the life cycle interface, and generating a life cycle implementation class; and adding annotation information matched with the module to be processed in the life cycle implementation class according to the annotation template.
Specifically, the data processing device creates a life cycle interface for a module to be processed, adds module initialization logic of the module to be processed to the life cycle interface, and generates a life cycle implementation class; according to the annotation template, annotation information matched with the module to be processed is added in the lifecycle implementation class, it can be understood that the data processing device creates a lifecycle interface for the module to be processed, the lifecycle interface is used for implementing the lifecycle of the module, the module initialization logic of the module to be processed is added in the lifecycle interface to generate the lifecycle implementation class, the lifecycle class includes the module initialization logic used for implementing the module initialization logic, the data processing device adds the annotation information matched with the module to be processed in the lifecycle implementation class according to the annotation template, the annotation template is a universal template of the annotation information, the annotation information is generated through the annotation template and the module name of the module to be processed and is added in the lifecycle implementation class, for example, the annotation template is @ single module ("xxx"), and the xxx is the module name of the module to be processed, and if the module name of the module to be processed is A, the annotation information generated according to the annotation template is @ single module ("A").
S202, obtaining path information of at least one module to be processed, and inquiring the life cycle implementation class of the module to be processed according to the path information;
specifically, the data processing device obtains path information of at least one module to be processed, queries a life cycle implementation class of the module to be processed according to the path information, and it can be understood that the data processing device obtains the path information of at least one module to be processed, the module to be processed is a sub-project divided according to different services in a software development project, the sub-project comprises program codes corresponding to the services, the path information is address information for storing the module to be processed, and can be specifically all-level directory information of the module to be processed, and the data processing device obtains the life cycle implementation class of the module to be processed according to the path information and queries codes of the life cycle implementation class, wherein the codes are used for realizing initialization logic of the module.
S203, if the life cycle implementation class comprises annotation information matched with a module to be processed, determining the module to be processed as a target module; and acquiring the module name information of the target module and the path information of the target module.
Specifically, if the life cycle implementation class includes annotation information matched with a module to be processed, the data processing equipment determines the module to be processed as a target module; the method comprises the steps of obtaining module name information of a target module and path information of the target module, and it is understood that a data processing device detects whether the life cycle implementation class comprises annotation information matched with the to-be-processed module, wherein the annotation information is a specific identifier, specifically can be a section of character string, if the module comprises the annotation information, the to-be-processed module is determined to be the target module, and the module name information of the target module and the path information of the target module are obtained.
S204, a class name template is adopted, and the class name of a first function class is generated according to the module name information of the target module; generating a method instruction in the first function class according to the path information; the method instructions are for returning an instance of a lifecycle implementation class of the target module.
Specifically, the data processing equipment adopts a class name template, generates a class name of a first function class according to the module name information of the target module, and generates a method instruction in the first function class according to the path information; it may be understood that the first function class is a piece of program code, the first function class includes a method instruction, where the method instruction is used to return to an instance of a lifecycle implementation class of the target module, the first function class has a fixed format, the data processing apparatus generates a class name of the first function class according to a module name and a class name template of the target module, for example, the class name template of the first function class is "moduleprovider_xxx" and "xxx" is module name information of the target module, specifically, if the module name information of the target module is a, the first function class of the target module is named as moduleprovider_a, and the data processing apparatus generates a method instruction, specifically may be a method get () according to the path information of the target module, where the method get () may return to the instance of the lifecycle implementation class of the target module.
S205, compiling the first function class and codes in the target module corresponding to the first function class to generate a compiled file;
specifically, the data processing device compiles the first function class and the code in the target module corresponding to the first function class to generate a compiled file, and it can be understood that the data processing device compiles the first function class and the code in the target module corresponding to the first function class to generate a file in a specified format, and specifically, the compiled file may be a file with a suffix name of class.
S206, generating a target file with a first format from the compiled file and the resource data of the target module, generating file name information of the target file by adopting module name information and a file name template of the target module, and storing the target file into a file library.
Specifically, the data processing device generates a target file with a first format from the compiled file and resource data of the target module, generates file name information of the target file by using module name information and a file name template of the target module, and stores the generated target file in a file library, where it can be understood that the resource data of the target module is data for initializing the target module, specifically, a picture, a dynamic view, a video, etc., the target file is a file with the first format generated according to the compiled file and the resource data of the target module, the first format is a preset fixed format, specifically, an Android (AAR) file, the data processing device generates the file name information of the target file by using module name information and a file name template of the target module, and stores the generated target file in a file library, where the file library is used for storing the file with the first format, for example, the file name template is "module-xxx.aaar", if the module name information of the target module is a, the target file of the target module a is a-module name information is a-module-a, and the data processing device stores the target file a-module a.
S207, when a file acquisition request is received, detecting file name information of all files in a file library, wherein all files contain the target file; if the file name information of the file is matched with the file name template, determining the matched file as the target file;
specifically, when a file acquisition request is received, the data processing device detects file name information of all files in a file library, wherein all files contain the target file; if the file name information of the file is matched with the file name template, the matched file is determined to be the target file, it can be understood that the file acquisition request can be an acquisition instruction for the target file, specifically a click instruction or a touch instruction, the file library comprises files with a first format and files with various other formats, the files with the first format comprise files named by the target module and files with other naming rules, when the file acquisition request is received, the file name information of all files in the file library is detected, if the file name information of the file is matched with the file name template, the matched file is determined to be the target file, specifically, if the target file is an AAR file, and the file name template is a module-xxx.aaar', the data processing device firstly collects all AAR files in the file library, filters out files named module-xxx.aaar from the AAR files, and determines the files named module-xxx.aaar as the target file.
S208, module name information corresponding to the target file is obtained from the file name information of the target file, and a module list is generated according to the module name information of the target file.
Specifically, the data processing device obtains module name information corresponding to the target file from file name information of the target file, and generates a module list according to the module name information of the target file, and it can be understood that the data processing device obtains module name information corresponding to the target file from the file name information of the target file, for example, the target file extracted by the data processing device includes "module-a.aar", "module-b.aar", and "module-c.aar", the file name template is "module-xxx.aar", and the names "xxx" of the target modules are extracted from the file names, and the module names of the three modules corresponding to the three AAR files are "a", "B", and "C", and the data processing device generates the module list according to the module names of the target file, specifically, if the module names include "a", "B", and "C", the module names include "a", "B", and "C".
S209, obtaining module name information of all target files in the module list, and obtaining a first function class corresponding to the target files according to the module name information; and generating a second function class according to the first function class by adopting a second class template, and calling the second function class to initialize a module corresponding to the target file through a registration instruction.
Specifically, the data processing equipment acquires module name information of all target files in the module list, and acquires a first function class corresponding to the target files according to the module name information; the second class template is adopted, the second function class is generated according to the first function class, the second function class is called through a registration instruction to initialize the module corresponding to the target file, it can be understood that the data processing equipment obtains module name information of all the target files in the module list, obtains the first function class corresponding to the target files according to the module name information, namely obtains the first function class corresponding to all the target files, adopts the second class template, generates the second function class according to the first function class corresponding to all the target files, the second function class is a section of program code, the second function class comprises a method instruction, completes the life cycle registration logic of the module through calling the registration method, the second function class has a fixed format, the method instruction in the second function class can be specifically an init method, obtains the first function class of the target module through the init method, and completes the life cycle registration logic of the module through calling the registration method, and initializes the target module.
In the embodiment of the application, a target module containing annotation information is obtained through the path information of at least one module to be processed, and the module name information of the target module and the path information of the target module are obtained; generating a first function class according to the module name information of the target module and the path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. By adopting the method, all the module life cycle realization classes can be automatically identified and found, registration is automatically completed in Application of shell engineering, a developer does not need to manually find out what module is quoted, and the life cycle realization class of each module is not required to be modified, so that the problems that manual registration is easy to make mistakes, large in workload and unfavorable for code maintenance are solved, the registration accuracy can be ensured, the working efficiency is improved, and the development cost is saved.
A specific implementation scenario provided for the embodiment of the present application will be described with reference to fig. 4, as shown in fig. 4. The embodiment of the application provides a scene schematic diagram of data processing equipment. When a developer creates a life cycle class of a module to be processed, annotation information is added in all life cycle implementation classes, specifically, annotation can be achieved by using an annotation template @ Single Module ("xxx"), wherein "xxx" is the name of the module, then the annotation information is declared at the top of the life cycle implementation class, specifically, the annotation information @ Single Module ("A") is added in the module A, the annotation information @ Single Module ("B") is added in the module B, and the annotation information @ Single Module ("C") is added in the module C.
When the module is required to be released after development, a module engineering compiling device is started, the device firstly collects annotation information defined in the module to be processed by using an APT (annotation processing tool), after the APT collects the module name and a complete class path of a life cycle implementation class, a class with a fixed format is automatically generated, the naming format can adopt 'ModuleProvider_xxx' and 'xxx' as module names, the class only comprises a method get (), and one example of the life cycle implementation class of the current module is returned in the method. After the moduleprovider_xxx class is generated, all source codes and resources in the module engineering are packaged into a target file in a fixed format, wherein the target file can be an AAR file named as module-xxx. AAR', specifically, the target file A is module-A. AAR, the target file B is module-B. AAR, and the target file C is module-C. AAR.
At the shell engineering compiling period, calling a shell engineering compiling device to collect all aar files, filtering aar files named as 'module-xxx. Aar', and intercepting the names xxx of the modules to generate a module list containing all module names; the shell engineering compiling device automatically generates a second function class with a fixed format according to the module list containing all the module names, and the second function class can be M classes. An init method exists in the M classes, a real life cycle realization class is created one by one through a moduleprovider_xxx class in the method, and then a registration method is called, so that life cycle registration logic of all modules is completed; it should be noted that, the internal flow of the scheme is shown in the dashed line box in fig. 4, and the whole module lifecycle registration flow can be completed by only calling the lifecycle registration plug-in and finally calling the init method in the M class in the shell engineering. By adopting the scheme, a developer does not need to manually find out what modules are quoted and the life cycle implementation class of each module, does not need to register in the Application class of the shell engineering one by one, and adds and deletes the modules, does not need to modify the Application class of the shell engineering, and can automatically complete the life cycle registration work of all the modules by only fixedly referencing the M classes in the Application of the shell engineering, thereby avoiding the possible omission problem of manual registration, avoiding the workload of registering one by one and improving the flexibility of code maintenance.
Referring to fig. 5, a schematic structural diagram of a data processing apparatus is provided in an embodiment of the present application. As shown in fig. 5, the data processing apparatus 1 of the embodiment of the present application may include: an information acquisition unit 11, a function class generation unit 12, a file generation unit 13, a list generation unit 14, an initialization unit 15, and an annotation addition unit 16.
An annotation adding unit 16, configured to create a lifecycle interface for a module to be processed, add module initialization logic of the module to be processed to the lifecycle interface, and generate a lifecycle implementation class; and adding annotation information matched with the module to be processed in the life cycle implementation class according to the annotation template.
Specifically, the annotation adding unit 16 creates a lifecycle interface for a module to be processed, adds module initialization logic of the module to be processed to the lifecycle interface, and generates a lifecycle implementation class; according to the annotation template, annotation information matched with the module to be processed is added in the lifecycle implementation class, it can be understood that the data processing device creates a lifecycle interface for the module to be processed, the lifecycle interface is used for implementing the lifecycle of the module, the module initialization logic of the module to be processed is added in the lifecycle interface to generate the lifecycle implementation class, the lifecycle class includes the module initialization logic used for implementing the module initialization logic, the data processing device adds the annotation information matched with the module to be processed in the lifecycle implementation class according to the annotation template, the annotation template is a universal template of the annotation information, the annotation information is generated through the annotation template and the module name of the module to be processed and is added in the lifecycle implementation class, for example, the annotation template is @ single module ("xxx"), and the xxx is the module name of the module to be processed, and if the module name of the module to be processed is A, the annotation information generated according to the annotation template is @ single module ("A").
An information obtaining unit 11, configured to obtain a target module including annotation information through path information of at least one module to be processed, and obtain module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
specifically, the information obtaining unit 11 obtains a target module including annotation information through path information of at least one module to be processed, and obtains module name information of the target module and path information of the target module; the at least one to-be-processed module is used for combining and realizing the service functions of the application program, and it can be understood that the to-be-processed module is a sub-project divided according to different services in a software development project, the sub-project comprises program codes corresponding to the services, the path information is address information of the to-be-processed module, and can be specifically all levels of directory information of the to-be-processed module, the annotation information can be specifically a section of character string, the data processing equipment traverses all to-be-processed modules through the path information of the at least one to-be-processed module, if the module contains the annotation information, the to-be-processed module is determined as a target module, and the module name information of the target module and the path information of the target module are acquired.
A function class generating unit 12, configured to generate a first function class according to module name information of the target module and path information of the target module;
specifically, the function class generating unit 12 generates a first function class according to the module name information of the target module and the path information of the target module, and it may be understood that the first function class is a section of program code, and includes a method instruction in the first function class, where the method instruction is used to return an instance of the life cycle implementation class of the target module, the first function class has a fixed format, the naming of the first function class is according to the module name information of the target module, for example, the generic naming of the first function class is "moduleprovider_xxx" and "xxx" is the module name information of the target module, specifically, if the module name information of the target module is a, the first function class of the target module a is named as moduleprovider_a, and the data processing apparatus generates a method instruction according to the path information of the target module, specifically may be a method get (), and the method get () may return an instance of the life cycle implementation class of the target module.
A file generating unit 13, configured to generate a target file with a first format according to the first function class and the resource data of the target module, and store the target file in a file library; the resource data is used for realizing the module initialization of the target module;
Specifically, the file generating unit 13 generates a target file with a first format according to the first function class and the resource data of the target module, and stores the target file in a file library, and it can be understood that the resource data of the target module is data for initializing the target module, specifically may be a picture, a dynamic graph, a video, and the like, the target file is a file with the first format generated according to the first function class and the resource data of the target module, the first format is a preset fixed format, specifically may be an AAR file, the target file has a fixed naming format, and is commonly named as "module-xxx.aar", and specifically, if the module name information of the target module is a, the target file of the target module a is module-a.aar, and the data processing device stores the generated target file in the file library, where the file library is used for storing the file with the first format.
A list generating unit 14, configured to, when a file acquisition request is received, acquire the target file from the file library according to the file acquisition request, and generate a module list according to file name information of the target file;
specifically, when a file acquisition request is received, the list generating unit 14 acquires the target file from the file library according to the file acquisition request, and generates a module list according to file name information of the target file, it is understood that the file acquisition request may be an acquisition instruction for the target file, specifically, a click instruction or a touch instruction, the file library includes files having a first format and files having various other formats, the files having the first format include files named by the target module and files having other naming rules, when a file acquisition request is received, the data processing apparatus acquires the target file having the first format from the file library according to the file acquisition request, and generating a module list according to the file name information of the target file, wherein the module list stores the module names of at least one target module, specifically, if the target file is an AAR file and the general name is "module-xxx.aar", the data processing device firstly collects all the AAR files, filters the files named as module-xxx.aar from the AAR files, extracts the names "xxx" of the target modules from the file names, for example, the AAR files extracted by the data processing device comprise "module-A.aar", "module-B.aar" and "module-C.aar", and the module names of the three modules corresponding to the three AAR files are "A", "B" and "C", respectively, and the data processing device generates a module list according to the module names of the three modules, wherein the module list comprises "A", "B" and "C".
And the initializing unit 15 is configured to generate a second function class according to the module list, and call the second function class to perform module initialization on the target module.
Specifically, the initializing unit 15 generates a second function class according to the module list, calls the second function class to initialize the target module, and it can be understood that the data processing device generates a second function class with a fixed format according to a first function class corresponding to the module name information of the target module in the module list, where the second function class is a section of program code, the second function class includes a method instruction, where the method instruction is used to create the first function class by the first function class, and complete the life cycle registration logic of the module by calling the registration method, the second function class has a fixed format, where the method instruction in the second function class may be specifically an init method, obtains the first function class of the target module by the init method, and completes the life cycle registration logic of the module by calling the registration method, and initializes the target module.
In the embodiment of the application, a target module containing annotation information is obtained through the path information of at least one module to be processed, and the module name information of the target module and the path information of the target module are obtained; generating a first function class according to the module name information of the target module and the path information of the target module; generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file; and generating a second function class according to the module list, and calling the second function class to initialize the target module. By adopting the method, all the module life cycle realization classes can be automatically identified and found, registration is automatically completed in Application of shell engineering, a developer does not need to manually find out what module is quoted, and the life cycle realization class of each module is not required to be modified, so that the problems that manual registration is easy to make mistakes, large in workload and unfavorable for code maintenance are solved, the registration accuracy can be ensured, the working efficiency is improved, and the development cost is saved.
Referring to fig. 6, a schematic structural diagram of a data processing apparatus is provided in an embodiment of the present application. As shown in fig. 6, the data processing apparatus 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, at least one communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display (Display), and the optional user interface 1003 may further include a standard wired interface, a wireless interface, among others. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 6, an operating system, network communication modules, user interface modules, and data processing applications may be included in memory 1005, which is a type of computer storage medium.
In the data processing apparatus 1000 shown in fig. 6, the network interface 1004 may provide a network communication function, and the user interface 1003 is mainly an interface for providing input to a user; the processor 1001 may be configured to invoke the data processing application stored in the memory 1005 to implement the description of the data processing method in any of the embodiments corresponding to fig. 2 to 4, which is not described herein.
It should be understood that the data processing apparatus 1000 described in the embodiment of the present application may perform the description of the data processing method in the embodiment corresponding to any one of fig. 2 to fig. 4, and may also perform the description of the data processing apparatus in the embodiment corresponding to fig. 5, which is not repeated herein. In addition, the description of the beneficial effects of the same method is omitted.
Furthermore, it should be noted here that: the embodiment of the present application further provides a computer readable storage medium, where a computer program executed by the aforementioned data processing apparatus is stored, where the computer program includes program instructions, when executed by the processor, can perform the description of the data processing method in any of the foregoing embodiments corresponding to fig. 2 to 4, and therefore, a description will not be given here. In addition, the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiments of the computer-readable storage medium according to the present application, please refer to the description of the method embodiments of the present application.
Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), or the like.
The foregoing disclosure is illustrative of the present application and is not to be construed as limiting the scope of the application, which is defined by the appended claims.

Claims (9)

1. A method of data processing, comprising:
acquiring a target module containing annotation information through path information of at least one module to be processed, and acquiring module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
generating a first function class according to the module name information of the target module and the path information of the target module; the first function class comprises a first method instruction, and the first method instruction is used for returning to an instance of a life cycle implementation class of the target module;
generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module;
when a file acquisition request is received, acquiring the target file from the file library according to the file acquisition request, and generating a module list according to file name information of the target file;
Generating a second function class according to the module list, calling the second function class to initialize the target module, wherein the method comprises the following steps: acquiring module name information of all target files in the module list, and acquiring a first function class corresponding to the target files according to the module name information; generating a second function class according to the first function class by adopting a second class template, and calling the second function class to initialize a module corresponding to the target file through a registration instruction; the second function class comprises a second method instruction, and the second method instruction is used for creating life cycle realization classes one by one through the first function class and calling a registration method to complete life cycle registration logic of the target module.
2. The method according to claim 1, wherein the obtaining, by the path information of the at least one module to be processed, the target module including annotation information, and before obtaining the module name information of the target module and the path information of the target module, further comprises:
creating a life cycle interface aiming at a module to be processed, adding module initialization logic of the module to be processed to the life cycle interface, and generating a life cycle implementation class;
And adding annotation information matched with the module to be processed in the life cycle implementation class according to the annotation template.
3. The method according to claim 1, wherein the obtaining the target module including the annotation information by the path information of the at least one module to be processed, obtaining the module name information of the target module and the path information of the target module, includes:
acquiring path information of at least one module to be processed, and inquiring the life cycle implementation class of the module to be processed according to the path information;
if the life cycle implementation class comprises annotation information matched with the module to be processed, determining the module to be processed as a target module;
and acquiring the module name information of the target module and the path information of the target module.
4. The method of claim 2, wherein the generating a first class of functions from the module name information of the target module and the path information of the target module comprises:
generating a class name of a first function class according to the module name information of the target module by adopting a class name template;
generating a method instruction in the first function class according to the path information; the method instructions are for returning an instance of a lifecycle implementation class of the target module.
5. The method of claim 1, wherein generating a target file having a first format from the first function class and the resource data of the target module, storing the target file in a file repository, comprises:
compiling the first function class and codes in the target module corresponding to the first function class to generate a compiled file;
generating a target file with a first format from the compiled file and the resource data of the target module, generating file name information of the target file by adopting module name information and a file name template of the target module, and storing the target file into a file library.
6. The method according to claim 1, wherein when a file acquisition request is received, the target file is acquired from the file library according to the file acquisition request, and a module list is generated according to file name information of the target file, including:
when a file acquisition request is received, detecting file name information of all files in a file library, wherein all files contain the target file;
if the file name information of the file is matched with the file name template, determining the matched file as the target file;
And acquiring module name information corresponding to the target file from the file name information of the target file, and generating a module list according to the module name information of the target file.
7. A data processing apparatus, comprising:
the information acquisition unit is used for acquiring a target module containing annotation information through path information of at least one module to be processed and acquiring module name information of the target module and path information of the target module; the at least one module to be processed is used for combining and realizing the business functions of the application program;
the function class generating unit is used for generating a first function class according to the module name information of the target module and the path information of the target module; the first function class comprises a first method instruction, and the first method instruction is used for returning to an instance of a life cycle implementation class of the target module;
the file generation unit is used for generating a target file with a first format according to the first function class and the resource data of the target module, and storing the target file into a file library; the resource data is used for realizing the module initialization of the target module;
the list generation unit is used for acquiring the target file from the file library according to the file acquisition request when receiving the file acquisition request, and generating a module list according to the file name information of the target file;
The initialization unit is configured to generate a second function class according to the module list, call the second function class to perform module initialization on the target module, and includes: acquiring module name information of all target files in the module list, and acquiring a first function class corresponding to the target files according to the module name information; generating a second function class according to the first function class by adopting a second class template, and calling the second function class to initialize a module corresponding to the target file through a registration instruction; the second function class comprises a second method instruction, and the second method instruction is used for creating life cycle realization classes one by one through the first function class and calling a registration method to complete life cycle registration logic of the target module.
8. A computer storage medium, characterized in that the computer storage medium stores a computer program comprising program instructions which, when executed by a processor, perform the method of any of claims 1-6.
9. A data processing apparatus, characterized by comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1-6.
CN201911115023.6A 2019-11-14 2019-11-14 Data processing method and device Active CN110928548B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911115023.6A CN110928548B (en) 2019-11-14 2019-11-14 Data processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911115023.6A CN110928548B (en) 2019-11-14 2019-11-14 Data processing method and device

Publications (2)

Publication Number Publication Date
CN110928548A CN110928548A (en) 2020-03-27
CN110928548B true CN110928548B (en) 2023-08-22

Family

ID=69853914

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911115023.6A Active CN110928548B (en) 2019-11-14 2019-11-14 Data processing method and device

Country Status (1)

Country Link
CN (1) CN110928548B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488144B (en) * 2020-04-17 2024-03-19 腾讯音乐娱乐科技(深圳)有限公司 Data processing method and device
CN111752601A (en) * 2020-06-19 2020-10-09 贝壳技术有限公司 Data configuration method, device and system, electronic equipment and storage medium thereof
CN115080006A (en) * 2021-03-15 2022-09-20 武汉斗鱼网络科技有限公司 Data calling method and related equipment
CN114168111B (en) * 2021-12-07 2024-04-05 北京五八信息技术有限公司 Method, device, product and storage medium for realizing componentized route

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103793257A (en) * 2014-03-07 2014-05-14 中南大学 Streaming Android program executing method
CN106528230A (en) * 2016-11-03 2017-03-22 用友网络科技股份有限公司 Application program management method, management device and client equipment
CN106648690A (en) * 2016-12-29 2017-05-10 北京恒华伟业科技股份有限公司 Code automatic generation method and apparatus
CN108038222A (en) * 2017-12-22 2018-05-15 冶金自动化研究设计院 System for Information System Modeling and entity-property frame of data access
CN108121563A (en) * 2017-11-10 2018-06-05 广州阿里巴巴文学信息技术有限公司 Application function method for customizing, device, computing device and storage medium
CN110045997A (en) * 2019-04-15 2019-07-23 武汉斗鱼鱼乐网络科技有限公司 Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190129712A1 (en) * 2017-10-27 2019-05-02 Intuit Inc. Methods, systems, and computer program products for an integrated platform for continuous deployment of software application delivery models

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103793257A (en) * 2014-03-07 2014-05-14 中南大学 Streaming Android program executing method
CN106528230A (en) * 2016-11-03 2017-03-22 用友网络科技股份有限公司 Application program management method, management device and client equipment
CN106648690A (en) * 2016-12-29 2017-05-10 北京恒华伟业科技股份有限公司 Code automatic generation method and apparatus
CN108121563A (en) * 2017-11-10 2018-06-05 广州阿里巴巴文学信息技术有限公司 Application function method for customizing, device, computing device and storage medium
CN108038222A (en) * 2017-12-22 2018-05-15 冶金自动化研究设计院 System for Information System Modeling and entity-property frame of data access
CN110045997A (en) * 2019-04-15 2019-07-23 武汉斗鱼鱼乐网络科技有限公司 Object initialization method, apparatus, equipment and the storage medium of fundamental functional modules

Also Published As

Publication number Publication date
CN110928548A (en) 2020-03-27

Similar Documents

Publication Publication Date Title
CN110928548B (en) Data processing method and device
CN110888842A (en) File storage method, file query method, file storage device, file query device and file query equipment
CN111399840B (en) Module development method and device
CN110688096B (en) Method and device for constructing application program containing plug-in, medium and electronic equipment
CN112769706B (en) Componentized routing method and system
US20130124611A1 (en) Unified repository & tool infrastructure
CN111488144B (en) Data processing method and device
CN114579109A (en) Code generation method and device, electronic equipment and storage medium
CN107633080B (en) User task processing method and device
JP2005228183A (en) Program execution method and computer system for executing the program
CN115145806A (en) Data acquisition method and device and computer readable storage medium
CN106484375B (en) Instruction block loading method, soft switch equipment and system
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN116578282A (en) Code generation method, device, electronic equipment and medium
CN113986312B (en) Software upgrading method and device, electronic equipment and computer readable storage medium
CN111488286B (en) Method and device for independently developing Android modules
CN114880020A (en) Software development kit management method, related device and computer program product
CN107092601B (en) Resource file construction method, resource file application method and device
CN114546410A (en) Code optimization method based on design mode and related equipment
CN114064176A (en) View interaction method and device, electronic equipment and computer readable medium
CN114816445A (en) System platform architecture, function publishing method and device, platform and storage medium
CN108089899B (en) Method and device for realizing query report
CN117724726B (en) Data processing method and related device
CN114995830B (en) Code compiling method and device
CN115878282A (en) Cross-platform interaction method, device and equipment

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