CN112346774A - Method and device for generating application installation package - Google Patents

Method and device for generating application installation package Download PDF

Info

Publication number
CN112346774A
CN112346774A CN201910720776.3A CN201910720776A CN112346774A CN 112346774 A CN112346774 A CN 112346774A CN 201910720776 A CN201910720776 A CN 201910720776A CN 112346774 A CN112346774 A CN 112346774A
Authority
CN
China
Prior art keywords
network
class
network monitoring
interface
generating
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.)
Pending
Application number
CN201910720776.3A
Other languages
Chinese (zh)
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910720776.3A priority Critical patent/CN112346774A/en
Publication of CN112346774A publication Critical patent/CN112346774A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/02Arrangements for optimising operational condition

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The invention discloses a method and a device for generating an application installation package, and relates to the technical field of computers. One embodiment of the method comprises: generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits; compiling the target file into a binary class file; and replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, thereby generating the application installation package. The implementation mode can solve the technical problems of high maintenance difficulty and insufficient light weight.

Description

Method and device for generating application installation package
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for generating an application installation package.
Background
Network performance optimization is crucial to the user experience of applications, such as: page loading exceeds 3 seconds and 57% of users will leave. Before network optimization, the network performance of the mobile terminal needs to be effectively monitored. Currently, the following methods are available for monitoring the network performance of the mobile terminal:
1) a network component developer manually implants codes to acquire performance parameters such as network request time consumption, network abnormity, success rate statistics and the like, and then reports data to a cloud service to perform data aggregation so as to achieve the purpose of monitoring;
2) the mobile application realizes network performance monitoring by accessing a third party payment SDK (Software Development Kit);
3) the mobile application adopts an AOP (Aspect organized Programming) mode to monitor the network performance, thereby achieving the purpose of non-invasive monitoring.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
for mode 1): firstly, a network monitoring developer needs to know network request native codes of all application programs, so that various troublesome problems such as code learning cost, code access authority and the like are involved; second, due to the fast iteration of the business code, the code that the developer manually implants may be optimized or tampered, which requires a significant maintenance cost; thirdly, the mobile terminal monitoring mode is difficult to output as a platform product after being developed and perfected, and is not beneficial to platform popularization.
For mode 2): firstly, the third party paid SDK is taken as a commercial product, and an access party is equivalent to a technical black box, so that customized demand development on network monitoring cannot be carried out; secondly, the third party paid SDK brings economic cost to the application program, and is more prone to a self-developed performance monitoring platform for a technical company with independent research and development capability; third, the use of paid third party SDKs, which is equivalent to reporting data to a third party monitoring platform, can involve the problem of leakage of business private data.
For mode 3), the following: due to the adoption of some mature AOP frameworks, functions cannot be tailored, which results in additional overhead for the host, such as an increase in the number of methods or the size of installation packages. At present, the open source APM framework mainly includes Argus and Matrix, and these open source frameworks mainly use AOP method to monitor network performance, thereby technically realizing non-invasive performance monitoring. However, Argus uses an AspectJ (an AOP implemented in annotated form at compile time) framework for network status monitoring, and the AspectJ framework has problems of a large number of methods for hosts or an increase in installation package size; the Matrix framework lacks support for monitoring the umts network.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for generating an application installation package, so as to solve the technical problems of high maintenance difficulty and insufficient light weight.
In order to achieve the above object, according to an aspect of the embodiments of the present invention, there is provided a method for generating an application installation package, including:
generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits;
compiling the target file into a binary class file;
and replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, thereby generating the application installation package.
Optionally, replacing the network component interface in the class file with a customized interface in the network monitoring toolkit by using a byte manipulation framework, including:
analyzing the class file to generate a tree-type byte code structure;
traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit, including:
through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
Optionally, before generating the target file based on the mobile application development framework, the method further includes:
enumerating network component interfaces corresponding to the network components;
respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit;
integrating the network monitoring toolkit into a mobile application development framework.
Optionally, the network monitoring toolkit is configured to collect network monitoring parameters of the mobile terminal, and report the network monitoring parameters in a timed or real-time manner;
wherein the network monitoring parameters include at least one of:
the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting uniform resource locator, uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time with a server, domain name query time and Http return code.
In addition, according to another aspect of the embodiments of the present invention, there is provided an apparatus for generating an application installation package, including:
the generation module is used for generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits;
the compiling module is used for compiling the target file into a binary class file;
and the replacing module is used for replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework so as to generate the application installation package.
Optionally, the replacement module is configured to:
analyzing the class file to generate a tree-type byte code structure;
traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit, including:
through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
Optionally, the system further comprises an integration module configured to:
enumerating network component interfaces corresponding to the network components before generating a target file based on a mobile application development framework;
respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit;
integrating the network monitoring toolkit into a mobile application development framework.
Optionally, the network monitoring toolkit is configured to collect network monitoring parameters of the mobile terminal, and report the network monitoring parameters in a timed or real-time manner;
wherein the network monitoring parameters include at least one of:
the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting uniform resource locator, uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time with a server, domain name query time and Http return code.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any of the embodiments described above.
According to another aspect of the embodiments of the present invention, there is also provided a computer readable medium, on which a computer program is stored, which when executed by a processor implements the method of any of the above embodiments.
One embodiment of the above invention has the following advantages or benefits: because the byte control framework is adopted, the customized interface in the network monitoring tool package replaces the network component interface in the class file, and the technical means of the application installation package is generated, the technical problems of large maintenance difficulty and insufficient light weight in the prior art are solved. The embodiment of the invention uses the ASM to realize the monitoring of the network performance of the mobile application by using the AOP idea, and has the following beneficial effects: 1) the non-invasive code implantation technology is adopted, so that the problems of labor cost caused by manual code implantation and service and monitoring logic coupling caused by invasive codes are solved; 2) the platform output can be realized, and different applications can be easily accessed to the network performance monitoring function; 3) adopting a lighter-weight AOP scheme and an ASM to realize non-invasive code implantation, and minimizing extra cost introduced to a host after a user accesses; 4) the monitoring by adopting a third party paid SDK is avoided, a developer can flexibly customize the requirements and can be deployed on a private platform, and the risk of business privacy data leakage is avoided; 5) the method can cover the existing mobile terminal network components, can perform fine performance monitoring on the mobile network, and is convenient for a user to fully monitor the network performance of the mobile terminal of the user on the line.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a generation method of an application installation package according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of network monitoring parameters according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of several ways of customizing an interface according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of 10 items in a Java class file according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating a main flow of a method for generating an application installation package according to a referential embodiment of the present invention;
FIG. 6 is a comparison of AOP bottom layer technologies;
fig. 7 is a schematic diagram of main modules of a generation apparatus of an application installation package according to an embodiment of the present invention;
FIG. 8 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 9 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a method for generating an application installation package according to an embodiment of the present invention. As an embodiment of the present invention, as shown in fig. 1, the method for generating an application installation package may include:
step 101, generating a target file based on a mobile application development framework.
In this step, target files may be generated based on the mobile application development framework, including source files, project dependent software packages (jar packages), resources (such as pictures, audio, etc.), configuration files (page layout for applications, etc.), and network monitoring toolkits.
In general, a mobile application development framework includes a native network component layer, a network interface layer, and a business development layer. Native network component layer: the native network component refers to a native component provided by a mobile terminal system or an independent network component sourced by a third party, and a developer can select different components to initiate a network request. For example, the Android system application currently provides three major network components, an http component, and an http component. Network interface layer: the network interface layer mainly works to perform interface encapsulation on the native components, and developers can use corresponding network components to initiate network requests by calling the interfaces. And a service development layer: the service development layer belongs to the uppermost layer of the application, the layer realizes specific services by using interfaces provided by the network interface layer, and a service developer does not need to know the realization of the bottom layer and concentrates on the development of the services.
It should be noted that the mobile application development framework is further integrated with a network monitoring toolkit, so that the generated target file includes the network monitoring toolkit (i.e., an SDK, which is generally a collection of development tools used by some software engineers to build application software for a specific software package, software framework, hardware platform, operating system, and the like). The network monitoring tool package is used for collecting network monitoring parameters of the mobile terminal and reporting the network monitoring parameters in a timed or real-time mode. As shown in fig. 2, the network monitoring parameters include at least one of: the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting Uniform Resource Locator (URL), uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time (TCP handshake time and/or SSL handshake time) with a server, Domain Name System (DNS) query time and Http return code. The network monitoring toolkit has the functions of collecting network monitoring parameters of the mobile terminal and reporting the collected network monitoring parameters to the cloud service, and the reporting mode can be realized by issuing a reporting strategy by the cloud service and utilizing a timing reporting mode or a real-time reporting mode.
Optionally, before step 101, the method further comprises: enumerating network component interfaces corresponding to the network components; respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit; integrating the network monitoring toolkit into a mobile application development framework. Network interface implementation AOP first needs to enumerate all possible call interfaces (e.g., A, B, C, etc.) requested by the network components commonly used by the mobile terminal, which can be understood as finding a network monitoring section, and then, provides corresponding customized interfaces (e.g., a ', B ', C ', etc.) for each interface.
For example, in an Android mobile application, commonly used network components for sending Http network requests include: an Okhttp component, an http component, and an http connection component. The common interfaces of these three network components generally include the following: okhttp components-enqueue, newCall, and execute; an http component-execute; http connection components getContent, openConnection and openStream.
Customizing and reconstructing the network component interfaces corresponding to the enumerated network components, and respectively generating the customized interfaces corresponding to the enumerated network components, so as to respectively provide alternative customized interfaces for the network component interfaces, and prepare for interface replacement in step 103.
A Java interface is a declaration of a series of methods, which is a collection of some method features. Optionally, the interface is generally customized in the following ways: as shown in fig. 3a, time tags are printed before and after the method to perform the method time consumption statistics; as shown in fig. 3b, the acquisition of the relevant parameters is performed before the method or after the function; as shown in fig. 3c, the original method is directly replaced. It should be noted that the interface customization modes are not limited to the three types described above, and different modes may be adopted to generate the customized interface according to different network monitoring parameters to be collected by the network monitoring toolkit.
Step 102, compiling the target file into a binary class file.
In this step, java (java compiler) may be used to compile the target file generated in step 101 into a binary class file, that is, compile a source file, a software package dependent on engineering, a resource, a configuration file, a network monitoring tool package, and the like into a binary class file (file with an extension of "class"). Each legal Java class file has an accurate definition, and it is the accurate definition that makes the Java virtual machine correctly read and interpret all Java class files.
The Java class file is a binary stream of 8-bit bytes, data items are stored in the class file in sequence, and no space is reserved between adjacent items, so that the class file becomes compact and the storage space is reduced. Many items with different sizes are contained in the Java class file, and the structure of each item is strictly specified, so that the class file can be successfully analyzed from beginning to end. As shown in fig. 4, a Java class file can be classified into approximately 10 items:
magic: this item stores the magic number (magic number) and version information of a Java class file. The first 4 bytes of a Java class file are called its magic number. Each correct Java class file is started with 0xCAFEBABE, which ensures that the Java virtual machine can easily distinguish Java files from non-Java files.
Version: the item stores the version information of the Java class file and has important significance for one Java file. As Java technology has been developed, the format of class files is also in constant change. The version information of the class file lets the virtual machine know how to read and process the class file.
Constant Pool: the item stores constants such as various character strings, class names, method names and interface names, final variables, and reference information to external classes in the class. The virtual machine must maintain a constant pool for each class loaded, in which symbolic references of all types, fields and methods used by the corresponding type are stored, so that it plays a core role in the dynamic linking of Java. The size of the constant pool accounts for on average about 60% of the size of the whole class.
Access _ flag: the item indicates whether a class or an interface is defined in the file, and also refers to an access mark of the class or the interface, such as public, private, abstrat and other information.
This Class: a pointer to a string constant representing the class of fully qualified names.
Super Class: a pointer to a string constant representing the parent fully qualified name.
Interfaces: and the pointer array stores pointers of the character string constants of all the interface names realized by the class or the parent class. The constants pointed to by the above three terms, particularly the first two terms, generally need to be modified when we derive a new class from an existing class using ASM: changing the class name to a subclass name; changing the parent class into the class name before derivation; if necessary, a new implementation interface is added.
Fields: this entry describes in detail the fields declared in a class or interface. It should be noted that the fields list only fields in the class or interface, and does not include fields inherited from the super class and parent interface.
Methods: this item describes in detail the methods declared in a class or interface. Such as the name of the method, the parameter and the return value type, etc. It should be noted that the Methods list only stores the Methods in the class or the interface, and does not include Methods inherited from the super class and the parent interface.
Class attributes: this item holds the basic information of the properties defined by the class or interface in the file.
103, replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, thereby generating an application installation package.
Specifically, the binary class file in step 102 may be modified by using ASM, and the customized interface in the network monitoring toolkit replaces the network component interface in the class file, where the modified class file is the application installation package. Generally, the primary thing to replace is the source file and the network component interfaces in the software package that the engineering relies on.
ASM is a Java bytecode manipulation framework that can be used to dynamically generate classes or enhance the functionality of existing classes. The ASM can either directly generate the binary class file or dynamically change the class behavior before the class is loaded into the Java virtual machine. Java class is stored in a strictly format defined class file, which has enough metadata to parse all the elements in the class: class name, method, attribute, and Java bytecode (instruction). After the ASM reads information from the class file, the ASM can change class behaviors, analyze class information and even generate a new class according to user requirements. Therefore, the embodiment of the invention modifies the applied network interface layer based on the ASM byte code editing technology and the idea of AOP (Aspect Oriented Programming) to customize the interface to replace the corresponding network component interface, thereby realizing the monitoring function with non-invasive and low cost.
Optionally, step 103 may specifically include: analyzing the class file to generate a tree-type byte code structure; traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
The ASM represents a complex byte code structure through a data structure of a tree, and traverses the tree byte code structure by using a Push model, and modifies byte codes in the traversing process. The so-called Push model is similar to a simple Visator design mode, and because the byte code structure to be processed is fixed, a Vistable interface does not need to be specially abstracted, and only the Visator interface needs to be provided.
Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit, including: through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
ClassReader class: a bytecode reading and analyzing engine. It adopts an event reading mechanism similar to SAX, and calls the registered ClassVisitor, AnnotationVisitor, FieldVisitor and MethodVisitor to perform corresponding processing whenever an event occurs.
Class ClassVisitor: defining events which can be triggered when reading the Class byte codes, such as Class header parsing completion, annotation parsing, field parsing, method parsing and the like.
ClassWriter class, which implements the ClassVisitor interface for splicing bytecodes.
MethodVisitor class: events triggered when a method is parsed are defined, such as annotations, properties, code, etc. on the method.
Therefore, the interface replacement can be realized by calling the four key classes, and the modified class file is obtained.
The customized interface in the network monitoring toolkit mainly functions as a network data collection function, as shown in fig. 2, basic parameters of a network request can be collected, and then data is collected and reported to a cloud service to realize a monitoring function. The customized interface is realized by adding network request data acquisition logic, such as response time, uplink and downlink flow and the like, under the condition of keeping the original network interface calling logic unchanged. Therefore, the embodiment of the invention uses the ASM to realize the monitoring of the network performance of the mobile application by using the AOP thought, and the implantation of the monitoring function realizes the development of a non-invasive mode, thereby greatly reducing the user access cost; meanwhile, the adoption of the ASM to edit the byte codes can reduce the number of methods for hosts and the increment of the size of the installation package, and the method has more advantages compared with other implementation modes (such as an AspectJ framework).
According to the various embodiments, it can be seen that the technical means of generating the application installation package is achieved by replacing the network component interface in the class file with the customized interface in the network monitoring toolkit through the byte manipulation framework, so that the technical problems of high maintenance difficulty and low light weight in the prior art are solved. The embodiment of the invention uses the ASM to realize the monitoring of the network performance of the mobile application by using the AOP idea, and has the following beneficial effects: 1) the non-invasive code implantation technology is adopted, so that the problems of labor cost caused by manual code implantation and service and monitoring logic coupling caused by invasive codes are solved; 2) the platform output can be realized, and different applications can be easily accessed to the network performance monitoring function; 3) adopting a lighter-weight AOP scheme and an ASM to realize non-invasive code implantation, and minimizing extra cost introduced to a host after a user accesses; 4) the monitoring by adopting a third party paid SDK is avoided, a developer can flexibly customize the requirements and can be deployed on a private platform, and the risk of business privacy data leakage is avoided; 5) the method can cover the existing mobile terminal network components, can perform fine performance monitoring on the mobile network, and is convenient for a user to fully monitor the network performance of the mobile terminal of the user on the line.
Fig. 5 is a schematic diagram of a main flow of a generation method of an application installation package according to a referential embodiment of the present invention.
Step 501, enumerating network component interfaces corresponding to each network component, and respectively generating customized interfaces corresponding to each network component interface according to each network component interface, thereby generating a network monitoring tool package.
Firstly, all possible calling interfaces are required to be enumerated by common network components of the mobile terminal, and then a corresponding customized interface is generated for each interface. For example, in an Android mobile application, commonly used network components for sending Http network requests include: an Okhttp component, an http component, and an http connection component. The common interfaces of these three network components generally include the following: okhttp components-enqueue, newCall, and execute; an http component-execute; http connection components getContent, openConnection and openStream.
The network monitoring tool package is used for collecting network monitoring parameters of the mobile terminal and reporting the network monitoring parameters in a timed or real-time mode. The customized interface in the network monitoring toolkit is mainly used for a network data collection function, can collect basic parameters of a network request, collects the data, and reports the data to a cloud service to realize a monitoring function.
Step 502, integrating the network monitoring toolkit into a mobile application development framework.
Step 503, generating a target file based on the mobile application development framework.
Step 504, compiling the target file into a binary class file.
The object file generated in step 503 can be compiled into a binary class file by using java, that is, the source file, the software package, the resource, the configuration file, the network monitoring tool package, and the like are compiled into a binary class file (i.e., class file).
And 505, replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, so as to generate an application installation package.
The binary class file in step 504 may be modified by ASM, and the customized interface in the network monitoring toolkit replaces the network component interface in the class file, and the modified class file is the application installation package. Generally, the primary thing to replace is the source file and the network component interfaces in the software package that the engineering relies on. The ASM represents a complex byte code structure through a data structure of a tree, and traverses the tree byte code structure by using a Push model, and modifies byte codes in the traversing process.
There are many implementation ways for the bytecode editing technology, as shown in fig. 6, as can be seen from comparison of AOP underlying technologies, ASM is an optimal implementation scheme in terms of functions, performance, interface-oriented programming and programming difficulty, etc. The embodiment of the invention adopts a high-efficiency ASM byte code editing technology to realize non-invasive code implantation, and if other technologies are adopted, the defect of high realization cost exists.
In addition, in one embodiment of the present invention, the detailed implementation content of the generation method of the application installation package is already described in detail in the above generation method of the application installation package, so that the repeated content is not described again.
Fig. 7 is a schematic diagram of main modules of an apparatus for generating an application installation package according to an embodiment of the present invention, and as shown in fig. 7, an apparatus 700 for generating an application installation package includes a generating module 701, a compiling module 702, and a replacing module 703. The generation module 701 is used for generating a target file based on a mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits; the compiling module 702 is configured to compile the target file into a binary class file; the replacing module 703 is configured to replace the network component interface in the class file with the customized interface in the network monitoring toolkit by using a byte manipulation framework, so as to generate an application installation package.
Optionally, the replacing module 703 is configured to:
analyzing the class file to generate a tree-type byte code structure;
traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit, including:
through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
Optionally, the system further comprises an integration module configured to:
enumerating network component interfaces corresponding to the network components before generating a target file based on a mobile application development framework;
respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit;
integrating the network monitoring toolkit into a mobile application development framework.
Optionally, the network monitoring toolkit is configured to collect network monitoring parameters of the mobile terminal, and report the network monitoring parameters in a timed or real-time manner;
wherein the network monitoring parameters include at least one of:
the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting uniform resource locator, uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time with a server, domain name query time and Http return code.
According to the various embodiments, it can be seen that the technical means of generating the application installation package is achieved by replacing the network component interface in the class file with the customized interface in the network monitoring toolkit through the byte manipulation framework, so that the technical problems of high maintenance difficulty and low light weight in the prior art are solved. The embodiment of the invention uses the ASM to realize the monitoring of the network performance of the mobile application by using the AOP idea, and has the following beneficial effects: 1) the non-invasive code implantation technology is adopted, so that the problems of labor cost caused by manual code implantation and service and monitoring logic coupling caused by invasive codes are solved; 2) the platform output can be realized, and different applications can be easily accessed to the network performance monitoring function; 3) adopting a lighter-weight AOP scheme and an ASM to realize non-invasive code implantation, and minimizing extra cost introduced to a host after a user accesses; 4) the monitoring by adopting a third party paid SDK is avoided, a developer can flexibly customize the requirements and can be deployed on a private platform, and the risk of business privacy data leakage is avoided; 5) the method can cover the existing mobile terminal network components, can perform fine performance monitoring on the mobile network, and is convenient for a user to fully monitor the network performance of the mobile terminal of the user on the line.
It should be noted that, in the embodiment of the apparatus for generating an application installation package according to the present invention, the above-mentioned method for generating an application installation package has been described in detail, and therefore, the repeated description is omitted here.
Fig. 8 shows an exemplary system architecture 800 of a method or an apparatus for generating an application installation package to which an embodiment of the present invention may be applied.
As shown in fig. 8, the system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. The network 804 serves to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. Network 804 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 801, 802, 803 to interact with a server 804 over a network 804 to receive or send messages or the like. The terminal devices 801, 802, 803 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 801, 802, 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 805 may be a server that provides various services, such as a back-office management server (for example only) that supports shopping-like websites browsed by users using the terminal devices 801, 802, 803. The background management server may analyze and process the received data such as the product information query request, and feed back a processing result (for example, target push information and product information — only an example) to the terminal device.
It should be noted that the method for generating the application installation package provided by the embodiment of the present invention is generally executed by the server 805, and accordingly, the apparatus for generating the application installation package is generally disposed in the server 805. The method for generating the application installation package provided by the embodiment of the present invention may also be executed by the terminal devices 801, 802, and 803, and accordingly, the apparatus for generating the application installation package may be disposed in the terminal devices 801, 802, and 803.
It should be understood that the number of terminal devices, networks, and servers in fig. 8 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 9, shown is a block diagram of a computer system 900 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output section 907 including components such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 908 including a hard disk and the like; and a communication section 909 including a network interface card such as a LAN card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present invention are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a generation module, a compilation module, and a replacement module, where the names of the modules do not in some cases constitute a limitation on the modules themselves.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits; compiling the target file into a binary class file; and replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, thereby generating the application installation package.
According to the technical scheme of the embodiment of the invention, because the byte control framework is adopted and the customized interface in the network monitoring toolkit replaces the network component interface in the class file, the technical means of generating the application installation package is realized, and the technical problems of high maintenance difficulty and low light weight in the prior art are solved. The embodiment of the invention uses the ASM to realize the monitoring of the network performance of the mobile application by using the AOP idea, and has the following beneficial effects: 1) the non-invasive code implantation technology is adopted, so that the problems of labor cost caused by manual code implantation and service and monitoring logic coupling caused by invasive codes are solved; 2) the platform output can be realized, and different applications can be easily accessed to the network performance monitoring function; 3) adopting a lighter-weight AOP scheme and an ASM to realize non-invasive code implantation, and minimizing extra cost introduced to a host after a user accesses; 4) the monitoring by adopting a third party paid SDK is avoided, a developer can flexibly customize the requirements and can be deployed on a private platform, and the risk of business privacy data leakage is avoided; 5) the method can cover the existing mobile terminal network components, can perform fine performance monitoring on the mobile network, and is convenient for a user to fully monitor the network performance of the mobile terminal of the user on the line.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method for generating an application installation package is characterized by comprising the following steps:
generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits;
compiling the target file into a binary class file;
and replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework, thereby generating the application installation package.
2. The method of claim 1, wherein replacing the network component interface in the class file with a custom interface in the network monitoring toolkit using a byte manipulation framework comprises:
analyzing the class file to generate a tree-type byte code structure;
traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
3. The method of claim 2, wherein replacing the bytecode of the network component interface in the class file with the bytecode of the custom interface in the network monitoring toolkit comprises:
through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
4. The method of claim 1, further comprising, prior to generating the target file based on the mobile application development framework:
enumerating network component interfaces corresponding to the network components;
respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit;
integrating the network monitoring toolkit into a mobile application development framework.
5. The method according to claim 1, wherein the network monitoring tool kit is used for collecting network monitoring parameters of the mobile terminal and reporting the network monitoring parameters in a timed or real-time manner;
wherein the network monitoring parameters include at least one of:
the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting uniform resource locator, uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time with a server, domain name query time and Http return code.
6. An apparatus for generating an application installation package, comprising:
the generation module is used for generating a target file based on the mobile application development framework; wherein the target files comprise source files, engineering dependent software packages, resources, configuration files and network monitoring toolkits;
the compiling module is used for compiling the target file into a binary class file;
and the replacing module is used for replacing the network component interface in the class file with the customized interface in the network monitoring toolkit by adopting a byte control framework so as to generate the application installation package.
7. The apparatus of claim 6, wherein the replacement module is configured to:
analyzing the class file to generate a tree-type byte code structure;
traversing the tree-type byte code structure, and replacing byte codes of the network component interfaces in the class files with byte codes of the customized interfaces in the network monitoring toolkit in the traversing process.
8. The apparatus of claim 7, wherein replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit comprises:
through the matching of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the byte code of the network component interface in the class file is replaced by the byte code of the customized interface in the network monitoring toolkit.
9. The apparatus of claim 1, further comprising an integration module to:
enumerating network component interfaces corresponding to the network components before generating a target file based on a mobile application development framework;
respectively generating a customized interface corresponding to each network component interface according to each network component interface, thereby generating a network monitoring toolkit;
integrating the network monitoring toolkit into a mobile application development framework.
10. The device according to claim 6, wherein the network monitoring tool kit is configured to collect network monitoring parameters of the mobile terminal, and report the network monitoring parameters in a timed or real-time manner;
wherein the network monitoring parameters include at least one of:
the method comprises the steps of requesting mode, requesting abnormal type, requesting initiation time, requesting uniform resource locator, uplink flow, downlink flow, residual packet time, first packet time, requesting time consumption, handshake time with a server, domain name query time and Http return code.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-5.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910720776.3A 2019-08-06 2019-08-06 Method and device for generating application installation package Pending CN112346774A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910720776.3A CN112346774A (en) 2019-08-06 2019-08-06 Method and device for generating application installation package

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910720776.3A CN112346774A (en) 2019-08-06 2019-08-06 Method and device for generating application installation package

Publications (1)

Publication Number Publication Date
CN112346774A true CN112346774A (en) 2021-02-09

Family

ID=74366355

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910720776.3A Pending CN112346774A (en) 2019-08-06 2019-08-06 Method and device for generating application installation package

Country Status (1)

Country Link
CN (1) CN112346774A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114296742A (en) * 2022-03-08 2022-04-08 苏州万店掌网络科技有限公司 Installation package creating method, device, equipment and medium
CN114844875A (en) * 2022-04-21 2022-08-02 深圳依时货拉拉科技有限公司 Application Programming Interface (API) management method, device, equipment and medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114296742A (en) * 2022-03-08 2022-04-08 苏州万店掌网络科技有限公司 Installation package creating method, device, equipment and medium
CN114296742B (en) * 2022-03-08 2022-05-10 苏州万店掌网络科技有限公司 Installation package creating method, installation package creating device, installation package creating equipment and installation package creating medium
CN114844875A (en) * 2022-04-21 2022-08-02 深圳依时货拉拉科技有限公司 Application Programming Interface (API) management method, device, equipment and medium

Similar Documents

Publication Publication Date Title
US20160162344A1 (en) Generation of representational state transfer interface from application programming interfaces
CN109981322B (en) Method and device for cloud resource management based on label
CN110489310B (en) Method and device for recording user operation, storage medium and computer equipment
CN110858202A (en) Method and device for generating where clause in database query statement
CN110716720A (en) Method and device for realizing application hot deployment
TW201409273A (en) Method and Apparatus of Responding to Webpage Access Request
CN111666293A (en) Database access method and device
CN110188308B (en) Client automatic dotting reporting method, storage medium, equipment and system
CN112346774A (en) Method and device for generating application installation package
CN110888794A (en) Interface test method and device
CN116431155A (en) Front-end application construction method, medium, device and computing equipment
CN113778725A (en) Data verification method and device
CN108845864B (en) Spring frame-based JVM garbage recycling method and device
US20210274017A1 (en) Request processing method and apparatus, electronic device, and computer storage medium
CN111767498B (en) Method and device for realizing file information sharing
CN109408057B (en) Method, device, medium and computing equipment for automatically generating codes
CN115934537A (en) Interface test tool generation method, device, equipment, medium and product
CN115640279A (en) Method and device for constructing data blood relationship
CN113779122B (en) Method and device for exporting data
CN114327404A (en) File processing method and device, electronic equipment and computer readable medium
CN109901934A (en) The method and apparatus for generating interface help document
Zhou et al. MCAF: Developing an Annotation‐Based Offloading Framework for Mobile Cloud Computing
CN113761433A (en) Service processing method and device
CN113535322A (en) Form verification method and device
CN114003317B (en) Inline implementation method and device, electronic equipment, storage medium and program product

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