[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN111427710B - Communication method, device, equipment and storage medium of components in application program - Google Patents

Communication method, device, equipment and storage medium of components in application program Download PDF

Info

Publication number
CN111427710B
CN111427710B CN202010237927.2A CN202010237927A CN111427710B CN 111427710 B CN111427710 B CN 111427710B CN 202010237927 A CN202010237927 A CN 202010237927A CN 111427710 B CN111427710 B CN 111427710B
Authority
CN
China
Prior art keywords
message
service
sub
component
functional component
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010237927.2A
Other languages
Chinese (zh)
Other versions
CN111427710A (en
Inventor
赵冬冬
彭杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Leading Technology Co Ltd
Original Assignee
Nanjing Leading 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 Nanjing Leading Technology Co Ltd filed Critical Nanjing Leading Technology Co Ltd
Priority to CN202010237927.2A priority Critical patent/CN111427710B/en
Publication of CN111427710A publication Critical patent/CN111427710A/en
Application granted granted Critical
Publication of CN111427710B publication Critical patent/CN111427710B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention discloses a communication method, a device, equipment and a storage medium of a component in an application program, wherein the method is applied to a message bus in a communication framework depended by the application program and comprises the following steps: analyzing the received message request message; if the message request message contains a first key identifier for inter-component communication, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message; the first message monitoring table is formed based on the business logic interface class which is depended by the functional components in the application program in the business service layer. The method solves the problem that the source and the destination of the message cannot be clearly known when the components in the application program are communicated with each other, realizes the effect of clearly knowing the event flow in the whole message transmission process, and has concise codes and high-efficiency decoupling.

Description

Communication method, device, equipment and storage medium of components in application program
Technical Field
The embodiment of the invention relates to a message communication technology, in particular to a communication method, a communication device, communication equipment and a storage medium of a component in an application program.
Background
In a long-term actual combat development process, along with the continuous increase of functions of application software APP, service logics are more and more complex, the modules have an intricate relationship, and one function is modified to pull one action to move the whole body by high coupling, so that the maintenance and development of projects are not facilitated. In order to solve the problems, a plurality of modularization schemes are also emerged in recent years, different modularization schemes have different advantages and disadvantages, but the modularization targets are basically consistent, and only the implementation ideas can be different.
The communication mode is the core of the componentized development. For an Android system, different components of different pages in each App are in message transmission, the message transmission is the most basic component, and the message transmission can be used for communication among the four components of the Android system and can also be used for communication among threads. For Android developers, there are many message delivery methods frequently used, from the earliest used Handler, broadcastretever, interface callback, Binder (all communication mechanisms inside the Android system), to the popular communication frameworks of EventBus, RxBus and the like in recent years, during the use of such communication frameworks, once an event is abused, the code is difficult to debug and maintain due to the unique decoupling characteristic of the communication frameworks during the iteration of time. In addition, in the existing communication framework, when the message communication is performed through the message bus, the message sender is only responsible for sending messages and cannot know the message destination, and the message receiver is only responsible for receiving messages and does not know the message source, so that the whole circulation of events cannot be clearly known.
Disclosure of Invention
The invention provides a communication method, a communication device, communication equipment and a storage medium of a component in an application program, and aims to realize traceability of a communication process of the component in the application program.
In a first aspect, an embodiment of the present invention provides a communication method for a component in an application, where the communication method is applied to a message bus in a communication framework depended by the application, and the communication method for the component in the application includes:
analyzing the received message request message;
if the message request message contains a first key identifier for inter-component communication, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message;
the first message listening table is formed based on the business logic interface class depended by the functional component in the application program at the business service layer.
In a second aspect, an embodiment of the present invention further provides a communication apparatus for a component in an application, where the communication apparatus for a component in an application includes:
the message analysis module is used for analyzing the received message request message;
the component acquisition module is used for acquiring a target function component associated with a first key identifier from a predetermined first message monitoring table if the message request message contains the first key identifier for communication among components, so that the target function component responds to a request operation corresponding to the message request message;
The first message monitoring table is formed based on the business logic interface class which is depended by the functional component in the application program at the business service layer.
In a third aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
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 communication method of the components in the application program according to any one of the embodiments of the present invention.
In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the communication method of the component in the application program according to any one of the embodiments of the present invention.
The embodiment of the invention provides a communication method, a device, equipment and a storage medium of a component in an application program, which are used for analyzing a received message request message; if the message request message contains a first key identifier for inter-component communication, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message; the first message monitoring table is formed based on the business logic interface class which is depended by the functional component in the application program at the business service layer. The target function component is obtained from the first message monitoring table through the first key identification in the message request message obtained through analysis, the problem that the source and the destination of the message cannot be clearly known when the components in the application program communicate with each other is solved, the destination of the message can be clearly known by identifying the first key identification and the first message monitoring table, the source of the message can be clearly known by identifying the first key identification, the effect of clearly knowing the event flow in the whole message transmission process is realized, and the code is concise and has high-efficiency decoupling performance.
Drawings
FIG. 1 is a flowchart of a communication method of components in an application according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an implementation of forming a first message listening table in a communication method of components in an application according to an embodiment of the present invention;
FIG. 3 is a flow chart illustrating an implementation of obtaining a target function component in a communication method of components in an application according to an embodiment of the present invention;
FIG. 4 is a flowchart of a communication method of components in an application according to a second embodiment of the present invention;
fig. 5 is a flowchart illustrating an implementation of forming a second message listening table in a communication method of a component in an application according to a second embodiment of the present invention;
FIG. 6 is a flowchart illustrating an implementation of obtaining a target component sub-service in a communication method for a component in an application provided in the second embodiment of the present invention;
fig. 7 is a block diagram of a communication apparatus of components in an application according to a third embodiment of the present invention;
fig. 8 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a communication method for components in an application according to an embodiment of the present invention, where this embodiment is applicable to a case where components in an application communicate with each other, and the method can be executed by a communication device of a component in an application, and is applied to a message bus in a communication framework that the application depends on, and specifically includes the following steps:
s110, analyzing the received message request message.
In this embodiment, the message request message may be specifically understood as communication information sent by the functional component in the application program to the message bus, and is used for communicating with other functional components. The message request message at least carries an identifier for realizing component communication, and the functional component serving as a message receiver is determined through the identifier, and can also carry data information and a message type for executing corresponding operation after the functional component serving as the message receiver receives the message request message.
Specifically, the message bus analyzes the received message request message, and obtains an identifier carried in the message request message.
S120, if the message request message contains a first key identifier for communication among the components, obtaining a target function component associated with the first key identifier from a predetermined first message monitoring table, so that the target function component responds to a request operation corresponding to the message request message.
In this embodiment, the first message listening table is formed based on a service logic interface class on which a functional component in an application depends at a service layer.
In this embodiment, the first key identifier may be specifically understood as an identifier used for distinguishing functional components in the application program, and is used for communication between the components in the application program, where the first key identifiers of different functional components are different and unique, and the first key identifier is a service logic interface class. The first message monitoring table may be specifically understood as a message monitoring table established according to a corresponding relationship between the first key identifier and the target functional component, and the target functional component corresponding to the first key identifier may be one or more, and is determined according to an actual service requirement. The target functional component may be specifically understood as a functional component that is a receiver of the message request message. A service logic interface class is understood to be a communication interface class, and a functional component has a unique service logic interface class.
Specifically, each functional component in the application program sends its own service logic interface class to the service layer as a precondition for realizing component communication, and the service layer stores multiple service logic interface classes. When the functional component 1 wants to monitor the functional components 2 and 3, the message bus stores the corresponding relation between the functional component 1 and the functional components 2 and 3, namely, the functional component serving as a message receiver is stored as a target functional component in association with the first key identifier of the functional component serving as a message sender to form a first message monitoring table, so that the associated target functional component is determined by the first key identifier of the functional component. The message bus analyzes the message request message, an identifier of a functional component serving as a message sender in the message request message is obtained, if the identifier contained in the message request message is a first key identifier, communication carried out at the moment is inter-component communication, a target functional component is determined according to the association relation between the first key identifier and the target functional component in a predetermined first message monitoring table, the message request message is sent to the target functional component, and the target functional component responds to the request operation corresponding to the message request message after receiving the message request message. For example, the message bus receives a message request message sent by the function module 1, where the message request message includes the first key identifier IService1, a message type (e.g., a login message), and data (e.g., a login success), and according to the first message snoop table, it may be determined that target function components corresponding to the first key identifier IService1 and serving as message receivers are the function component 2(IService2) and the function component 3(IService3), and the message request message is sent to the function component 2 and the function component 3, and the function component 2 and the function component 3 execute corresponding operations according to the message type and the data.
The embodiment of the invention provides a communication method of a component in an application program, which comprises the steps of analyzing a received message request message; if the message request message contains a first key identifier for inter-component communication, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message; the first message listening table is formed based on the business logic interface class depended by the functional component in the application program at the business service layer. The first key identification and the target functional component are associated by establishing a first message monitoring table, so that the target functional component can be effectively acquired in the communication process, the functional component is identified by using the first key identification, and the first key identification is carried in the communication process, so that the functional component serving as a message receiver can determine a message source according to the first key identification after receiving the message; the receiver of the message request message containing the first key identification can be made clear through the first message monitoring table, the definition of event transfer in the whole message transfer process is improved, the event transfer process is made clear, and the message monitoring table is concise in code and has high-efficiency decoupling performance.
Further, an embodiment of the present invention provides a preferred embodiment, and fig. 2 provides an implementation flowchart of forming a first message listening table in a communication method of a component in an application program, where the forming of the first message listening table is further detailed on the basis of the foregoing technical solution, and specifically, the method mainly includes the following steps:
s210, monitoring communication interface types sent by functional components in an application program are received, and each monitoring communication interface type is a business logic interface type which is depended by the corresponding functional component on a business service layer.
In this embodiment, the monitoring communication interface class may be specifically understood as a communication interface class of another functional component that is selected by the functional component according to an actual service requirement and needs to monitor the publishing information of the functional component. For example, the functional component 1 needs to monitor the functional components 2 and 3, and the functional component 1 sends the communication interface classes of the functional components 2 and 3 to the message bus as the monitoring communication interface classes, so as to implement monitoring on the functional components 2 and 3.
Specifically, the service layer prestores service logic interface classes corresponding to the functional components, the functional components select monitoring communication interface classes from the service logic interface classes prestored in the service layer according to actual service requirements and send the monitoring communication interface classes, and the message bus receives the monitoring communication interface classes sent by the functional components.
S220, aiming at the first functional component of each sending monitoring communication interface class, storing the monitoring communication interface class and the first functional component in the first message monitoring table in an associated mode.
In this embodiment, the first functional component may be specifically understood as a functional component that is an information listener.
Specifically, the first functional component serving as the message listener, i.e., the message receiver, sends the listening communication interface class to the message bus, i.e., it is described that the first functional component needs to perform message listening on the functional component corresponding to the listening communication interface class, that is, if the functional component corresponding to the listening communication interface class and serving as the message issuer issues a message to the message bus, the message bus sends the message to the first functional component (the message listener). When the message bus receives the monitoring communication interface class sent by the first functional component, the corresponding relation between the monitoring communication interface class and the first functional component is stored in a first message monitoring table, so that a message receiver can be found when the components communicate.
In this embodiment, the functional components implement functional division according to services, and in practical application, the functional component may be the first functional component, which is used as an information monitoring party to monitor information issued by other functional components, or may be used as an information issuing party to issue information, so that other functional components monitor the information.
Further, in the embodiment of the present invention, if the message request message includes a first key identifier used for inter-component communication, a target function component associated with the first key identifier is obtained from a predetermined first message listening table, so that a request operation that the target function component responds to the message request message is specifically: if the message request message contains a first key identifier for communication among the components, the first key identifier is a first service logic interface class which is depended by the functional component for sending the message request message; correspondingly, the obtaining of the target functional component as a message responder from a predetermined first message listening table according to the first key identifier includes: determining a target listening communication interface class matching the first service logic interface class from the first message listening table; and acquiring a first functional component associated with the target monitoring communication interface class in the first message monitoring table, and recording as a target functional component responding to the message request message.
Fig. 3 provides an implementation flowchart of obtaining a target function component in a communication method of components in an application program, which specifically includes the following steps:
S310, if the message request message contains a first key identifier for inter-component communication, the first key identifier is a first service logic interface class depended by a functional component sending the message request message, and a target monitoring communication interface class matched with the first service logic interface class is determined from the first message monitoring table.
In this embodiment, the first service logic interface class may be specifically understood as a service logic interface class to which a functional component serving as a message publisher belongs; the target listening communication interface class may be specifically understood as a listening communication interface class in the first message listening table that is correspondingly matched with the first service logic interface class.
Specifically, the message request message sent by the functional component includes a first key identifier, and the first key identifier identifies a first service logic interface class of the functional component itself, and searches for a monitoring communication interface class in the first message monitoring table according to the first service logic interface class, and uses the matched monitoring communication interface class as a target monitoring communication interface class.
And S320, acquiring a first functional component associated with the target monitoring communication interface class in the first message monitoring table, and recording as a target functional component responding to the message request message.
Specifically, according to the association relationship between the monitoring communication interface class and the first functional component in the first message monitoring table, the first functional component corresponding to the target monitoring communication interface class is determined, and the first functional component is marked as the target functional component.
The embodiment of the invention provides a communication method of a component in an application program, which associates a first key identifier with a target function component by pre-forming a first message monitoring table, realizes the effective tracing of the source and the destination of a message in the communication process of the function component, and avoids the problem that an event cannot be traced in the original message bus communication mode. Identifying the functional component by using the first key identification to determine a message source according to the first key identification; the first message monitoring table can be used for defining a receiver of the message request message, the definition of event flow in the whole message transmission process is improved, the event flow process is defined, and the first message monitoring table is concise in code and has high-efficiency decoupling performance.
Example two
Fig. 4 is a flowchart of a communication method of components in an application according to a second embodiment of the present invention. The technical scheme of the embodiment is further detailed on the basis of the technical scheme, and specifically mainly comprises the following steps:
S410, analyzing the received message request message.
Specifically, a message request message sent by a functional component serving as a message publisher is analyzed to obtain identification information of a message receiver.
S420, if the message request message contains a second key identifier for communication in the component, acquiring a target component sub-service associated with the second key identifier from a predetermined second message monitoring table, so that the target component sub-service responds to a request operation corresponding to the message request message.
In this embodiment, the second key identifier is different from the first key identifier, and the second message listening table is formed based on an implementation class included in each of the functional components.
In this embodiment, the second key identifier may be specifically understood as an identifier for distinguishing different sub-service modules in different functional components, and is used for communication of the sub-service modules inside the components, where the different sub-service modules have unique and different second key identifiers, and the second key identifier is a specific implementation class of a communication interface. The second message listening table may be specifically understood as a data table storing the second key identifier and the target component sub-services according to the corresponding relationship, where one or more target component sub-services corresponding to the second key identifier may be determined according to actual service requirements. The target component sub-service may be specifically understood as a sub-service module in a functional component as a receiver of a message request message.
Specifically, the sub-service modules in each functional component of the application program send their own implementation classes to the message bus, and one sub-service module corresponds to one implementation class. When the sub-service module 1 wants to monitor the messages of other sub-service modules in the functional component, it first sends its own implementation class to the message bus and registers in the message bus. The message bus classifies and stores the received implementation classes of different sub-service modules in the form of the functional components, and establishes a second message monitoring table by using other sub-service modules of the monitoring sub-service module as the target component sub-service and associating the target component sub-service with the second key identifier of the sub-service module. And the message bus analyzes the message request message, acquires the identifier of the sub-service module in the message request message, and if the identifier contained in the message request message is the second key identifier, the message at the moment only needs to be sent inside the component to carry out communication in the component. And determining a target component sub-service corresponding to the second key identifier according to the predetermined association relationship between the second key identifier in the second message monitoring table and the target component sub-service, sending a message request message to the target component sub-service, and executing corresponding operation after the target component sub-service receives the message request message.
The embodiment of the invention provides a communication method of a component in an application program, which associates a second key identifier with a target sub-service by pre-forming a second message monitoring table, realizes the effective tracing of the source and the destination of a message during the communication between sub-service modules in a functional component, and avoids the problem that an event cannot be traced in the original message bus communication mode. Identifying the target sub-service by using a second key identifier to determine a message source according to the second key identifier; the receiver of the message request message can be defined through the second message monitoring table, the definition of event flow in the whole message transmission process is improved, the event flow process is defined, and the code is concise and has high-efficiency decoupling performance.
Further, an embodiment of the present invention provides a preferred embodiment, and fig. 5 provides an implementation flowchart of forming a second message monitoring table in a communication method of a component in an application program, where the forming of the second message monitoring table is further detailed on the basis of the foregoing technical solution, and specifically, the method mainly includes the following steps:
s510, receiving a sub-service implementation class sent by a functional component in an application program, wherein the sub-service implementation class is the implementation class of the sub-service included in the corresponding functional component.
In this embodiment, the sub-service implementation class may be specifically understood as a specific implementation class defined for a service logic interface of each sub-service module included in the functional component. When the functional component is a login component, the sub-services included in the functional component can be password login, WeChat login, verification code login and the like.
Specifically, the sub-service in the functional component in the application program wants to monitor other sub-services in the component, that is, to receive information sent by other sub-services, it needs to send its own sub-service implementation class to the message bus first, and the message bus receives the sub-service implementation class sent by the functional component, so as to establish a second message monitoring table subsequently.
S520, aiming at the second functional component of each sending sub-service implementation class, a second message monitoring table corresponding to the second functional component is created.
In this embodiment, the second functional component may be specifically understood as any functional component in which one or more sub-services are included in an application program, and the sub-services have a requirement for mutual communication.
Specifically, when the sub-services in the second functional component need to communicate with each other, the second functional component sends each sub-service implementation class of the sub-service that needs to monitor other sub-services to the message bus, and creates a corresponding second message monitoring table according to the difference of the second functional components to which the sub-services belong. For example, the second functional component 10 includes a sub-service 11, a sub-service 12, a sub-service 13, and a sub-service 14, where the sub-service 11, the sub-service 12, and the sub-service 13 need to listen to messages issued by other sub-services in the second functional component 10, the second functional component 10 sends the sub-service implementation classes of the sub-service 11, the sub-service 12, and the sub-service 13 to the message bus, and the sub-service 14 does not need to listen to other sub-services and therefore does not need to send its sub-service implementation class to the message bus, and the message bus does not send messages issued by the sub-service 11, the sub-service 12, and the sub-service 13 to the sub-service 14. When the second functional component 10 sends the sub-service implementation class, the identifier representing the second functional component is carried, for example, the service logic interface class of the second functional component 10, so that the message bus can distinguish the sub-service implementation classes sent by different functional components. And the message bus establishes a second message monitoring table corresponding to the second functional component according to the second functional component to which the sub-service implementation class belongs.
S530, aiming at each sub-service implementation class in the second functional component, determining each sub-service in the second functional component corresponding to each sub-service implementation class as a target sub-service, and storing the sub-service implementation class and the corresponding target sub-service in the second message monitoring table in an associated manner.
In this embodiment, the target sub-service may be specifically understood as a sub-service module in the second functional component, which monitors requirements of other sub-services in the component, where one or more target sub-services correspond to one sub-service implementation class.
Specifically, each sub-service implementation class sent by the second functional component to the message bus needs to monitor communication information in the second functional component, that is, other sub-services in the sub-service monitoring component identified by the sub-service implementation class. And the sub-service identified by each sub-service realization class sent to the message bus in the second functional component is the target sub-service, and the sub-service realization class and the corresponding target sub-service are stored in a second message monitoring table in an associated manner. For example, the message bus receives the sub-service implementation classes IServiceImpI11, IServiceImpI12 and IServiceImpI13, and identifies the sub-service 11, the sub-service 12 and the sub-service 13 respectively, so as to establish an association relationship between the IServiceImpI11 and the sub-service 12 and the sub-service 13, an association relationship between the IServiceImpI12 and the sub-service 11 and the sub-service 13, and an association relationship between the IServiceImpI13 and the sub-service 11 and the sub-service 12, and store the association relationships in the second message monitoring table. When the message bus receives the information issued by the sub-service 11, the sub-service 12 and the sub-service 13 are determined as target sub-services according to the second message monitoring table. The sub-service that publishes information may also be targeted together with other sub-services.
Further, in the embodiment of the present invention, if the message request message includes a second key identifier used for intra-component communication, a target component sub-service associated with the second key identifier is obtained from a predetermined second message listening table, so that a request operation corresponding to the target component sub-service responding to the message request message is embodied as: if the message request message contains a second key identifier for communication in the component, the second key identifier is a source implementation class of a sub-service in the functional component for sending the message; correspondingly, obtaining the target component sub-service as the message responder from a predetermined second message listening table according to the second key identifier, including: determining a second message monitoring table corresponding to the functional component to which the source implementation class belongs; determining a target sub-service implementation class matched with the source implementation class from the second message monitoring table; and acquiring the target sub-service associated with the target sub-service implementation class in the second message monitoring table, and recording as the target component sub-service responding to the message request message.
Fig. 6 provides an implementation flowchart of obtaining a target component sub-service in a communication method of a component in an application program, which specifically includes the following steps:
S610, if the message request message contains a second key identification used for communication in the component, the second key identification is a source implementation class of a sub-service in the functional component sending the message request message, and a second message monitoring table corresponding to the functional component to which the source implementation class belongs is determined.
In this embodiment, the source implementation class may be specifically understood as a sub-service implementation class that a sub-service issuing a message has.
Specifically, if a message request message received by the message bus includes a second key identifier and the second identifier is a source implementation class of a sub-service in the functional component that sends the message request message, the source implementation class carried in the message request message is obtained by parsing the message request message, the functional component to which the sub-service that issues the message request message belongs is determined, and a second message monitoring table corresponding to the functional component is further determined.
S620, determining the target sub-service implementation class matched with the source implementation class from the second message monitoring table.
In this embodiment, the target sub-service implementation class may be specifically understood as a sub-service implementation class corresponding to the source implementation class in the second message listening table.
Specifically, the sub-service implementation class in the second message monitoring table is searched according to the source implementation class, and the corresponding matched sub-service implementation class is used as the target sub-service implementation class.
S630, obtaining the target sub-service related to the target sub-service realization class in the second message monitoring table, and recording as the target component sub-service responding to the message request message.
Specifically, the target sub-service corresponding to the target sub-service implementation class is determined according to the association relationship between the target sub-service implementation class and the target sub-service in the second message monitoring table, and the target sub-service is used as the target component sub-service.
Further, the communication method of the components in the application program further comprises the following steps: when the corresponding functions of the functional components in the application program are triggered, forming the second message monitoring table; and when the triggering of the corresponding function inhibition of the functional component in the application program is monitored, the second message monitoring table is cancelled.
Specifically, the manner in which the corresponding function of the functional component in the application program is triggered may be that a certain function in the application program is entered by clicking a button or icon of the functional component in the application program; the corresponding function prohibition triggering mode of the functional component in the application program may be to exit a certain function in the application program, enter other functions in the application program, or exit the application program. Taking the wechat application program as an example, when the setting function in the wechat is clicked, the corresponding function of the setting function component is triggered to form a second message monitoring table, so as to facilitate the subsequent intra-component communication of the setting function component. And when the setting interface is quitted or the WeChat interface is quitted, the second message monitoring table is cancelled.
The embodiment of the invention provides a communication method of a component in an application program, which associates a second key identifier with a target sub-service by pre-forming a second message monitoring table, realizes the effective tracing of the source and the destination of a message during the communication between sub-service modules in a functional component, and avoids the problem that an event cannot be traced in the original message bus communication mode. The second message monitoring table is established to provide message transmission basis for each sub-service communication in the component, so that the source and the destination of the message are effectively determined, the definition of event flow in the whole message transmission process is improved, the event flow process is determined, and the code is concise and has high-efficiency decoupling. And when the corresponding function of the functional component in the application program is monitored to be prohibited to trigger in the communication process, the second message monitoring table is cancelled, so that the life cycle of the message transmission process in the message transmission process is consistent with that of the page, and the condition that the message transmission time is still triggered after the page is destroyed can not occur.
EXAMPLE III
Fig. 7 is a structural diagram of a communication device of a component in an application according to a third embodiment of the present invention, where the device includes: a message parsing module 71 and a component acquisition module 72.
In this embodiment, the message parsing module 71 is configured to parse a received message request message; a component obtaining module 72, configured to, if the message request message includes a first key identifier used for inter-component communication, obtain, from a predetermined first message monitoring table, a target function component associated with the first key identifier, so that the target function component responds to a request operation corresponding to the message request message; the first message monitoring table is formed based on the business logic interface class which is depended by the functional component in the application program at the business service layer.
The embodiment of the invention provides a communication device of a component in an application program, which analyzes a received message request message; if the message request message contains a first key identifier for inter-component communication, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message; the first message monitoring table is formed based on the business logic interface class which is depended by the functional component in the application program at the business service layer. The first key identification and the target functional component are associated by establishing a first message monitoring table, so that the target functional component can be effectively acquired in the communication process, the functional component is identified by using the first key identification, and the first key identification is carried in the communication process, so that the functional component serving as a message receiver can determine a message source according to the first key identification after receiving the message; the receiver of the message request message containing the first key identification can be made clear through the first message monitoring table, the definition of event transfer in the whole message transfer process is improved, the event transfer process is made clear, and the message monitoring table is concise in code and has high-efficiency decoupling performance.
Further, the apparatus further comprises:
the first message monitoring table forming module is used for receiving monitoring communication interface classes sent by functional components in an application program, and each monitoring communication interface class is a business logic interface class which is depended by the corresponding functional component on a business service layer; for a first functional component of each sending listening communication interface class, storing the listening communication interface class in association with the first functional component in the first message listening table.
Further, the first key identifier is a first service logic interface class depended by the functional component that sends the message request packet, and correspondingly, the component obtaining module 72 includes:
and the determining unit is used for determining a target monitoring communication interface class matched with the first service logic interface class from the first message monitoring table.
And the component acquisition unit is used for acquiring the first functional component associated with the target monitoring communication interface class in the first message monitoring table and recording the first functional component as a target functional component responding to the message request message.
Further, the apparatus further comprises:
a sub-service obtaining module, configured to, if the message request message includes a second key identifier for intra-component communication, obtain, from a predetermined second message monitoring table, a target component sub-service associated with the second key identifier, so that the target component sub-service responds to a request operation corresponding to the message request message; the second key identification is different from the first key identification; wherein the second message monitoring table is formed based on the implementation classes contained in the functional components.
Further, the apparatus further comprises:
a second message monitoring table forming module, configured to receive each sub-service implementation class sent by a functional component in an application program, where each sub-service implementation class is an implementation class of a sub-service included in a corresponding functional component; aiming at a second functional component of each sending sub-service implementation class, creating a second message monitoring table corresponding to the second functional component; and aiming at each sub-service implementation class in the second functional component, determining each sub-service corresponding to each sub-service implementation class sent by the second functional component as a target sub-service, and storing the sub-service implementation class and the corresponding target sub-service in the second message monitoring table in an associated manner.
Further, the second key identifier is a source implementation class of a sub-service in the functional component that sends the message request packet; correspondingly, the sub-service obtaining module further comprises:
and the monitoring table determining unit is used for determining a second message monitoring table corresponding to the function component to which the source implementation class belongs.
And the implementation class determining unit is used for determining the target sub-service implementation class matched with the source implementation class from the second message monitoring table.
And the sub-service acquisition unit is used for acquiring the target sub-service associated with the target sub-service implementation class in the second message monitoring table and recording the target sub-service as the target component sub-service responding to the message request message.
Further, the apparatus further comprises:
and the forming module is used for forming the second message monitoring table when monitoring that the corresponding function of the functional component in the application program is triggered.
And the logout module is used for logging out the second message monitoring table when the triggering of the corresponding function prohibition of the functional component in the application program is monitored.
The communication device of the component in the application program provided by the embodiment of the invention can execute the communication method of the component in the application program provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Example four
Fig. 8 is a schematic structural diagram of an apparatus according to a fourth embodiment of the present invention, as shown in fig. 8, the apparatus includes a processor 80, a memory 81, an input device 82, and an output device 83; the number of the processors 80 in the device may be one or more, and one processor 80 is taken as an example in fig. 8; the processor 80, the memory 81, the input device 82 and the output device 83 in the apparatus may be connected by a bus or other means, and the connection by a bus is exemplified in fig. 8.
The memory 81 is used as a computer-readable storage medium for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the communication method of the component in the application program in the embodiment of the present invention (for example, the message parsing module 71 and the component acquisition module 72 in the communication device of the component in the application program). The processor 80 executes various functional applications of the device and data processing, i.e., implements the communication method of the components in the application program described above, by executing software programs, instructions, and modules stored in the memory 81.
The memory 81 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the memory 81 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, the memory 81 may further include memory located remotely from the processor 80, which may be connected to the devices over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 82 is operable to receive input numeric or character information and to generate key signal inputs associated with user settings and function controls. The output device 83 may include a display device such as a display screen.
EXAMPLE five
An embodiment of the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform a communication method for a component in an application, the method being applied to a message bus in a communication framework on which the application depends, and the method including:
Analyzing the received message request message;
if the message request message contains a first key identifier for communication among the components, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message;
the first message listening table is formed based on the business logic interface class depended by the functional component in the application program at the business service layer.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also execute the relevant operations in the communication method of the component in the application program provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the communication apparatus of the component in the application program, each included unit and each module are merely divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be implemented; in addition, the specific names of the functional units are only for the convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
It is to be noted that the foregoing description is only exemplary of the invention and that the principles of the technology may be employed. Those skilled in the art will appreciate that the present invention is not limited to the particular embodiments described herein, and that various obvious changes, rearrangements and substitutions will now be apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in some detail by the above embodiments, the invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the invention, and the scope of the invention is determined by the scope of the appended claims.

Claims (9)

1. A method for communicating components in an application for use in a message bus in a communication framework upon which the application depends, comprising:
Analyzing the received message request message;
if the message request message contains a first key identifier for communication among the components, acquiring a target function component associated with the first key identifier from a predetermined first message monitoring table so that the target function component responds to a request operation corresponding to the message request message;
the first message monitoring table is formed based on a business logic interface class which is depended by a functional component in an application program on a business service layer;
the step of forming the first message listening table comprises:
receiving monitoring communication interface classes sent by functional components in an application program, wherein each monitoring communication interface class is a business logic interface class which is depended by the corresponding functional component on a business service layer;
for a first functional component of each sending listening communication interface class, storing the listening communication interface class in association with the first functional component in the first message listening table.
2. The method of claim 1, wherein the first key identifier is a first service logic interface class on which a functional component that sends the message request packet depends;
correspondingly, the obtaining of the target functional component as a message responder from a predetermined first message listening table according to the first key identifier includes:
Determining a target listening communication interface class matching the first service logic interface class from the first message listening table;
and acquiring a first functional component associated with the target monitoring communication interface class in the first message monitoring table, and recording as a target functional component responding to the message request message.
3. The method of claim 1, further comprising:
if the message request message contains a second key identifier for communication in the component, acquiring a target component sub-service associated with the second key identifier from a predetermined second message monitoring table so that the target component sub-service responds to a request operation corresponding to the message request message;
the second key identifier is different from the first key identifier, and the second message monitoring table is formed based on the implementation classes contained in the functional components.
4. The method of claim 3, wherein the step of forming the second message listening table comprises:
receiving each sub-service implementation class sent by a functional component in an application program, wherein each sub-service implementation class is the implementation class of the sub-service contained in the corresponding functional component;
Aiming at a second functional component of each sending sub-service implementation class, a second message monitoring table corresponding to the second functional component is created;
and aiming at each sub-service implementation class in the second functional component, determining each sub-service corresponding to each sub-service implementation class sent by the second functional component as a target sub-service, and storing the sub-service implementation class and the corresponding target sub-service in the second message monitoring table in an associated manner.
5. The method of claim 4, wherein the second key identifier is a source implementation class of a sub-service in the functional component that sends the message request packet;
correspondingly, obtaining the target component sub-service as the message responder from a predetermined second message listening table according to the second key identifier, including:
determining a second message monitoring table corresponding to the functional component to which the source implementation class belongs;
determining a target sub-service implementation class matched with the source implementation class from the second message monitoring table;
and acquiring the target sub-service associated with the target sub-service implementation class in the second message monitoring table, and recording as the target component sub-service responding to the message request message.
6. The method of claim 3, further comprising:
when the corresponding functions of the functional components in the application program are triggered, forming the second message monitoring table;
and when the triggering of the corresponding function inhibition of the functional component in the application program is monitored, the second message monitoring table is cancelled.
7. A communication device for a component in an application, comprising:
the message analysis module is used for analyzing the received message request message;
the component acquisition module is used for acquiring a target function component associated with a first key identifier from a predetermined first message monitoring table if the message request message contains the first key identifier for communication among components, so that the target function component responds to a request operation corresponding to the message request message;
the first message monitoring table is formed based on a business logic interface class which is depended by a functional component in an application program on a business service layer;
the first message monitoring table forming module is used for receiving monitoring communication interface types sent by functional components in an application program, and each monitoring communication interface type is a business logic interface type which is depended by the corresponding functional component on a business service layer; for a first functional component of each sending listening communication interface class, storing the listening communication interface class in association with the first functional component in the first message listening table.
8. A computer device, characterized in that the device comprises:
one or more processors;
a storage device to store one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method of communication for a component in an application as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a method for communication of components in an application program according to any one of claims 1-6.
CN202010237927.2A 2020-03-30 2020-03-30 Communication method, device, equipment and storage medium of components in application program Active CN111427710B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010237927.2A CN111427710B (en) 2020-03-30 2020-03-30 Communication method, device, equipment and storage medium of components in application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010237927.2A CN111427710B (en) 2020-03-30 2020-03-30 Communication method, device, equipment and storage medium of components in application program

Publications (2)

Publication Number Publication Date
CN111427710A CN111427710A (en) 2020-07-17
CN111427710B true CN111427710B (en) 2022-06-28

Family

ID=71549926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010237927.2A Active CN111427710B (en) 2020-03-30 2020-03-30 Communication method, device, equipment and storage medium of components in application program

Country Status (1)

Country Link
CN (1) CN111427710B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112817779B (en) * 2021-01-29 2024-08-20 京东方科技集团股份有限公司 Modularized application program communication method, device, equipment and medium
CN115022406B (en) * 2022-05-23 2024-06-14 中国南方电网有限责任公司 Communication method, apparatus, device, medium and program product for electric power spot system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107783849A (en) * 2017-09-27 2018-03-09 武汉斗鱼网络科技有限公司 Event-handling method and client
CN110727523A (en) * 2019-09-30 2020-01-24 歌尔股份有限公司 Service request processing method, processing device and readable storage medium
CN110912807A (en) * 2019-11-22 2020-03-24 北京奇艺世纪科技有限公司 Information prompting method and device, electronic equipment and computer readable storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107783849A (en) * 2017-09-27 2018-03-09 武汉斗鱼网络科技有限公司 Event-handling method and client
CN110727523A (en) * 2019-09-30 2020-01-24 歌尔股份有限公司 Service request processing method, processing device and readable storage medium
CN110912807A (en) * 2019-11-22 2020-03-24 北京奇艺世纪科技有限公司 Information prompting method and device, electronic equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN111427710A (en) 2020-07-17

Similar Documents

Publication Publication Date Title
CN111752799B (en) Service link tracking method, device, equipment and storage medium
CN110113381B (en) Method and device for subscribing theme in block chain
CN108833950B (en) Barrage message issuing method, server, system and storage medium
CN112448969B (en) Link tracking method, device, system, equipment and readable storage medium
CN114024972B (en) Long connection communication method, system, device, equipment and storage medium
US9680719B2 (en) Communication system, client terminal, and server
CN113825129B (en) Industrial Internet asset mapping method in 5G network environment
CN107168844B (en) Performance monitoring method and device
CN111427710B (en) Communication method, device, equipment and storage medium of components in application program
US10775751B2 (en) Automatic generation of regular expression based on log line data
CN106713011B (en) Method and system for obtaining test data
CN111581518A (en) Information pushing method and device
CN110602171A (en) Interaction method and device
CN116069838A (en) Data processing method, device, computer equipment and storage medium
CN112118600B (en) Flow traction system under 5G independent networking SA architecture
CN117176802B (en) Full-link monitoring method and device for service request, electronic equipment and medium
CN113468001A (en) Method and device for testing interface processing logic
CN113778709B (en) Interface calling method, device, server and storage medium
CN115269269A (en) Drill method, device, backup server, medium, server cluster and system
CN112950447B (en) Resource scheduling method, device, server and storage medium
CN111585844B (en) Test method, system, server and storage medium based on verification code
CN112291209B (en) Method and device for acquiring front-end equipment catalog
CN112486815B (en) Analysis method and device of application program, server and storage medium
CN117557211B (en) Intelligent financial business processing method, platform and medium based on flow automation
CN115499402B (en) Instant messaging information processing method, terminal and system

Legal Events

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