CN110347371A - A kind of method and apparatus of intermodule communication - Google Patents

A kind of method and apparatus of intermodule communication Download PDF

Info

Publication number
CN110347371A
CN110347371A CN201810287382.9A CN201810287382A CN110347371A CN 110347371 A CN110347371 A CN 110347371A CN 201810287382 A CN201810287382 A CN 201810287382A CN 110347371 A CN110347371 A CN 110347371A
Authority
CN
China
Prior art keywords
module
class
communication interface
register machine
function
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810287382.9A
Other languages
Chinese (zh)
Inventor
胡锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201810287382.9A priority Critical patent/CN110347371A/en
Publication of CN110347371A publication Critical patent/CN110347371A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/457Communication

Abstract

The invention discloses a kind of method and apparatus of intermodule communication, are related to field of computer technology.One specific embodiment of this method includes: that predefined register machine class is called to obtain register machine object, routes class by the register machine object acquisition;The case-based system function for calling the routing class, is passed to the case-based system function for preset object module mark, identifies corresponding communication interface example to obtain the object module;It is communication interface by the communication interface instance transfer, function defined in the communication interface is called, to realize the communication of intermodule.The embodiment obtains the communication interface example of object module, and then call the function in corresponding communication interface, realizes the communication of intermodule by calling the case-based system function in routing class.The method call of the embodiment of the present invention is simple, is not necessarily to additionally consume equipment performance in addition to obtaining communication interface example.

Description

A kind of method and apparatus of intermodule communication
Technical field
The present invention relates to computer field more particularly to a kind of method and apparatus of intermodule communication.
Background technique
In mobile terminal in APP (Application, application program) development process, with the progress of exploration project, function Iteration, code can be more and more.If all codes mixed in miscellaneous to one file, later maintenance difficulty is inevitably resulted in, Compilation speed reduces.To avoid the above problem, modularization framework can be used in APP development process, i.e., is split exploration project At mutually independent module, the modification of a module does not influence other modules.In modularization framework, each intermodule how is realized Communication be a key problem.In the prior art by uniform resource locator (Uniform Resource Locator, URL) or intermodule communication is realized in broadcast.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery: URL communication mode is needed Parameter is mutually turned back and forth with character string, broadcast communication mode needs to localize parameter, in the process for mutually turning or localizing In, a part of performance of equipment can be consumed, when especially intermodule communication is more frequent, will cause the urgency of equipment performance Play decline.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus of intermodule communication, by calling in routing class Case-based system function, obtain the communication interface example of object module, and then call the function in corresponding communication interface, realize mould Communication between block.The method call of the embodiment of the present invention is simple, is not necessarily to additionally consume equipment in addition to obtaining communication interface example Energy.
Realize that above-mentioned purpose provides a kind of method of intermodule communication according to an aspect of an embodiment of the present invention.
The method of a kind of intermodule communication of the embodiment of the present invention, comprising: predefined register machine class is called to obtain registration Machine object routes class by the register machine object acquisition;Wherein, the register machine class includes the routing class, the routing Class includes the case-based system function for obtaining the communication interface example of each module;The case-based system function of the routing class is called, Preset object module mark is passed to the case-based system function, identifies corresponding communication to obtain the object module Interface instance;It is communication interface by the communication interface instance transfer, calls function defined in the communication interface, realizes The communication of intermodule.
Optionally, the register machine class further includes the module id of own module, by routing class acquisition target mould The example return function of the communication interface example for obtaining function and returning to own module of the communication interface example of block;The routing Class further includes multiple module ids and corresponding register machine object;It is described to obtain the corresponding communication of the object module mark Interface instance, comprising: the register machine object of corresponding object module is obtained according to object module mark;Call the registration Example return function in the corresponding register machine class of machine object, to return to the communication interface example of the object module;Call institute Acquisition function is stated, to obtain the communication interface example of the object module.
Optionally, before described the step of calling predefined register machine class to obtain register machine object, further includes: according to matching Set the universal class name of the register machine class of each module in file, the corresponding register machine object for generating each module;Pass through the note The module id of volume each module of machine object acquisition, by the module id and the register machine object in the form of key-value pair It is saved in the routing class.
Optionally, before described the step of obtaining the object module mark corresponding communication interface example, further includes: fixed Adopted communication interface;Wherein, the communication interface is for being arranged the function that each module can be realized;Realize the communication interface, The communication interface is instantiated by the realization class of the communication interface, to obtain the communication interface example.
Optionally, the universal class name of the register machine class according to module each in configuration file, it is corresponding to generate each mould Before the step of register machine object of block, further includes: define the register machine class, institute is written in the universal class name of the register machine class State configuration file.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of device of intermodule communication is provided.
A kind of device of intermodule communication of the embodiment of the present invention, comprising: routing class acquiring unit, it is predefined for calling Register machine class obtain register machine object, pass through the register machine object acquisition route class;Wherein, the register machine class includes institute Routing class is stated, the routing class includes the case-based system function for obtaining the communication interface example of each module;Case-based system unit, For calling the case-based system function of the routing class, preset object module mark is passed to the case-based system letter Number identifies corresponding communication interface example to obtain the object module;Function calling cell, for the communication interface is real Example is converted to communication interface, function defined in the communication interface is called, to realize the communication of intermodule.
Optionally, the register machine class further includes the module id of own module, by routing class acquisition target mould The example return function of the communication interface example for obtaining function and returning to own module of the communication interface example of block;The routing Class further includes multiple module ids and corresponding register machine object;The case-based system unit, is also used to: according to the mesh Mark module id obtains the register machine object of corresponding object module;It calls in the corresponding register machine class of the register machine object Example return function, to return to the communication interface example of the object module;And the acquisition function is called, described in obtaining The communication interface example of object module.
Optionally, described device further include: storage unit is generated, for the register machine according to module each in configuration file The universal class name of class, the corresponding register machine object for generating each module;And pass through each mould of the register machine object acquisition The module id and the register machine object are saved in the routing class by the module id of block in the form of key-value pair.
Optionally, described device further include: unit is realized in definition, for defining communication interface;Wherein, the communication interface The function of can be realized for each module to be arranged;And realize the communication interface, pass through the realization class of the communication interface The communication interface is instantiated, to obtain the communication interface example.
Optionally, described device further include: writing unit is defined, for defining the register machine class, by the register machine The configuration file is written in the universal class name of class.
To achieve the above object, according to an embodiment of the present invention in another aspect, providing a kind of electronic equipment.
The a kind of electronic equipment of the embodiment of the present invention, comprising: one or more processors;Storage device, for storing one A or multiple programs, when one or more of programs are executed by one or more of processors, so that one or more The method that a processor realizes a kind of intermodule communication of the embodiment of the present invention.
To achieve the above object, according to an embodiment of the present invention in another aspect, providing a kind of computer-readable medium.
A kind of computer-readable medium of the embodiment of the present invention, is stored thereon with computer program, and described program is processed A kind of method of intermodule communication of the embodiment of the present invention is realized when device executes.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that by calling the example in routing class to obtain Function is taken, obtains the communication interface example of object module, and then can be by calling the function in corresponding communication interface to realize mould Communication between block, calling is simple, is not necessarily to additionally consume equipment performance in addition to obtaining communication interface example;By module id and registration Machine class object is pre-stored in routing class, corresponding register machine class object can be obtained by object module mark, by this Register machine class object can communication interface example;Module id and register machine class object are saved in routing in the form of key-value pair In class, facilitate the corresponding register machine class object of subsequent lookup;Communication interface is pre-defined and realizes, to be arranged and realize each mould The function of block;Pre-defined register machine class, to realize the definition of module id by such, the preservation for routing class, obtain function With the definition of example return function.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is the schematic diagram of the key step of the method for intermodule communication according to an embodiment of the present invention;
Fig. 2 is the main flow schematic diagram of the method for intermodule communication according to an embodiment of the present invention;
Fig. 3 is the configuration diagram of the system of intermodule communication according to an embodiment of the present invention;
Fig. 4 is the schematic diagram of the formant of the device of intermodule communication according to an embodiment of the present invention;
Fig. 5 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 6 is the structural schematic diagram for being suitable for the computer installation of the electronic equipment to realize the embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
Fig. 1 is the schematic diagram of the key step of the method for intermodule communication according to an embodiment of the present invention.As shown in Figure 1, The method of the intermodule communication of the embodiment of the present invention, mainly includes the following steps:
Step S101: it calls predefined register machine class to obtain register machine object, passes through register machine object acquisition road By class;Wherein, the register machine class includes the routing class, and the routing class includes obtaining the communication interface example of each module Case-based system function.Register machine class is a customized class, such can be realized definition module mark, preservation routes class, Definition obtains function and example return function, and the communication interface for obtaining function for obtaining object module by routing class is real Example, the example return function are used to return the communication interface example of own module.It is saved in the form of key-value pair in routing class The module id and the register machine object.Source module (module for initiating communication request) calls the register machine of own module Class to obtain register machine object, and then passes through register machine object acquisition to routing class.
Step S102: calling the case-based system function of the routing class, and preset object module is identified incoming institute Case-based system function is stated, identifies corresponding communication interface example to obtain the object module.Assuming that source module will be with some mould Block is communicated, which is known as object module, the object module mark is the module id of object module.The step In object module found by key-value pair first identify corresponding register machine object;The register machine object found is called later Example return function, to return to the communication interface example of object module;Then the acquisition function of source module is called, to obtain mesh Mark the communication interface example of module.
Step S103: it is communication interface by the communication interface instance transfer, calls letter defined in the communication interface Number, to realize the communication of intermodule.Communication interface example is converted to by force communication interface by source module, and calling according to their needs should Function defined in communication interface, to achieve the purpose that be communicated with object module.
Word customized in the application is explained below.
Register machine class: a customized class, such is at least with the following functions: (1) defining one only for own module One module id;(2) routing class is saved, i.e., will route a member variable of the class preservation at oneself;(3) it is obtained by routing class Take the communication interface example of object module;(4) the communication interface example of own module is returned.
Route class: a customized class, such is at least with the following functions: (1) being stored in the form of key-value pair each The module id and register machine object of module;(2) the communication interface example of each module is obtained.
Fig. 2 is the schematic diagram of the key step of the method for intermodule communication according to an embodiment of the present invention.As shown in Fig. 2, The method of the intermodule communication of the embodiment of the present invention mainly includes the following steps: by taking the communication of business module key as an example
Step S201: communication interface is defined in common interface module;Wherein, the communication interface is for being arranged each business The function that module can be realized.An interface is defined with Interface in embodiment, this interface define some functions (can also Referred to as method), but there is no realize for these functions.It, can in subsequent calls by defining communication interface in public module Need to receive which type of parameter and the module can return to which type of parameter with very clear target service module of seeing. The business module for initiating call request will be known as source business module in the present embodiment, called module is known as target service Module.
Step S202: realizing the communication interface of own module respectively in each business module, passes through the communication interface Realize that class instantiates the communication interface, to obtain communication interface example.Communication interface is after definition, so that it may The communication interface is realized in class, i.e., the specific implementation logic of function is write and realize in class.
Step S203: a register machine class is defined respectively for each business module;Wherein, the member variable of the register machine class Including routing class and module id, the member function of the register machine class includes obtaining other business modules by the routing class Communication interface example function and return own module communication interface example function.The module id is each business mould The unique identification of block, and the module id of each business module is different, the module id is a character string in embodiment; It include the function for obtaining the communication interface example of each business module in the routing class.
For convenience of description, hereinafter the communication for obtaining target service module by the routing class in register machine class is connect The function of cause for gossip example is known as obtaining function, and the function for the communication interface example for returning to own module is known as example return function; The function of the communication interface example of each business module of acquisition routed in class is known as case-based system function.It is preferred real one It applies in example, the register machine class is designed as singleton pattern, i.e. only one register machine object in a register machine class.Following realities Existing process is the specific implementation of the acquisition function in register machine class:
Step S204: will be in the configuration file of the universal class name write-in routing module of the register machine class of each business module. The complete class name of the entitled register machine class of universal class.When having increased a business module newly, need to match again in configuration file A r node is set, and specifies the universal class name of register machine class by name attribute.Configuration file described in embodiment is XML (EXtensibleMarkup Language, extensible markup language) format, specific format can be with are as follows:
Step S205: when APP starting, each business module calls the initial method of routing module respectively, to read State configuration file.Start APP, initialize routing module, configuration file is read by the program code write in advance.
Step S206: each business module parses the configuration file respectively, to obtain the register machine class of itself business module Universal class name, later pass through reflection mechanism generate register machine object.The configuration file is parsed, the value of name attribute is obtained, it should Value is the universal class name of the register machine class.
Step S207: each business module is by the module id of the register machine object acquisition own service module, by institute It states module id and the register machine object is saved in the routing class of routing module in the form of key-value pair.In the key-value pair Key is that module id is key, is worth for register machine object.
Step S208: when some business module initiates call request to routing module, the note of own service module is called Volume machine class obtains register machine object, routes class by the register machine object acquisition.It wherein, include target in the call request Module id, the object module are identified as the module id for the business module that the business module to be communicated.
Step S209: source business module calls the case-based system function of the routing class, and object module is identified incoming institute Case-based system function is stated, identifies corresponding communication interface example to obtain the object module.In the step, routing module first Routing class according to the object module identifier lookup key-value pair, to obtain the register machine object of target service module;Mesh later The register machine of mark business module passes through the example return function in its register machine class to object, and the communication interface of own module is real Example is back to the routing class of routing module;The routing class of routing module caches the communication interface example received, source business later Module calls the acquisition function of itself register machine class, to obtain the communication interface example of the target service module.
Step S210: the communication interface instance transfer is communication interface by source business module, calls the communication interface Defined in function, to realize and the communication of target service module.The communication interface example that source business module will acquire turns by force It is changed to communication interface, calls function defined in the communication interface according to their needs, to reach logical with target service module The purpose of letter.
In above-mentioned steps, step S201 to step S204 is preparation process, and step S205 to step S207 is each business mould The registration process of block, communication process of the step S208 to step S210 between each business module.
Below by taking login module calls line module as an example, communication process of the invention is further described in detail.
(1) login module calls the register machine class of itself, obtains the register machine object of own module, passes through the register machine Object acquisition routes class IRouterCommunication.GetService method is defined in routing class, it is each for obtaining The communication interface example of business module.
IRouterCommunication router=UserRegister.getIns () .getRouter ();
(2) getService method defined in IRouterCommunication, and the mould of incoming line module are called Block identification, to obtain the communication interface example of line module.
Object userComm=router.getService (" user_tag ");
Wherein, getService () is accomplished by
(3) the Object object that getService method returns is converted by force to the communication interface of line module, is used UserComm calls method defined in IUserCommunication, to realize the communication with line module.The reality converted by force It is existing are as follows:
IUserCommunication userComm=(IUserCommunication) object;
Fig. 3 is the configuration diagram of the system of intermodule communication according to an embodiment of the present invention.As shown in figure 3, of the invention The method of the intermodule communication of embodiment is realized that the system includes using inlet module, routing mould by the system of intermodule communication Block, at least one business module and common interface module.Entrance is provided for an APP using inlet module, includes in the module Open the pages relevant to program starting such as screen page, guide page, advertising page.Routing module is used to save the registration letter of each business module Breath, while the function for obtaining the communication interface example of other business modules being provided for each business module.Business module is one Module relevant to specific business in APP, for example provide and log in, the login module of registering functional, web page browsing function is provided Web page module etc.;The module is for realizing communication interface and defines register machine class.Common interface module, for defining each business mould The communication interface of block and common bottom tool, each business module is defined in the communication interface extraneous to be provided Institute is functional;Described bottom tool, such as the load of network request, picture, database manipulation etc., each business module can be according to reality Border business needs these bottom tools of the dependence of selectivity.
In a preferred embodiment, the function using inlet module and routing module is relatively easy, and modify can Energy property is smaller, therefore can be combined into one the two modules.
The method of intermodule communication through the embodiment of the present invention can be seen that by calling the case-based system in routing class Function obtains the communication interface example of object module, and then can be by calling the function in corresponding communication interface to realize module Between communication, call it is simple, be not necessarily to additionally consume equipment performance in addition to obtaining communication interface example;By module id and register machine Class object is pre-stored in routing class, can be obtained corresponding register machine class object by object module mark, be passed through the note Volume machine class object can communication interface example;Module id and register machine class object are saved in routing class in the form of key-value pair In, facilitate the corresponding register machine class object of subsequent lookup;Communication interface is pre-defined and realizes, to be arranged and realize each module Function;Pre-defined register machine class, with the definition that module id is realized by such, the preservation for routing class, acquisition function and The definition of example return function.
Fig. 4 is the schematic diagram of the main modular of the device of intermodule communication according to an embodiment of the present invention.As shown in figure 4, The device 400 of the intermodule communication of the embodiment of the present invention, specifically includes that
Class acquiring unit 401 is routed, for calling predefined register machine class to obtain register machine object, passes through the registration Machine object acquisition routes class;Wherein, the register machine class includes the routing class, and the routing class includes obtaining each module The case-based system function of communication interface example.Register machine class be a customized class, such can be realized definition module mark, Routing class, definition acquisition function and example return function are saved, the acquisition function is used to obtain object module by routing class Communication interface example, the example return function is used to return to the communication interface example of own module.It routes in class with key assignments The module id and the register machine object are saved to form.
Case-based system unit 402, for calling the case-based system function of the routing class, by preset object module Mark is passed to the case-based system function, identifies corresponding communication interface example to obtain the object module.The unit is first Object module, which is found, by key-value pair identifies corresponding register machine object;The example of the register machine object found is called later Return function, to return to the communication interface example of object module;Then the acquisition function of source module is called, to obtain object module Communication interface example.
Function calling cell 403 calls the communication interface for being communication interface by the communication interface instance transfer Defined in function, to realize the communication of intermodule.Communication interface example is converted to by force communication interface, is adjusted according to their needs The function defined in the communication interface, to achieve the purpose that be communicated with object module.
In addition, the device 400 of the intermodule communication of the embodiment of the present invention can also include: to generate storage unit, definition in fact Existing unit and definition writing unit (not shown).Wherein, storage unit is generated, for according to module each in configuration file Register machine class universal class name, the corresponding register machine object for generating each module;And pass through the register machine object acquisition The module id and the register machine object are saved in the road by the module id of each module in the form of key-value pair By in class.Unit is realized in definition, for defining communication interface;Wherein, the communication interface can be real for each module to be arranged Existing function;And realize the communication interface, the communication interface is carried out by example by the realization class of the communication interface Change, to obtain the communication interface example.Writing unit is defined, for defining the register machine class, by the register machine class The configuration file is written in universal class name.
From the above, it can be seen that obtaining the communication of object module by calling the case-based system function in routing class Interface instance, and then can be called by calling the communication for corresponding to the function in communication interface and realizing intermodule simply, except acquisition It is not necessarily to additionally consume equipment performance outside communication interface example;Module id and register machine class object are pre-stored in routing class In, corresponding register machine class object can be obtained by object module mark, it can communication interface by the register machine class object Example;Module id and register machine class object are saved in routing class in the form of key-value pair, facilitate subsequent lookup corresponding Register machine class object;Communication interface is pre-defined and realizes, to be arranged and realize the function of each module;Pre-defined register machine Class, to realize the definition, the preservation for routing class, the definition for obtaining function and example return function of module id by such.
Fig. 5 is shown can showing using the device of the method or intermodule communication of the intermodule communication of the embodiment of the present invention Example property system architecture 500.
As shown in figure 5, system architecture 500 may include terminal device 501,502,503, network 504 and server 505. Network 504 between terminal device 501,502,503 and server 505 to provide the medium of communication link.Network 504 can be with Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 501,502,503 and be interacted by network 504 with server 505, to receive or send out Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 501,502,503 (merely illustrative) such as the application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform softwares.
Terminal device 501,502,503 can be the various electronic equipments with display screen and supported web page browsing, packet Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 505 can be to provide the server of various services, such as utilize terminal device 501,502,503 to user Generated click event provides the back-stage management server (merely illustrative) supported.Back-stage management server can be to receiving The data such as click data, content of text analyze etc. processing, and (such as target push information, product are believed by processing result Breath -- merely illustrative) feed back to terminal device.
It should be noted that the method for intermodule communication provided by the embodiment of the present application is generally executed by server 505, Correspondingly, the device of intermodule communication is generally positioned in server 505.
It should be understood that the number of terminal device, network and server in Fig. 5 is only schematical.According to realization need It wants, can have any number of terminal device, network and server.
According to an embodiment of the invention, the present invention also provides a kind of electronic equipment and a kind of computer-readable medium.
Electronic equipment of the invention includes: one or more processors;Storage device, for storing one or more journeys Sequence, when one or more of programs are executed by one or more of processors, so that one or more of processors are real A kind of method of intermodule communication of the existing embodiment of the present invention.
Computer-readable medium of the invention is stored thereon with computer program, real when described program is executed by processor A kind of method of intermodule communication of the existing embodiment of the present invention.
Below with reference to Fig. 6, it illustrates the computer systems 600 being suitable for realize the electronic equipment of the embodiment of the present invention Structural schematic diagram.Electronic equipment shown in Fig. 6 is only an example, function to the embodiment of the present invention and should not use model Shroud carrys out any restrictions.
As shown in fig. 6, computer system 600 includes central processing unit (CPU) 601, it can be read-only according to being stored in Program in memory (ROM) 602 or be loaded into the program in random access storage device (RAM) 603 from storage section 608 and Execute various movements appropriate and processing.In RAM 603, also it is stored with computer system 600 and operates required various programs And data.CPU 601, ROM 602 and RAM 603 are connected with each other by bus 604.Input/output (I/O) interface 605 It is connected to bus 604.
I/O interface 605 is connected to lower component: the importation 606 including keyboard, mouse etc.;It is penetrated including such as cathode The output par, c 607 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 608 including hard disk etc.; And the communications portion 609 of the network interface card including LAN card, modem etc..Communications portion 609 via such as because The network of spy's net executes communication process.Driver 610 is also connected to I/O interface 605 as needed.Detachable media 611, such as Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 610, in order to read from thereon Computer program be mounted into storage section 608 as needed.
Particularly, disclosed embodiment, the process of key step figure description above may be implemented as counting according to the present invention Calculation machine software program.For example, embodiment of the disclosure includes a kind of computer program product comprising be carried on computer-readable Computer program on medium, the computer program include the program code for executing method shown in key step figure.? In such embodiment, which can be downloaded and installed from network by communications portion 609, and/or from can Medium 611 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 601, system of the invention is executed The above-mentioned function of middle restriction.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device, Or above-mentioned any appropriate combination.In the present invention, computer readable storage medium can be it is any include or storage journey The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this In invention, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal, Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of various embodiments of the invention, method and computer journey The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction It closes to realize.
Being described in unit involved in the embodiment of the present invention can be realized by way of software, can also be by hard The mode of part is realized.Described unit also can be set in the processor, for example, can be described as: a kind of processor packet Include routing class acquiring unit, case-based system unit and function calling cell.Wherein, the title of these units is under certain conditions simultaneously The restriction to the unit itself is not constituted, for example, routing class acquiring unit is also described as " calling predefined register machine Class obtains register machine object, and the unit of class is routed by the register machine object acquisition ".
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes Obtaining the equipment includes: that predefined register machine class is called to obtain register machine object, passes through the register machine object acquisition and routes class; Wherein, the register machine class includes the routing class, and the routing class includes obtaining the reality of the communication interface example of each module Example obtains function;Preset object module mark is passed to the example by the case-based system function for calling the routing class Function is obtained, identifies corresponding communication interface example to obtain the object module;It is logical by the communication interface instance transfer Believe interface, calls function defined in the communication interface.
From the above, it can be seen that obtaining the communication of object module by calling the case-based system function in routing class Interface instance, and then can be called by calling the communication for corresponding to the function in communication interface and realizing intermodule simply, except acquisition It is not necessarily to additionally consume equipment performance outside communication interface example;Module id and register machine class object are pre-stored in routing class In, corresponding register machine class object can be obtained by object module mark, it can communication interface by the register machine class object Example;Module id and register machine class object are saved in routing class in the form of key-value pair, facilitate subsequent lookup corresponding Register machine class object;Communication interface is pre-defined and realizes, to be arranged and realize the function of each module;Pre-defined register machine Class, to realize the definition, the preservation for routing class, the definition for obtaining function and example return function of module id by such.
Method provided by the embodiment of the present invention can be performed in the said goods, has the corresponding functional module of execution method and has Beneficial effect.The not technical detail of detailed description in the present embodiment, reference can be made to method provided by the embodiment of the present invention.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention Within.

Claims (12)

1. a kind of method of intermodule communication characterized by comprising
It calls predefined register machine class to obtain register machine object, class is routed by the register machine object acquisition;Wherein, described Register machine class includes the routing class, and the routing class includes the case-based system letter for obtaining the communication interface example of each module Number;
Preset object module mark is passed to the case-based system letter by the case-based system function for calling the routing class Number identifies corresponding communication interface example to obtain the object module;
It is communication interface by the communication interface instance transfer, function defined in the communication interface is called, to realize module Between communication.
2. the method according to claim 1, wherein the register machine class further includes the module mark of own module Know, the acquisition function of the communication interface example of object module is obtained by the routing class and returns to the communication interface of own module The example return function of example;The routing class further includes multiple module ids and corresponding register machine object;
It is described to obtain the corresponding communication interface example of the object module mark, comprising:
The register machine object of corresponding object module is obtained according to object module mark;
The example return function in the corresponding register machine class of the register machine object is called, to return to the communication of the object module Interface instance;
The acquisition function is called, to obtain the communication interface example of the object module.
3. method according to claim 1 or 2, which is characterized in that described that predefined register machine class is called to obtain registration Before the step of machine object, further includes:
According to the universal class name of the register machine class of module each in configuration file, the corresponding register machine object for generating each module;
By the module id of each module of the register machine object acquisition, by the module id and the register machine object It is saved in the form of key-value pair in the routing class.
4. the method according to claim 1, wherein the corresponding communication of the acquisition object module mark connects Before the step of cause for gossip example, further includes:
Define communication interface;Wherein, the communication interface is for being arranged the function that each module can be realized;
It realizes the communication interface, is instantiated the communication interface by the realization class of the communication interface, to obtain The communication interface example.
5. according to the method described in claim 3, it is characterized in that, the register machine class according to module each in configuration file Universal class name, the step of the corresponding register machine object for generating each module before, further includes: define the register machine class, will The configuration file is written in the universal class name of the register machine class.
6. a kind of device of intermodule communication characterized by comprising
Class acquiring unit is routed, for calling predefined register machine class to obtain register machine object, passes through the register machine object Obtain routing class;Wherein, the register machine class includes the routing class, and the routing class includes obtaining the communication of each module to connect The case-based system function of cause for gossip example;
Preset object module is identified and is passed for calling the case-based system function of the routing class by case-based system unit Enter the case-based system function, identifies corresponding communication interface example to obtain the object module;
Function calling cell is called and is defined in the communication interface for being communication interface by the communication interface instance transfer Function, to realize the communication of intermodule.
7. device according to claim 6, which is characterized in that the register machine class further includes the module mark of own module Know, the acquisition function of the communication interface example of object module is obtained by the routing class and returns to the communication interface of own module The example return function of example;The routing class further includes multiple module ids and corresponding register machine object;
The case-based system unit, is also used to:
The register machine object of corresponding object module is obtained according to object module mark;
The example return function in the corresponding register machine class of the register machine object is called, to return to the communication of the object module Interface instance;And
The acquisition function is called, to obtain the communication interface example of the object module.
8. device according to claim 6 or 7, which is characterized in that described device further include: generate storage unit, be used for
According to the universal class name of the register machine class of module each in configuration file, the corresponding register machine object for generating each module; And
By the module id of each module of the register machine object acquisition, by the module id and the register machine object It is saved in the form of key-value pair in the routing class.
9. device according to claim 6, which is characterized in that described device further include: unit is realized in definition, is used for
Define communication interface;Wherein, the communication interface is for being arranged the function that each module can be realized;And
It realizes the communication interface, is instantiated the communication interface by the realization class of the communication interface, to obtain The communication interface example.
10. device according to claim 8, which is characterized in that described device further include: writing unit is defined, for fixed The configuration file is written in the universal class name of the register machine class by the justice register machine class.
11. a kind of electronic equipment characterized by comprising
One or more processors;
Storage device, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real Now such as method as claimed in any one of claims 1 to 5.
12. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor Such as method as claimed in any one of claims 1 to 5 is realized when row.
CN201810287382.9A 2018-04-03 2018-04-03 A kind of method and apparatus of intermodule communication Pending CN110347371A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810287382.9A CN110347371A (en) 2018-04-03 2018-04-03 A kind of method and apparatus of intermodule communication

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810287382.9A CN110347371A (en) 2018-04-03 2018-04-03 A kind of method and apparatus of intermodule communication

Publications (1)

Publication Number Publication Date
CN110347371A true CN110347371A (en) 2019-10-18

Family

ID=68172368

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810287382.9A Pending CN110347371A (en) 2018-04-03 2018-04-03 A kind of method and apparatus of intermodule communication

Country Status (1)

Country Link
CN (1) CN110347371A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030018825A1 (en) * 2001-07-17 2003-01-23 Johnson Hollis Bruce Methods and systems for providing platform-independent shared software components for mobile devices
CN107015873A (en) * 2017-01-23 2017-08-04 阿里巴巴集团控股有限公司 Call method, component interface device, electronic equipment and the App of App functional module
CN107066341A (en) * 2017-04-12 2017-08-18 武汉斗鱼网络科技有限公司 Event Routing Framework and method between a kind of software module
CN107203419A (en) * 2016-03-17 2017-09-26 阿里巴巴集团控股有限公司 Intermodule call method, apparatus and system in application program
CN107220129A (en) * 2017-04-14 2017-09-29 武汉斗鱼网络科技有限公司 Communication means and system between a kind of software module

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030018825A1 (en) * 2001-07-17 2003-01-23 Johnson Hollis Bruce Methods and systems for providing platform-independent shared software components for mobile devices
CN107203419A (en) * 2016-03-17 2017-09-26 阿里巴巴集团控股有限公司 Intermodule call method, apparatus and system in application program
CN107015873A (en) * 2017-01-23 2017-08-04 阿里巴巴集团控股有限公司 Call method, component interface device, electronic equipment and the App of App functional module
CN107066341A (en) * 2017-04-12 2017-08-18 武汉斗鱼网络科技有限公司 Event Routing Framework and method between a kind of software module
CN107220129A (en) * 2017-04-14 2017-09-29 武汉斗鱼网络科技有限公司 Communication means and system between a kind of software module

Similar Documents

Publication Publication Date Title
CN107357914B (en) Information processing method and device
CN107729106A (en) It is a kind of that the method and apparatus quickly redirected are realized between application component
CN108804327A (en) A kind of method and apparatus of automatic Data Generation Test
CN110472207A (en) List generation method and device
CN109766082A (en) The method and apparatus that the application program page jumps
CN110109979A (en) A kind of allocation list radio button method and apparatus
CN109062563A (en) Method and apparatus for generating the page
CN109325213A (en) Method and apparatus for labeled data
CN109981322A (en) The method and apparatus of cloud resource management based on label
CN109783741A (en) Method and apparatus for pushed information
CN110471848A (en) A kind of method and apparatus of dynamic returned packet
CN110245030A (en) A kind of data service providing method, device, medium and electronic equipment
CN109241033A (en) The method and apparatus for creating real-time data warehouse
CN109062560B (en) Method and apparatus for generating information
CN110427304A (en) O&M method, apparatus, electronic equipment and medium for banking system
CN109389182A (en) Method and apparatus for generating information
CN110134427A (en) A kind of method and apparatus generating code file
CN109582317A (en) Method and apparatus for debugging boarding application
CN108959642A (en) Method and apparatus for information to be written
CN110445632A (en) A kind of method and apparatus for preventing client collapse
CN110070394A (en) Data processing method, system, medium and calculating equipment
CN108959294A (en) A kind of method and apparatus accessing search engine
CN109241409A (en) Method and apparatus for sending information, receiving information
CN108460020A (en) Method and device for obtaining information
CN108694194A (en) A kind of method and apparatus of construction data object

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