A method and device for communication between modules

By using the routing class to obtain the communication interface instance and calling the interface function in inter-module communication, the problem of inter-module communication consuming device performance in the existing technology is solved, and an efficient and low-consumption communication method is realized.

CN110347371BActive Publication Date: 2024-09-20BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810287382.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-04-03
Publication Date
2024-09-20
Estimated Expiration
2038-04-03

AI Technical Summary

Technical Problem

Inter-module communication methods in the existing technology, such as URL communication and broadcast communication, will consume device performance, especially when communication between modules is frequent, leading to a sharp decline in device performance.

Method used

Obtain the communication interface instance of the target module by calling the instance acquisition function in the routing class, and call the function in the corresponding communication interface to realize communication between modules. This method is simple and does not consume additional device performance except obtaining the communication interface instance.

Benefits of technology

It achieves efficient communication between modules, avoids the consumption of equipment performance, simplifies the communication process, and improves the stability and performance of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110347371B
    Figure CN110347371B
Patent Text Reader

Abstract

The present invention discloses a method and device for inter-module communication, and relates to the field of computer technology. A specific implementation of the method includes: calling a predefined registration machine class to obtain a registration machine object, and obtaining a routing class through the registration machine object; calling an instance acquisition function of the routing class, and passing a preset target module identifier into the instance acquisition function to obtain a communication interface instance corresponding to the target module identifier; converting the communication interface instance into a communication interface, and calling a function defined in the communication interface to achieve inter-module communication. This implementation method obtains the communication interface instance of the target module by calling the instance acquisition function in the routing class, and then calls the function in the corresponding communication interface to achieve inter-module communication. The method call of the embodiment of the present invention is simple, and does not require additional consumption of device performance except for obtaining the communication interface instance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to a method and device for inter-module communication. Background Art

[0002] In the process of mobile APP (Application) development, as the development project progresses and the functions are iterated, the code will become more and more. If all the codes are mixed into one file, it will inevitably lead to difficulties in later maintenance and reduce the compilation speed. In order to avoid the above problems, a modular architecture is adopted in the APP development process, that is, the development project is split into independent modules, and the modification of one module does not affect other modules. In the modular architecture, how to achieve communication between modules is a core issue. In the prior art, inter-module communication is achieved through Uniform Resource Locator (URL) or broadcast.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: the URL communication method requires converting parameters and strings back and forth, and the broadcast communication method requires localizing parameters. During the conversion or localization process, part of the device performance will be consumed, especially when the communication between modules is more frequent, which will cause a sharp decline in device performance. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for inter-module communication, which obtains the communication interface instance of the target module by calling the instance acquisition function in the routing class, and then calls the function in the corresponding communication interface to achieve inter-module communication. The method call of the embodiment of the present invention is simple and does not require additional consumption of device performance except for obtaining the communication interface instance.

[0005] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for inter-module communication is provided.

[0006] A method for inter-module communication in an embodiment of the present invention includes: calling a predefined registration machine class to obtain a registration machine object, and obtaining a routing class through the registration machine object; wherein the registration machine class includes the routing class, and the routing class includes an instance acquisition function for obtaining a communication interface instance of each module; calling the instance acquisition function of the routing class, passing a preset target module identifier into the instance acquisition function to obtain a communication interface instance corresponding to the target module identifier; converting the communication interface instance into a communication interface, and calling a function defined in the communication interface to achieve communication between modules.

[0007] Optionally, the registration machine class also includes a module identifier of its own module, an acquisition function for acquiring a communication interface instance of a target module through the routing class, and an instance return function for returning the communication interface instance of its own module; the routing class also includes a plurality of the module identifiers and corresponding registration machine objects; the acquisition of the communication interface instance corresponding to the target module identifier includes: acquiring the corresponding registration machine object of the target module according to the target module identifier; calling the instance return function in the registration machine class corresponding to the registration machine object to return the communication interface instance of the target module; calling the acquisition function to acquire the communication interface instance of the target module.

[0008] Optionally, before the step of calling a predefined registration machine class to obtain a registration machine object, it also includes: generating a corresponding registration machine object for each module according to the full class name of the registration machine class of each module in the configuration file; obtaining the module identifier of each module through the registration machine object, and saving the module identifier and the registration machine object in the form of a key-value pair in the routing class.

[0009] Optionally, before the step of obtaining the communication interface instance corresponding to the target module identifier, it also includes: defining a communication interface; wherein the communication interface is used to set the functions that each module can implement; implementing the communication interface, and instantiating the communication interface through the implementation class of the communication interface to obtain the communication interface instance.

[0010] Optionally, before the step of generating corresponding registration machine objects for each module according to the full class name of the registration machine class of each module in the configuration file, the step further includes: defining the registration machine class and writing the full class name of the registration machine class into the configuration file.

[0011] To achieve the above objective, according to one aspect of an embodiment of the present invention, a device for inter-module communication is provided.

[0012] An inter-module communication device according to an embodiment of the present invention comprises: a routing class acquisition unit, used to call a predefined registration machine class to obtain a registration machine object, and obtain a routing class through the registration machine object; wherein the registration machine class includes the routing class, and the routing class includes an instance acquisition function for obtaining a communication interface instance of each module; an instance acquisition unit, used to call the instance acquisition function of the routing class, and pass a preset target module identifier into the instance acquisition function to obtain a communication interface instance corresponding to the target module identifier; and a function calling unit, used to convert the communication interface instance into a communication interface, and call a function defined in the communication interface to achieve communication between modules.

[0013] Optionally, the registration machine class also includes a module identifier of its own module, an acquisition function for acquiring a communication interface instance of a target module through the routing class, and an instance return function for returning the communication interface instance of its own module; the routing class also includes multiple module identifiers and corresponding registration machine objects; the instance acquisition unit is further used to: acquire the corresponding registration machine object of the target module according to the target module identifier; call the instance return function in the registration machine class corresponding to the registration machine object to return the communication interface instance of the target module; and call the acquisition function to acquire the communication interface instance of the target module.

[0014] Optionally, the device also includes: a generating and saving unit, which is used to generate a corresponding registration machine object for each module according to the full class name of the registration machine class of each module in the configuration file; and obtain the module identifier of each module through the registration machine object, and save the module identifier and the registration machine object in the form of a key-value pair in the routing class.

[0015] Optionally, the device also includes: a definition implementation unit, used to define a communication interface; wherein the communication interface is used to set the functions that each module can implement; and implement the communication interface, instantiating the communication interface through the implementation class of the communication interface to obtain the communication interface instance.

[0016] Optionally, the device further comprises: a definition writing unit, configured to define the registration machine class and write the full class name of the registration machine class into the configuration file.

[0017] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device is provided.

[0018] An electronic device according to an embodiment of the present invention comprises: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement a method for inter-module communication according to an embodiment of the present invention.

[0019] To achieve the above objective, according to another aspect of the embodiments of the present invention, a computer readable medium is provided.

[0020] A computer-readable medium according to an embodiment of the present invention stores a computer program, and when the program is executed by a processor, a method for inter-module communication according to an embodiment of the present invention is implemented.

[0021] An embodiment of the above invention has the following advantages or beneficial effects: by calling the instance acquisition function in the routing class, the communication interface instance of the target module is obtained, and then the communication between modules can be realized by calling the function in the corresponding communication interface. The call is simple and no additional device performance is consumed except for obtaining the communication interface instance; the module identifier and the registration machine class object are pre-saved in the routing class, and the corresponding registration machine class object can be obtained through the target module identifier, and the communication interface instance can be obtained through the registration machine class object; the module identifier and the registration machine class object are saved in the routing class in the form of a key-value pair to facilitate subsequent search for the corresponding registration machine class object; the communication interface is pre-defined and implemented to set and implement the function of each module; the registration machine class is pre-defined to implement the definition of the module identifier, the preservation of the routing class, the definition of the acquisition function and the definition of the instance return function through this class.

[0022] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0024] Figure 1 is a schematic diagram of main steps of a method for inter-module communication according to an embodiment of the present invention;

[0025] Figure 2 is a schematic diagram of the main flow of the method for inter-module communication according to an embodiment of the present invention;

[0026] Figure 3 is a schematic diagram of the architecture of a system for inter-module communication according to an embodiment of the present invention;

[0027] Figure 4 is a schematic diagram of main units of an apparatus for inter-module communication according to an embodiment of the present invention;

[0028] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0029] Figure 6 It is a schematic diagram of the structure of a computer device suitable for implementing the electronic device of the embodiment of the present invention. DETAILED DESCRIPTION

[0030] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0031] Figure 1 FIG. 1 is a schematic diagram of the main steps of the method for inter-module communication according to an embodiment of the present invention. Figure 1 As shown, the method for inter-module communication in an embodiment of the present invention mainly includes the following steps:

[0032] Step S101: Call the predefined registration machine class to obtain the registration machine object, and obtain the routing class through the registration machine object; wherein the registration machine class includes the routing class, and the routing class includes an instance acquisition function for obtaining the communication interface instance of each module. The registration machine class is a custom class that can define the module identifier, save the routing class, define the acquisition function and the instance return function. The acquisition function is used to obtain the communication interface instance of the target module through the routing class, and the instance return function is used to return the communication interface instance of the own module. The module identifier and the registration machine object are saved in the routing class in the form of a key-value pair. The source module (the module that initiates the communication request) calls the registration machine class of its own module to obtain the registration machine object, and then obtains the routing class through the registration machine object.

[0033] Step S102: Call the instance acquisition function of the routing class, pass the preset target module identifier into the instance acquisition function, and obtain the communication interface instance corresponding to the target module identifier. Assuming that the source module wants to communicate with a certain module, the module is called the target module, and the target module identifier is the module identifier of the target module. In this step, firstly find the registration machine object corresponding to the target module identifier through the key-value pair; then call the instance return function of the found registration machine object to return the communication interface instance of the target module; then call the acquisition function of the source module to obtain the communication interface instance of the target module.

[0034] Step S103: convert the communication interface instance into a communication interface, and call the function defined in the communication interface to achieve communication between modules. The source module converts the communication interface instance into a communication interface, and calls the function defined in the communication interface according to its own needs, so as to achieve the purpose of communicating with the target module.

[0035] The following is an explanation of the custom terms in this application.

[0036] Registration machine class: A custom class that has at least the following functions: (1) define a unique module identifier for its own module; (2) save the routing class, that is, save the routing class as one of its own member variables; (3) obtain the communication interface instance of the target module through the routing class; (4) return the communication interface instance of its own module.

[0037] Routing class: A custom class that has at least the following functions: (1) storing the module identifier and registration machine object of each module in the form of key-value pairs; (2) obtaining the communication interface instance of each module.

[0038] Figure 2 FIG. 1 is a schematic diagram of the main steps of the method for inter-module communication according to an embodiment of the present invention. Figure 2 As shown, the method for inter-module communication in an embodiment of the present invention, taking the communication of a business module key as an example, mainly includes the following steps:

[0039] Step S201: define a communication interface in the common interface module; wherein the communication interface is used to set the functions that each business module can implement. In the embodiment, an interface is defined by Interface, and the interface defines some functions (also called methods), but these functions are not implemented. By defining the communication interface in the common module, in subsequent calls, it can be clearly seen what kind of parameters the target business module needs to receive and what kind of parameters the module will return. In this embodiment, the business module that initiates the call request is called the source business module, and the module to be called is called the target business module.

[0040] Step S202: Implement the communication interface of each business module, and instantiate the communication interface through the implementation class of the communication interface to obtain a communication interface instance. After the communication interface is defined, it can be implemented in the class, that is, the specific implementation logic of the function is written into the implementation class.

[0041] Step S203: define a registration machine class for each business module; wherein the member variables of the registration machine class include a routing class and a module identifier, and the member functions of the registration machine class include a function for obtaining the communication interface instance of other business modules through the routing class and a function for returning the communication interface instance of its own module. The module identifier is a unique identifier of each business module, and the module identifiers of each business module are different from each other. In the embodiment, the module identifier is a string; the routing class includes a function for obtaining the communication interface instance of each business module.

[0042] For the convenience of description, the function in the register class that obtains the communication interface instance of the target business module through the routing class is referred to as the acquisition function, and the function that returns the communication interface instance of its own module is referred to as the instance return function; the function in the routing class that obtains the communication interface instance of each business module is referred to as the instance acquisition function. In a preferred embodiment, the register class is designed as a singleton mode, that is, there is only one register object in a register class. The following implementation process is the specific implementation of the acquisition function in the register class:

[0043]

[0044]

[0045] Step S204: Write the full class name of the registration machine class of each business module into the configuration file of the routing module. The full class name is the complete class name of the registration machine class. When a new business module is added, it is necessary to reconfigure an r node in the configuration file and specify the full class name of the registration machine class through the name attribute. In the embodiment, the configuration file is in XML (EXtensibleMarkup Language) format, and the specific format can be:

[0046]

[0047] Step S205: When the APP is started, each service module calls the initialization method of the routing module to read the configuration file. The APP is started, the routing module is initialized, and the configuration file is read through the pre-written program code.

[0048] Step S206: Each business module parses the configuration file to obtain the full class name of the registration machine class of its own business module, and then generates a registration machine object through the reflection mechanism. The configuration file is parsed to obtain the value of the name attribute, which is the full class name of the registration machine class.

[0049] Step S207: Each business module obtains the module identification of its own business module through the register object, and saves the module identification and the register object in the form of a key-value pair to the routing class of the routing module. The key of the key-value pair is the module identification, and the value is the register object.

[0050] Step S208: When a business module initiates a call request to the routing module, the registration machine class of its own business module is called to obtain the registration machine object, and the routing class is obtained through the registration machine object. The call request includes a target module identifier, and the target module identifier is the module identifier of the business module with which the business module wants to communicate.

[0051] Step S209: The source business module calls the instance acquisition function of the routing class, and passes the target module identifier into the instance acquisition function to obtain the communication interface instance corresponding to the target module identifier. In this step, the routing class of the routing module first searches for the key-value pair according to the target module identifier to obtain the registration machine object of the target business module; then the registration machine object of the target business module returns the communication interface instance of its own module to the routing class of the routing module through the instance return function in its registration machine class; then the routing class of the routing module caches the received communication interface instance, and the source business module calls the acquisition function of its own registration machine class to obtain the communication interface instance of the target business module.

[0052] Step S210: The source service module converts the communication interface instance into a communication interface and calls the function defined in the communication interface to achieve communication with the target service module. The source service module converts the acquired communication interface instance into a communication interface and calls the function defined in the communication interface according to its own needs, thereby achieving the purpose of communicating with the target service module.

[0053] In the above steps, steps S201 to S204 are the preparation process, steps S205 to S207 are the registration process of each service module, and steps S208 to S210 are the communication process between each service module.

[0054] The communication process of the present invention is further described in detail below by taking the login module calling the user module as an example.

[0055] (1) The login module calls its own registration machine class to obtain the registration machine object of its own module, and obtains the routing class IRouterCommunication through the registration machine object. The getService method is defined in the routing class to obtain the communication interface instance of each business module.

[0056] IRouterCommunication router=UserRegister.getIns().getRouter();

[0057] (2) Call the getService method defined in IRouterCommunication and pass in the module identifier of the user module to obtain the communication interface instance of the user module.

[0058] Object userComm=router.getService("user_tag");

[0059] Among them, the implementation of getService() is as follows:

[0060]

[0061] (3) The Object object returned by the getService method is strongly converted into the communication interface of the user module, and userComm is used to call the method defined in IUserCommunication to realize communication with the user module. The strong conversion is implemented as follows:

[0062] IUserCommunication userComm=(IUserCommunication)object;

[0063] Figure 3 FIG. 1 is a schematic diagram of the architecture of a system for inter-module communication according to an embodiment of the present invention. Figure 3 As shown, the method of inter-module communication in an embodiment of the present invention is implemented by an inter-module communication system, which includes an application entry module, a routing module, at least one business module and a public interface module. The application entry module provides an entry for an APP, and the module includes pages related to program startup such as a startup page, a boot page, and an advertisement page. The routing module is used to save the registration information of each business module, and at the same time provides each business module with a function for obtaining communication interface instances of other business modules. The business module is a module related to a specific business in an APP, such as a login module that provides login and registration functions, a web page module that provides web browsing functions, etc.; this module is used to implement the communication interface and define the registration machine class. The public interface module is used to define the communication interface of each business module and the commonly used underlying tools. The communication interface defines all the functions that each business module can provide to the outside world; the underlying tools, such as network requests, image loading, database operations, etc., each business module can selectively rely on these underlying tools according to actual business needs.

[0064] In a preferred embodiment, the functions of the application entry module and the routing module are relatively simple and the possibility of modification is relatively small, so the two modules can be combined into one.

[0065] It can be seen from the method for inter-module communication in the embodiment of the present invention that the communication interface instance of the target module is obtained by calling the instance acquisition function in the routing class, and then the communication between modules can be realized by calling the function in the corresponding communication interface. The calling is simple and no additional device performance is consumed except for obtaining the communication interface instance; the module identifier and the registration machine class object are pre-saved in the routing class, and the corresponding registration machine class object can be obtained through the target module identifier, and the communication interface instance can be obtained through the registration machine class object; the module identifier and the registration machine class object are saved in the routing class in the form of a key-value pair to facilitate subsequent search for the corresponding registration machine class object; the communication interface is pre-defined and implemented to set and implement the function of each module; the registration machine class is pre-defined to implement the definition of the module identifier, the preservation of the routing class, and the definition of the acquisition function and the instance return function through this class.

[0066] Figure 4 Schematic diagram of main modules of the device for inter-module communication according to an embodiment of the present invention. Figure 4 As shown, the inter-module communication device 400 of the embodiment of the present invention mainly includes:

[0067] The routing class acquisition unit 401 is used to call the predefined registration machine class to obtain the registration machine object, and obtain the routing class through the registration machine object; wherein the registration machine class includes the routing class, and the routing class includes an instance acquisition function for obtaining the communication interface instance of each module. The registration machine class is a custom class that can define the module identifier, save the routing class, define the acquisition function and the instance return function, the acquisition function is used to obtain the communication interface instance of the target module through the routing class, and the instance return function is used to return the communication interface instance of the own module. The module identifier and the registration machine object are saved in the routing class in the form of a key-value pair.

[0068] The instance acquisition unit 402 is used to call the instance acquisition function of the routing class, pass the preset target module identifier into the instance acquisition function, and obtain the communication interface instance corresponding to the target module identifier. The unit first finds the registration machine object corresponding to the target module identifier through the key-value pair; then calls the instance return function of the found registration machine object to return the communication interface instance of the target module; and then calls the acquisition function of the source module to obtain the communication interface instance of the target module.

[0069] The function calling unit 403 is used to convert the communication interface instance into a communication interface and call the function defined in the communication interface to achieve communication between modules. The communication interface instance is forcibly converted into a communication interface, and the function defined in the communication interface is called according to its own needs, so as to achieve the purpose of communicating with the target module.

[0070] In addition, the device 400 for inter-module communication in the embodiment of the present invention may also include: a generation and preservation unit, a definition implementation unit and a definition writing unit (not shown in the figure). Among them, the generation and preservation unit is used to generate a corresponding registration machine object for each module according to the full class name of the registration machine class of each module in the configuration file; and obtain the module identification of each module through the registration machine object, and save the module identification and the registration machine object in the form of a key-value pair to the routing class. The definition implementation unit is used to define a communication interface; wherein the communication interface is used to set the functions that each module can implement; and implement the communication interface, and instantiate the communication interface through the implementation class of the communication interface to obtain the communication interface instance. The definition writing unit is used to define the registration machine class and write the full class name of the registration machine class into the configuration file.

[0071] From the above description, it can be seen that by calling the instance acquisition function in the routing class, the communication interface instance of the target module is obtained, and then the communication between modules can be realized by calling the function in the corresponding communication interface. The call is simple and no additional device performance is consumed except for obtaining the communication interface instance; the module identifier and the registration machine class object are pre-saved in the routing class, and the corresponding registration machine class object can be obtained through the target module identifier, and the communication interface instance can be obtained through the registration machine class object; the module identifier and the registration machine class object are saved in the routing class in the form of a key-value pair to facilitate subsequent search for the corresponding registration machine class object; the communication interface is pre-defined and implemented to set and implement the function of each module; the registration machine class is pre-defined to implement the definition of the module identifier, the preservation of the routing class, the definition of the acquisition function and the definition of the instance return function through this class.

[0072] Figure 5 An exemplary system architecture 500 is shown to which the method for inter-module communication or the apparatus for inter-module communication according to the embodiment of the present invention can be applied.

[0073] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0074] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0075] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0076] The server 505 may be a server that provides various services, such as a background management server (only an example) that provides support for click events generated by users using the terminal devices 501, 502, and 503. The background management server may analyze and process the received click data, text content, and other data, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0077] It should be noted that the method for inter-module communication provided in the embodiment of the present application is generally executed by the server 505 , and accordingly, the device for inter-module communication is generally set in the server 505 .

[0078] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0079] According to an embodiment of the present invention, the present invention also provides an electronic device and a computer-readable medium.

[0080] The electronic device of the present invention comprises: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method of inter-module communication of an embodiment of the present invention.

[0081] The computer-readable medium of the present invention stores a computer program, and when the program is executed by a processor, a method for inter-module communication according to an embodiment of the present invention is implemented.

[0082] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 suitable for implementing an electronic device of an embodiment of the present invention. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0083] like Figure 6As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0084] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0085] In particular, according to the embodiments disclosed in the present invention, the process described in the main step diagram above can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the main step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0086] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0087] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0088] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be arranged in a processor, for example, may be described as: a processor includes a routing class acquisition unit, an instance acquisition unit and a function call unit. The names of these units do not constitute a limitation on the units themselves in certain circumstances, for example, the routing class acquisition unit may also be described as "a unit that calls a predefined registration machine class to obtain a registration machine object, and obtains a routing class through the registration machine object".

[0089] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: calling a predefined registration machine class to obtain a registration machine object, and obtaining a routing class through the registration machine object; wherein the registration machine class includes the routing class, and the routing class includes an instance acquisition function for obtaining a communication interface instance of each module; calling the instance acquisition function of the routing class, passing a preset target module identifier into the instance acquisition function, so as to obtain a communication interface instance corresponding to the target module identifier; converting the communication interface instance into a communication interface, and calling the function defined in the communication interface.

[0090] From the above description, it can be seen that by calling the instance acquisition function in the routing class, the communication interface instance of the target module is obtained, and then the communication between modules can be realized by calling the function in the corresponding communication interface. The call is simple and no additional device performance is consumed except for obtaining the communication interface instance; the module identifier and the registration machine class object are pre-saved in the routing class, and the corresponding registration machine class object can be obtained through the target module identifier, and the communication interface instance can be obtained through the registration machine class object; the module identifier and the registration machine class object are saved in the routing class in the form of a key-value pair to facilitate subsequent search for the corresponding registration machine class object; the communication interface is pre-defined and implemented to set and implement the function of each module; the registration machine class is pre-defined to implement the definition of the module identifier, the preservation of the routing class, the definition of the acquisition function and the definition of the instance return function through this class.

[0091] The above product can execute the method provided by the embodiment of the present invention, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not described in detail in this embodiment, please refer to the method provided by the embodiment of the present invention.

[0092] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for inter-module communication, characterized in that: include: Calling a predefined registration machine class to obtain a registration machine object, and obtaining a routing class through the registration machine object; wherein the registration machine class includes the routing class, a module identifier of its own module, an acquisition function for acquiring a communication interface instance of a target module through the routing class, and an instance return function for returning the communication interface instance of its own module, and the routing class includes an instance acquisition function for acquiring an instance of a communication interface of each module, a plurality of the module identifiers, and corresponding registration machine objects; Calling the instance acquisition function of the routing class, passing the preset target module identifier into the instance acquisition function to obtain the communication interface instance corresponding to the target module identifier, including: obtaining the corresponding target module registration machine object according to the target module identifier; calling the instance return function in the registration machine class corresponding to the registration machine object to return the communication interface instance of the target module; calling the acquisition function to obtain the communication interface instance of the target module; The communication interface instance is converted into a communication interface, and the function defined in the communication interface is called to realize communication between modules.

2. The method according to claim 1, characterized in that Before the step of calling the predefined registration machine class to obtain the registration machine object, the method further includes: Generate a registration machine object for each module according to the full class name of the registration machine class of each module in the configuration file; The module identifier of each module is obtained through the registration machine object, and the module identifier and the registration machine object are saved in the routing class in the form of a key-value pair.

3. The method according to claim 1, characterized in that Before the step of obtaining the communication interface instance corresponding to the target module identifier, the method further includes: Defining a communication interface; wherein the communication interface is used to set the functions that each module can implement; The communication interface is implemented, and the communication interface is instantiated through the implementation class of the communication interface to obtain the communication interface instance.

4. The method according to claim 2, characterized in that: Before the step of generating corresponding registration machine objects of each module according to the full class name of the registration machine class of each module in the configuration file, the method further includes: defining the registration machine class and writing the full class name of the registration machine class into the configuration file.

5. A device for inter-module communication, characterized in that: include: A routing class acquisition unit, used to call a predefined registration machine class to obtain a registration machine object, and obtain a routing class through the registration machine object; wherein the registration machine class includes the routing class, a module identifier of its own module, an acquisition function for acquiring a communication interface instance of a target module through the routing class, and an instance return function for returning the communication interface instance of its own module; the routing class includes an instance acquisition function for acquiring an instance of a communication interface of each module, a plurality of the module identifiers and corresponding registration machine objects; An instance acquisition unit, used for calling the instance acquisition function of the routing class, passing a preset target module identifier into the instance acquisition function, so as to acquire a communication interface instance corresponding to the target module identifier; A function calling unit, used to convert the communication interface instance into a communication interface, and call the function defined in the communication interface to realize communication between modules; The instance acquisition unit is further used for: Obtain the registration machine object of the corresponding target module according to the target module identifier; Calling the instance return function in the registration machine class corresponding to the registration machine object to return the communication interface instance of the target module; as well as The acquisition function is called to acquire the communication interface instance of the target module.

6. The device according to claim 5, characterized in that The device also includes: a generating and saving unit for Generate a corresponding registration machine object for each module according to the full class name of the registration machine class of each module in the configuration file; and The module identifier of each module is obtained through the registration machine object, and the module identifier and the registration machine object are saved in the routing class in the form of a key-value pair.

7. The device according to claim 5, characterized in that The device also includes: a definition implementation unit, which is used to Defining a communication interface; wherein the communication interface is used to set the functions that each module can implement; and The communication interface is implemented, and the communication interface is instantiated through the implementation class of the communication interface to obtain the communication interface instance.

8. The device according to claim 6, characterized in that The device further comprises: a definition writing unit, which is used to define the registration machine class and write the full class name of the registration machine class into the configuration file.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.