CN111767237B - Inter-module communication method and device - Google Patents

Inter-module communication method and device Download PDF

Info

Publication number
CN111767237B
CN111767237B CN201910338178.XA CN201910338178A CN111767237B CN 111767237 B CN111767237 B CN 111767237B CN 201910338178 A CN201910338178 A CN 201910338178A CN 111767237 B CN111767237 B CN 111767237B
Authority
CN
China
Prior art keywords
file
module
compressed file
annotation list
compressed
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
CN201910338178.XA
Other languages
Chinese (zh)
Other versions
CN111767237A (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.)
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 CN201910338178.XA priority Critical patent/CN111767237B/en
Publication of CN111767237A publication Critical patent/CN111767237A/en
Application granted granted Critical
Publication of CN111767237B publication Critical patent/CN111767237B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/12Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor
    • G06F13/124Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor where hardware is a sequential transfer control unit, e.g. microprocessor, peripheral processor or state-machine
    • G06F13/126Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor where hardware is a sequential transfer control unit, e.g. microprocessor, peripheral processor or state-machine and has means for transferring I/O instructions and statuses between control unit and main processor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/12Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor
    • G06F13/122Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor where hardware performs an I/O function other than control of data transfer

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Microelectronics & Electronic Packaging (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a method and a device for communication between modules. One specific implementation mode of the method comprises the steps of sending a pre-generated storage address of a compressed file of a first module to a second module; downloading the compressed file from the storage address by using a compiling interface pre-configured by a second module; determining whether the compressed file has an identifier of a class corresponding to an interface provided by a first module; responding to the existence identification, and acquiring a class corresponding to the interface provided by the first module based on the identification; adding a class corresponding to an interface provided by a first module into a compiling dependency of a second module; the second module is compiled so that the second module communicates with the first module referencing the interface provided by the first module. This embodiment provides a new way of inter-module communication, making inter-module communication simpler.

Description

Inter-module communication method and device
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for communication between modules.
Background
With the development of services, most applications are larger and bulkier, and developers tend to increase. As the service types are more and more, the dependence relationship and the coupling degree between the service types are higher and higher. Intercommunication between businesses can result in more and more code being placed on the base project, and over time, the code in the base project cannot be modified at will. Therefore, the application needs to be split into a plurality of modules, and the communication between the modules is very important.
Currently, the communication modes between modules mainly include the following two modes: first, the Event bus serves as a medium for communication between modules. It features that it is suitable for one-to-many broadcasting scene. Because Event needs to define entity class in advance, event use is skipped, and the code is directly sunk to the basic project to share the code, thereby causing the continuous expansion of the basic project. And secondly, protocol communication. It is a cross-platform/serialized communication mode. Both module parties must jointly establish and adhere to this protocol. Typically, protocols are deposited into a common area for convenience. The synchronization problem on both ends is also complicated if the protocol changes. Where a large number of reflections are also used and the efficiency is low.
Disclosure of Invention
The embodiment of the application provides a method and a device for communication between modules.
In a first aspect, an embodiment of the present application provides an inter-module communication method, including: sending a pre-generated storage address of a compressed file of a first module to a second module; downloading the compressed file from the storage address by using a compiling interface pre-configured by a second module; determining whether the compressed file has an identifier of a class corresponding to an interface provided by a first module; responding to the existence of the identification, and acquiring a class corresponding to the interface provided by the first module based on the identification; adding a class corresponding to an interface provided by a first module into a compiling dependency of a second module; the second module is compiled so that the second module communicates with the first module referencing the interface provided by the first module.
In some embodiments, determining whether the compressed file has an identifier of a class corresponding to the interface provided by the first module includes: decompressing the compressed file to obtain a file contained in the compressed file; determining whether an annotation list file exists in files contained in the compressed file, wherein the annotation list file is used for recording an identifier; if the annotation list file exists, determining that an identifier exists in the compressed file; and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file.
In some embodiments, determining whether an annotation list file exists in the files contained in the compressed file comprises: searching a directory file from files contained in the compressed file, wherein the directory file is used for recording names of the files contained in the compressed file; determining whether the name of the annotation list file is recorded in the directory file; if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file; if the name of the annotation list file is not recorded, the annotation list file does not exist in the files contained in the compressed file.
In some embodiments, the compressed file is generated by: annotating a class corresponding to an interface provided by a first module; traversing the source code of the first module based on the annotation to obtain the identification of the class corresponding to the interface provided by the first module; generating an annotation list file based on the identification of the class corresponding to the interface provided by the first module; compiling the first module to obtain a compiled intermediate file; generating a compressed file based on the annotation list file and the compiled intermediate file; and releasing the compressed file.
In some embodiments, generating the annotation list file based on the identification of the class corresponding to the interface provided by the first module includes: sequentially splicing the identifications of the classes corresponding to the interfaces provided by the first module to generate a character string; and storing the character strings into a text file to generate an annotation list file.
In some embodiments, generating a compressed file based on the annotation list file and the compiled intermediate file comprises: generating a directory file for recording names of files included in the compressed file; and compressing the annotation list file, the compiling intermediate file and the directory file to generate a compressed file.
In a second aspect, an embodiment of the present application provides an inter-module communication apparatus, including: a storage address transmitting unit configured to transmit a storage address of a compressed file of a first module generated in advance to a second module; a compressed file acquisition unit configured to download the compressed file from the storage address using a compilation interface preconfigured by the second module; the compressed file determining unit is configured to determine whether the identifier of the class corresponding to the interface provided by the first module exists in the compressed file; the class acquisition unit is configured to respond to the existence identification and acquire a class corresponding to the interface provided by the first module based on the identification; the compiling dependency adding unit is configured to add a class corresponding to the interface provided by the first module as a compiling dependency of the second module; and the module compiling unit is configured to compile the second module so that the second module refers to the interface provided by the first module to communicate with the first module.
In some embodiments, the compressed file determining unit is further configured to: decompressing the compressed file to obtain a file contained in the compressed file; determining whether an annotation list file exists in files contained in the compressed file, wherein the annotation list file is used for recording the identifier; if the annotation list file exists, determining that an identifier exists in the compressed file; and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file.
In some embodiments, the compressed file determination unit is further configured to: searching a directory file from files contained in the compressed file, wherein the directory file is used for recording names of the files contained in the compressed file; determining whether the name of the annotation list file is recorded in the directory file; if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file; if the name of the annotation list file is not recorded, the annotation list file does not exist in the files contained in the compressed file.
In some embodiments, the compressed file is generated by: annotating a class corresponding to an interface provided by a first module; traversing the source code of the first module based on the annotation to obtain the identification of the class corresponding to the interface provided by the first module; generating an annotation list file based on the identification of the class corresponding to the interface provided by the first module; compiling the first module to obtain a compiled intermediate file; generating a compressed file based on the annotation list file and the compiled intermediate file; and releasing the compressed file.
In some embodiments, generating the annotation list file based on the identification of the class corresponding to the interface provided by the first module includes: sequentially splicing the identifications of the classes corresponding to the interfaces provided by the first module to generate character strings; and storing the character strings into a text file to generate an annotation list file.
In some embodiments, generating a compressed file based on the annotation list file and the compiled intermediate file comprises: generating a directory file recording names of files contained in the compressed file; and compressing the annotation list file, the compiled intermediate file and the directory file to generate a compressed file.
In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, the present application provides a computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the inter-module communication method and device provided by the embodiment of the application, the storage address of the compressed file of the first module is sent to the second module, so that the compressed file can be downloaded from the storage address by using the compiling interface of the second module; then determining whether the compressed file has an identifier of a class corresponding to the interface provided by the first module, and acquiring the class corresponding to the interface provided by the first module based on the identifier under the condition that the identifier exists; then adding the class corresponding to the interface provided by the first module as the compiling dependency of the second module; and finally, compiling the second module so that the second module refers to the interface provided by the first module to communicate with the first module. A new inter-module communication method is provided, thereby making inter-module communication simpler. Moreover, classes required by communication among the modules are exposed in an interface form, and if the interface provided by the first module is changed, the second module refers to the interface, so that errors can be easily sensed during compiling, and problem troubleshooting is facilitated. Meanwhile, when the second module refers to the first module, only the interface provided by the second module is referred to, and the class corresponding to the interface is not considered, so that the purpose of compiling and isolating is achieved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture in which the present application may be applied;
FIG. 2 is a flow diagram for one embodiment of a method of inter-module communication according to the present application;
FIG. 3 is a flow diagram for one embodiment of a compressed file generation method according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of an inter-module communication apparatus according to the present application;
FIG. 5 is a schematic block diagram of a computer system suitable for use in implementing an electronic device according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present application, the embodiments and features of the embodiments may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
FIG. 1 illustrates an exemplary system architecture 100 to which embodiments of the inter-module communication method or inter-module communication apparatus of the present application may be applied.
As shown in fig. 1, a terminal device 101 may be included in the system architecture 100. Various client applications, such as shopping applications, instant messaging applications, search applications, and the like, may be installed on the terminal device 101. The client application installed on the terminal apparatus 101 may be split into a plurality of modules. When the user 102 uses a client application installed on the terminal apparatus 101, communication can be performed between the plurality of split modules.
The terminal apparatus 101 may be hardware or software. When the terminal device 101 is hardware, it may be various electronic devices, including but not limited to a smart phone, a tablet computer, a PDA (Personal Digital Assistant), a laptop portable computer, a desktop computer, and the like. When the terminal apparatus 101 is software, it can be installed in the above-described electronic apparatus. It may be implemented as multiple pieces of software or software modules, or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the inter-module communication method provided in the embodiment of the present application is generally executed by the terminal device 101, and accordingly, the inter-module communication apparatus is generally disposed in the terminal device 101.
It should be understood that the number of terminal devices in fig. 1 is merely illustrative. There may be any number of terminal devices, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method of inter-module communication according to the present application is illustrated. The communication method between the modules comprises the following steps:
step 201, sending the pre-generated storage address of the compressed file of the first module to the second module.
In this embodiment, the execution subject of the inter-module communication method (for example, the terminal device 101 shown in fig. 1) may transmit the storage address of the compressed file of the first module generated in advance to the second module. The execution body may be installed with various applications, such as a shopping application, an instant messaging application, a search application, and the like. Since the same application can implement multiple services, the same application is usually split into multiple modules according to the service categories. The first module and the second module may be modules separated by the same application.
In practice, the execution agent may generate and distribute a compressed file of the first module. For example, the execution agent may publish the compressed file to the maven repository using a maven-publish plug-in. Thus, the compressed file can be stored in the maven repository. Wherein, maven-publish is a gradle plug-in, and can publish files to the maven warehouse. The compressed file may be an aar file or a jar file. The aar file, namely an Android Archive package, is a binary Archive file of an Android library item. jar files and Java Archive files are a Java document format.
And 202, downloading the compressed file from the storage address by using a pre-configured compiling interface of the second module.
In this embodiment, the execution agent may download the compressed file from the storage address using a compiler API (compiler API) of the second module. Here, the execution body may perform custom configuration on the compiler API in the gradle, and use such a custom manner to refer to the first module. Specifically, the execution agent may download the compressed file locally from the maven repository using a gradle dependent form.
Step 203, determining whether the compressed file has an identifier of a class corresponding to the interface provided by the first module.
In this embodiment, the execution subject may parse the compressed file to determine whether the identifier of the class corresponding to the interface provided by the first module exists in the compressed file. If there is an identifier of a class corresponding to the interface provided by the first module, it indicates that the second module can communicate with the first module, and at this time, step 204 is executed. If the identifier of the class corresponding to the interface provided by the first module does not exist, it indicates that the second module may not communicate with the first module, and at this time, step 206 is directly executed without any processing. The class corresponding to the interface provided by the first module may be a class in the first module that communicates with other modules. And encapsulating classes in the first module, which communicate with other modules, and providing interfaces for the other modules to reference. The identification may be made up of a package name and a class name.
In some optional implementations of this embodiment, the execution subject may first decompress the compressed file to obtain a file included in the compressed file; then determining whether an annotation list file exists in files contained in the compressed file; if the annotation list file exists, determining that an identifier exists in the compressed file; and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file. The annotation list file may be used to record an identifier of a class corresponding to the interface provided by the first module.
In practice, the execution subject may determine whether the annotation list file exists in the files contained in the compressed file in various ways. As an example, the execution agent may traverse a file contained in the compressed file to determine if an annotation list file exists. As another example, the execution body may first find a directory file from files included in the compressed file; then determining whether the name of the annotation list file is recorded in the directory file; if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file; if the name of the annotation list file is not recorded, the annotation list file does not exist in the files contained in the compressed file. The directory file may be used to record names of files included in the compressed file, and is a file in a text format.
And 204, acquiring a class corresponding to the interface provided by the first module based on the identification.
In this embodiment, when the identifier of the class corresponding to the interface provided by the first module exists in the compressed file, the execution main body may obtain the class corresponding to the interface provided by the first module based on the identifier of the class corresponding to the interface provided by the first module. Generally, a class and jar compressed package exists in a file included in the compressed file, and the execution main body may find a class corresponding to an interface provided by the first module from the class and jar compressed package according to an identifier of the class corresponding to the interface provided by the first module.
Step 205, adding the class corresponding to the interface provided by the first module as the compilation dependency of the second module.
In this embodiment, the execution subject may add a class corresponding to an interface provided by the first module as a compilation dependency of the second module.
Step 206, the second module is compiled.
In this embodiment, the execution subject may compile the second module. Since the class corresponding to the interface provided by the first module is added as the compilation dependency of the second module, the second module refers to the interface provided by the first module to communicate with the first module when the second module is compiled.
According to the inter-module communication method provided by the embodiment of the application, firstly, the storage address of the compressed file of the first module is sent to the second module, so that the compressed file can be conveniently downloaded from the storage address by utilizing the compiling interface of the second module; then, whether the identification of the class corresponding to the interface provided by the first module exists in the compressed file is determined, and under the condition that the identification exists, the class corresponding to the interface provided by the first module is obtained based on the identification; then adding the class corresponding to the interface provided by the first module as the compiling dependency of the second module; and finally, compiling the second module so that the second module refers to the interface provided by the first module to communicate with the first module. A new communication mode between modules is provided, thereby simplifying the communication between modules. Moreover, classes required by communication among the modules are exposed in an interface form, if the interface provided by the first module changes, the second module refers to the interfaces, errors can be easily sensed during compiling, and problem troubleshooting is facilitated. Meanwhile, when the second module refers to the first module, only the interface provided by the second module is referred to, and the class corresponding to the interface is not considered, so that the purpose of compiling and isolating is achieved.
With further reference to FIG. 3, a flow 300 of one embodiment of a compressed file generation method according to the present application is shown. The compressed file generation method comprises the following steps:
step 301, annotating a class corresponding to an interface provided by the first module.
In this embodiment, an execution subject (for example, the terminal device 101 shown in fig. 1) of the compressed file generation method may annotate a class corresponding to an interface provided by the first module. In particular, for classes in the first module that communicate with other modules, the execution body may annotate these classes to distinguish them from other classes.
Step 302, based on the source code of the annotation traversal first module, the identifier of the class corresponding to the interface provided by the first module is obtained.
In this embodiment, the execution subject may find out, from the source code of the first module, the identifier of the class corresponding to the interface provided by the first module according to the source code of the annotation traversal of the first module. The identifier may be composed of a package name and a class name.
Step 303, generating an annotation list file based on the identifier of the class corresponding to the interface provided by the first module.
In this embodiment, the execution subject may generate the annotation list file based on the identifier of the class corresponding to the interface provided by the first module. Specifically, the execution subject may store the identifier of the class corresponding to the interface provided by the first module in a text file to generate an annotation list file. For example, the execution main body may first sequentially concatenate identifiers of classes corresponding to the interface provided by the first module, and generate a character string; the character strings are then stored in a text file to generate an annotation list file.
And step 304, compiling the first module to obtain a compiled intermediate file.
In this embodiment, the execution main body may compile the first module to obtain a compiled intermediate file. The compilation intermediate file may be a file required for generating an aar file, and includes, but is not limited to, an android manifest. The class files are class files, namely class files. Txt files can be used to record information such as resource type, name, and identification.
Step 305 generates a compressed file based on the annotation list file and the compiled intermediate file.
In this embodiment, the execution subject may generate a compressed file based on the annotation list file and the compiled intermediate file. For example, the execution subject may directly compress the annotation list file and the compilation intermediate file to generate a compressed file. For another example, the execution agent may first generate a directory file that records names of files included in the compressed file; and then compressing the annotation list file, the compiling intermediate file and the directory file to generate a compressed file.
Step 306, the compressed file is published.
In this embodiment, the execution agent may issue a compressed file. For example, the execution agent may publish the compressed file to the maven repository using a maven-publish plug-in. Thus, the compressed file can be stored in the maven repository.
With further reference to fig. 4, as an implementation of the methods shown in the above figures, the present application provides an embodiment of an inter-module communication apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which is particularly applicable in various electronic devices.
As shown in fig. 4, the inter-module communication apparatus 400 of the present embodiment may include: a storage address sending unit 401, a compressed file acquiring unit 402, a compressed file determining unit 403, a class acquiring unit 404, a compilation dependency adding unit 405, and a module compiling unit 406. Wherein, the storage address sending unit 401 is configured to send the storage address of the compressed file of the first module generated in advance to the second module; a compressed file obtaining unit 402 configured to download the compressed file from the storage address using a compiling interface preconfigured by the second module; a compressed file determining unit 403 configured to determine whether an identifier of a class corresponding to an interface provided by the first module exists in the compressed file; a class obtaining unit 404 configured to, in response to the existence identifier, obtain a class corresponding to the interface provided by the first module based on the identifier; a compiling dependency adding unit 405 configured to add a class corresponding to an interface provided by a first module as a compiling dependency of a second module; and a module compiling unit 406 configured to compile the second module so that the second module communicates with the first module by referring to the interface provided by the first module.
In the present embodiment, in the inter-module communication apparatus 400: the specific processing of the storage address sending unit 401, the compressed file obtaining unit 402, the compressed file determining unit 403, the class obtaining unit 404, the compiling dependency adding unit 405, and the module compiling unit 406 and the technical effects thereof may refer to the related descriptions of step 201, step 202, step 203, step 204, step 205, and step 206 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of the present embodiment, the compressed file determining unit 403 is further configured to: decompressing the compressed file to obtain a file contained in the compressed file; determining whether an annotation list file exists in files contained in the compressed file, wherein the annotation list file is used for recording an identifier; if the annotation list file exists, determining that an identifier exists in the compressed file; and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file.
In some optional implementations of the present embodiment, the compressed file determining unit 403 is further configured to: searching a directory file from files contained in the compressed file, wherein the directory file is used for recording names of the files contained in the compressed file; determining whether the name of the annotation list file is recorded in the directory file; if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file; if the name of the annotation list file is not recorded, the annotation list file does not exist in the files contained in the compressed file.
In some optional implementations of this embodiment, the compressed file is generated by: annotating a class corresponding to an interface provided by a first module; traversing the source code of the first module based on the annotation to obtain the identification of the class corresponding to the interface provided by the first module; generating an annotation list file based on the identification of the class corresponding to the interface provided by the first module; compiling the first module to obtain a compiled intermediate file; generating a compressed file based on the annotation list file and the compiled intermediate file; and releasing the compressed file.
In some optional implementations of this embodiment, generating the annotation list file based on the identifier of the class corresponding to the interface provided by the first module includes: sequentially splicing the identifications of the classes corresponding to the interfaces provided by the first module to generate character strings; and storing the character strings into a text file to generate an annotation list file.
In some optional implementations of this embodiment, generating the compressed file based on the annotation list file and the compiled intermediate file includes: generating a directory file recording names of files contained in the compressed file; and compressing the annotation list file, the compiling intermediate file and the directory file to generate a compressed file.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use in implementing an electronic device (e.g., terminal device 101 shown in FIG. 1) according to embodiments of the present application is shown. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present application.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU) 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment 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 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium described herein 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 application, 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 this application, 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 any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may 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.
Computer program code for carrying out operations for aspects of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
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 application. 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 and/or flowchart illustration, and combinations of blocks in the block diagrams and/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 units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a storage address sending unit, a compressed file acquiring unit, a compressed file determining unit, a class acquiring unit, a compilation dependency adding unit, and a module compiling unit. The names of the units do not constitute a limitation to the units themselves in some cases, and for example, the storage address transmission unit may also be described as a "unit that transmits a storage address of a compressed file of a first module generated in advance to a second module".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: sending a pre-generated storage address of a compressed file of a first module to a second module; downloading the compressed file from the storage address by using a compiling interface pre-configured by a second module; determining whether the compressed file has a class identifier corresponding to an interface provided by a first module; responding to the existence of the identification, and acquiring a class corresponding to the interface provided by the first module based on the identification; adding a class corresponding to an interface provided by a first module into a compiling dependency of a second module; the second module is compiled so that the second module communicates with the first module referencing the interface provided by the first module.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements in which any combination of the features described above or their equivalents does not depart from the spirit of the invention disclosed above. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (12)

1. An inter-module communication method, comprising:
sending a pre-generated storage address of a compressed file of a first module to a second module, wherein the compressed file is generated through the following steps: annotating a class corresponding to the interface provided by the first module; traversing the source code of the first module based on the annotation to obtain the identifier of the class corresponding to the interface provided by the first module; generating an annotation list file based on the identification of the class corresponding to the interface provided by the first module; compiling the first module to obtain a compiled intermediate file; generating the compressed file based on the annotation list file and the compiled intermediate file; releasing the compressed file;
downloading the compressed file from the storage address by utilizing a compiling interface pre-configured by the second module;
determining whether the compressed file has an identifier of a class corresponding to the interface provided by the first module;
in response to the identification, acquiring a class corresponding to the interface provided by the first module based on the identification;
adding a class corresponding to an interface provided by the first module as a compiling dependency of the second module;
compiling the second module to cause the second module to communicate with the first module referencing the interface provided by the first module.
2. The method of claim 1, wherein the determining whether the compressed file has an identifier of a class corresponding to the interface provided by the first module comprises:
decompressing the compressed file to obtain a file contained in the compressed file;
determining whether an annotation list file exists in files contained in the compressed file, wherein the annotation list file is used for recording the identifier;
if the annotation list file exists, determining that the identifier exists in the compressed file;
and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file.
3. The method of claim 2, wherein said determining whether an annotation list file exists in the files contained in the compressed file comprises:
searching a directory file from files contained in the compressed file, wherein the directory file is used for recording names of the files contained in the compressed file;
determining whether the name of the annotation list file is recorded in the directory file;
if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file;
if the name of the annotation list file is not recorded, determining that the annotation list file does not exist in the files contained in the compressed file.
4. The method of claim 1, wherein the generating the annotation list file based on the identification of the class corresponding to the interface provided by the first module comprises:
sequentially splicing the identifications of the classes corresponding to the interfaces provided by the first module to generate a character string;
and storing the character string into a text file to generate the annotation list file.
5. The method of claim 1, wherein generating the compressed file based on the annotation list file and the compiled intermediate file comprises:
generating a directory file for recording names of files contained in the compressed file;
and compressing the annotation list file, the compiling intermediate file and the directory file to generate the compressed file.
6. An inter-module communication apparatus comprising:
a storage address transmitting unit configured to transmit a storage address of a compressed file of a first module generated in advance to a second module, wherein the compressed file is generated by: annotating a class corresponding to the interface provided by the first module; traversing the source code of the first module based on the annotation to obtain the identifier of the class corresponding to the interface provided by the first module; generating an annotation list file based on the identification of the class corresponding to the interface provided by the first module; compiling the first module to obtain a compiled intermediate file; generating the compressed file based on the annotation list file and the compiled intermediate file; releasing the compressed file;
a compressed file obtaining unit configured to download the compressed file from the storage address by using a compiling interface pre-configured by the second module;
a compressed file determining unit configured to determine whether an identifier of a class corresponding to an interface provided by the first module exists in the compressed file;
the class acquisition unit is configured to respond to the existence of the identification, and acquire a class corresponding to the interface provided by the first module based on the identification;
a compiling dependency adding unit configured to add a class corresponding to an interface provided by the first module as a compiling dependency of the second module;
a module compiling unit configured to compile the second module to cause the second module to communicate with the first module referencing the interface provided by the first module.
7. The apparatus of claim 6, wherein the compressed file determination unit is further configured to:
decompressing the compressed file to obtain a file contained in the compressed file;
determining whether an annotation list file exists in files contained in the compressed file, wherein the annotation list file is used for recording the identifier;
if the annotation list file exists, determining that the identifier exists in the compressed file;
and if the annotation list file does not exist, determining that the identifier does not exist in the compressed file.
8. The apparatus of claim 7, wherein the compressed file determination unit is further configured to:
searching a directory file from files contained in the compressed file, wherein the directory file is used for recording names of the files contained in the compressed file;
determining whether the name of the annotation list file is recorded in the directory file;
if the name of the annotation list file is recorded, determining that the annotation list file exists in the files contained in the compressed file;
if the name of the annotation list file is not recorded, determining that the annotation list file does not exist in the files contained in the compressed file.
9. The apparatus of claim 6, wherein the generating the annotation list file based on the identification of the class corresponding to the interface provided by the first module comprises:
sequentially splicing the identifications of the classes corresponding to the interfaces provided by the first module to generate a character string;
and storing the character strings into a text file to generate the annotation list file.
10. The apparatus of claim 6, wherein the generating the compressed file based on the annotation list file and the compiled intermediate file comprises:
generating a directory file recording names of files contained in the compressed file;
and compressing the annotation list file, the compiling intermediate file and the directory file to generate the compressed file.
11. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
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, wherein the computer program, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201910338178.XA 2019-04-25 2019-04-25 Inter-module communication method and device Active CN111767237B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910338178.XA CN111767237B (en) 2019-04-25 2019-04-25 Inter-module communication method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910338178.XA CN111767237B (en) 2019-04-25 2019-04-25 Inter-module communication method and device

Publications (2)

Publication Number Publication Date
CN111767237A CN111767237A (en) 2020-10-13
CN111767237B true CN111767237B (en) 2022-11-08

Family

ID=72718246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910338178.XA Active CN111767237B (en) 2019-04-25 2019-04-25 Inter-module communication method and device

Country Status (1)

Country Link
CN (1) CN111767237B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6410377A (en) * 1987-07-03 1989-01-13 Nippon Telegraph & Telephone Inter-module communication system
CN106406971A (en) * 2016-09-26 2017-02-15 杭州迪普科技有限公司 A compiling method and device for code files
CN109032663A (en) * 2018-07-09 2018-12-18 深圳市小牛在线互联网信息咨询有限公司 Generation method, device, computer equipment and the storage medium of interface document

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS6410377A (en) * 1987-07-03 1989-01-13 Nippon Telegraph & Telephone Inter-module communication system
CN106406971A (en) * 2016-09-26 2017-02-15 杭州迪普科技有限公司 A compiling method and device for code files
CN109032663A (en) * 2018-07-09 2018-12-18 深圳市小牛在线互联网信息咨询有限公司 Generation method, device, computer equipment and the storage medium of interface document

Also Published As

Publication number Publication date
CN111767237A (en) 2020-10-13

Similar Documents

Publication Publication Date Title
US20100162225A1 (en) Cross-product refactoring apparatus and method
CN110554876A (en) Method and device for compiling android project
CN111290760B (en) Application program compiling method and device, electronic equipment and storage medium
CN110780874B (en) Method and device for generating information
CN109766127B (en) Method for updating application version information
WO2019029451A1 (en) Method for publishing mobile applications and electronic apparatus
CN113407165B (en) SDK generation and self-upgrade method, device, readable medium and equipment
CN109218338B (en) Information processing system, method and device
CN111813685B (en) Automatic test method and device
CN111767498B (en) Method and device for realizing file information sharing
CN111787041B (en) Method and device for processing data
CN111767237B (en) Inter-module communication method and device
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN111124541A (en) Configuration file generation method, device, equipment and medium
CN114860213A (en) Application package generation method, device, equipment and medium
CN116226189A (en) Cache data query method, device, electronic equipment and computer readable medium
CN111625232B (en) Method and device for generating application program installation package, readable medium and electronic equipment
CN111399902B (en) Client source file processing method and device, readable medium and electronic equipment
CN111460020B (en) Method, device, electronic equipment and medium for resolving message
CN112579553B (en) Method and apparatus for recording information
CN109376023B (en) Method and equipment for generating calling information and issuing return code group
CN109766246B (en) Method and apparatus for monitoring applications
CN117555542A (en) Transcoding method, transcoding device, electronic device and computer readable medium
CN116931934A (en) Method, device, equipment and storage medium for converting shader codes
CN113760348A (en) Code packaging method and device, electronic equipment and computer readable medium

Legal Events

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